mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 06:14:35 +00:00
Further separation of window and context.
The context related parts of _GLFWwndconfig have been moved to _GLFWctxconfig and given better names. Window hint and attribute members have been renamed to match.
This commit is contained in:
parent
0701d4ce6e
commit
6d8e78cc95
@ -971,6 +971,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
if (!initializeAppKit())
|
if (!initializeAppKit())
|
||||||
@ -1005,7 +1006,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
if (!createWindow(window, wndconfig))
|
if (!createWindow(window, wndconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
if (!_glfwCreateContext(window, wndconfig, fbconfig))
|
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
[window->nsgl.context setView:window->ns.view];
|
[window->nsgl.context setView:window->ns.view];
|
||||||
|
102
src/context.c
102
src/context.c
@ -87,21 +87,21 @@ static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev)
|
|||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
|
||||||
{
|
{
|
||||||
if (wndconfig->clientAPI != GLFW_OPENGL_API &&
|
if (ctxconfig->api != GLFW_OPENGL_API &&
|
||||||
wndconfig->clientAPI != GLFW_OPENGL_ES_API)
|
ctxconfig->api != GLFW_OPENGL_ES_API)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid client API requested");
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid client API requested");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
if (ctxconfig->api == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if ((wndconfig->glMajor < 1 || wndconfig->glMinor < 0) ||
|
if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
|
||||||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 5) ||
|
(ctxconfig->major == 1 && ctxconfig->minor > 5) ||
|
||||||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 1) ||
|
(ctxconfig->major == 2 && ctxconfig->minor > 1) ||
|
||||||
(wndconfig->glMajor == 3 && wndconfig->glMinor > 3))
|
(ctxconfig->major == 3 && ctxconfig->minor > 3))
|
||||||
{
|
{
|
||||||
// OpenGL 1.0 is the smallest valid version
|
// OpenGL 1.0 is the smallest valid version
|
||||||
// OpenGL 1.x series ended with version 1.5
|
// OpenGL 1.x series ended with version 1.5
|
||||||
@ -110,7 +110,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
"Invalid OpenGL version %i.%i requested",
|
"Invalid OpenGL version %i.%i requested",
|
||||||
wndconfig->glMajor, wndconfig->glMinor);
|
ctxconfig->major, ctxconfig->minor);
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -118,18 +118,18 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
// For now, let everything else through
|
// For now, let everything else through
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile)
|
if (ctxconfig->profile)
|
||||||
{
|
{
|
||||||
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE &&
|
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
|
||||||
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
|
ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
_glfwInputError(GLFW_INVALID_ENUM,
|
||||||
"Invalid OpenGL profile requested");
|
"Invalid OpenGL profile requested");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glMajor < 3 ||
|
if (ctxconfig->major < 3 ||
|
||||||
(wndconfig->glMajor == 3 && wndconfig->glMinor < 2))
|
(ctxconfig->major == 3 && ctxconfig->minor < 2))
|
||||||
{
|
{
|
||||||
// Desktop OpenGL context profiles are only defined for version 3.2
|
// Desktop OpenGL context profiles are only defined for version 3.2
|
||||||
// and above
|
// and above
|
||||||
@ -141,7 +141,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glForward && wndconfig->glMajor < 3)
|
if (ctxconfig->forward && ctxconfig->major < 3)
|
||||||
{
|
{
|
||||||
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
@ -150,11 +150,11 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
else if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||||
{
|
{
|
||||||
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0 ||
|
if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
|
||||||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 1) ||
|
(ctxconfig->major == 1 && ctxconfig->minor > 1) ||
|
||||||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 0))
|
(ctxconfig->major == 2 && ctxconfig->minor > 0))
|
||||||
{
|
{
|
||||||
// OpenGL ES 1.0 is the smallest valid version
|
// OpenGL ES 1.0 is the smallest valid version
|
||||||
// OpenGL ES 1.x series ended with version 1.1
|
// OpenGL ES 1.x series ended with version 1.1
|
||||||
@ -162,7 +162,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
"Invalid OpenGL ES version %i.%i requested",
|
"Invalid OpenGL ES version %i.%i requested",
|
||||||
wndconfig->glMajor, wndconfig->glMinor);
|
ctxconfig->major, ctxconfig->minor);
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -170,7 +170,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
// For now, let everything else through
|
// For now, let everything else through
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile)
|
if (ctxconfig->profile)
|
||||||
{
|
{
|
||||||
// OpenGL ES does not support profiles
|
// OpenGL ES does not support profiles
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
@ -178,7 +178,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glForward)
|
if (ctxconfig->forward)
|
||||||
{
|
{
|
||||||
// OpenGL ES does not support forward-compatibility
|
// OpenGL ES does not support forward-compatibility
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
@ -187,10 +187,10 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glRobustness)
|
if (ctxconfig->robustness)
|
||||||
{
|
{
|
||||||
if (wndconfig->glRobustness != GLFW_NO_RESET_NOTIFICATION &&
|
if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
|
||||||
wndconfig->glRobustness != GLFW_LOSE_CONTEXT_ON_RESET)
|
ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_INVALID_VALUE,
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
"Invalid context robustness mode requested");
|
"Invalid context robustness mode requested");
|
||||||
@ -358,20 +358,20 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
|
GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
||||||
|
|
||||||
if (!parseGLVersion(&window->clientAPI,
|
if (!parseGLVersion(&window->context.api,
|
||||||
&window->glMajor,
|
&window->context.major,
|
||||||
&window->glMinor,
|
&window->context.minor,
|
||||||
&window->glRevision))
|
&window->context.revision))
|
||||||
{
|
{
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_GLFW_USE_OPENGL)
|
#if defined(_GLFW_USE_OPENGL)
|
||||||
if (window->glMajor > 2)
|
if (window->context.major > 2)
|
||||||
{
|
{
|
||||||
// OpenGL 3.0+ uses a different function for extension string retrieval
|
// OpenGL 3.0+ uses a different function for extension string retrieval
|
||||||
// We cache it here instead of in glfwExtensionSupported mostly to alert
|
// We cache it here instead of in glfwExtensionSupported mostly to alert
|
||||||
@ -386,47 +386,47 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->clientAPI == GLFW_OPENGL_API)
|
if (window->context.api == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
// Read back context flags (OpenGL 3.0 and above)
|
// Read back context flags (OpenGL 3.0 and above)
|
||||||
if (window->glMajor >= 3)
|
if (window->context.major >= 3)
|
||||||
{
|
{
|
||||||
GLint flags;
|
GLint flags;
|
||||||
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||||
|
|
||||||
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
|
||||||
window->glForward = GL_TRUE;
|
window->context.forward = GL_TRUE;
|
||||||
|
|
||||||
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||||
window->glDebug = GL_TRUE;
|
window->context.debug = GL_TRUE;
|
||||||
else if (glfwExtensionSupported("GL_ARB_debug_output") &&
|
else if (glfwExtensionSupported("GL_ARB_debug_output") &&
|
||||||
wndconfig->glDebug)
|
ctxconfig->debug)
|
||||||
{
|
{
|
||||||
// HACK: This is a workaround for older drivers (pre KHR_debug)
|
// HACK: This is a workaround for older drivers (pre KHR_debug)
|
||||||
// not setting the debug bit in the context flags for
|
// not setting the debug bit in the context flags for
|
||||||
// debug contexts
|
// debug contexts
|
||||||
window->glDebug = GL_TRUE;
|
window->context.debug = GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read back OpenGL context profile (OpenGL 3.2 and above)
|
// Read back OpenGL context profile (OpenGL 3.2 and above)
|
||||||
if (window->glMajor > 3 ||
|
if (window->context.major > 3 ||
|
||||||
(window->glMajor == 3 && window->glMinor >= 2))
|
(window->context.major == 3 && window->context.minor >= 2))
|
||||||
{
|
{
|
||||||
GLint mask;
|
GLint mask;
|
||||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||||
|
|
||||||
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
||||||
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
|
window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||||
else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
|
else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
|
||||||
window->glProfile = GLFW_OPENGL_CORE_PROFILE;
|
window->context.profile = GLFW_OPENGL_CORE_PROFILE;
|
||||||
else if (glfwExtensionSupported("GL_ARB_compatibility"))
|
else if (glfwExtensionSupported("GL_ARB_compatibility"))
|
||||||
{
|
{
|
||||||
// HACK: This is a workaround for the compatibility profile bit
|
// HACK: This is a workaround for the compatibility profile bit
|
||||||
// not being set in the context flags if an OpenGL 3.2+
|
// not being set in the context flags if an OpenGL 3.2+
|
||||||
// context was created without having requested a specific
|
// context was created without having requested a specific
|
||||||
// version
|
// version
|
||||||
window->glProfile = GLFW_OPENGL_COMPAT_PROFILE;
|
window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,9 +440,9 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
|
|||||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||||
|
|
||||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||||
window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||||
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
||||||
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
|
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -457,9 +457,9 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
|
|||||||
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
|
||||||
|
|
||||||
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
|
||||||
window->glRobustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
|
||||||
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
|
||||||
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
|
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // _GLFW_USE_OPENGL
|
#endif // _GLFW_USE_OPENGL
|
||||||
@ -467,13 +467,13 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
|
|||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLboolean _glfwIsValidContext(const _GLFWwndconfig* wndconfig)
|
GLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
||||||
|
|
||||||
if (window->glMajor < wndconfig->glMajor ||
|
if (window->context.major < ctxconfig->major ||
|
||||||
(window->glMajor == wndconfig->glMajor &&
|
(window->context.major == ctxconfig->major &&
|
||||||
window->glMinor < wndconfig->glMinor))
|
window->context.minor < ctxconfig->minor))
|
||||||
{
|
{
|
||||||
// The desired OpenGL version is greater than the actual version
|
// The desired OpenGL version is greater than the actual version
|
||||||
// This only happens if the machine lacks {GLX|WGL}_ARB_create_context
|
// This only happens if the machine lacks {GLX|WGL}_ARB_create_context
|
||||||
@ -581,7 +581,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->glMajor < 3)
|
if (window->context.major < 3)
|
||||||
{
|
{
|
||||||
// Check if extension is in the old style OpenGL extensions string
|
// Check if extension is in the old style OpenGL extensions string
|
||||||
|
|
||||||
|
@ -301,15 +301,15 @@ void _glfwTerminateContextAPI(void)
|
|||||||
// Prepare for creation of the OpenGL context
|
// Prepare for creation of the OpenGL context
|
||||||
//
|
//
|
||||||
int _glfwCreateContext(_GLFWwindow* window,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
int attribs[40];
|
int attribs[40];
|
||||||
GLXFBConfig native;
|
GLXFBConfig native;
|
||||||
GLXContext share = NULL;
|
GLXContext share = NULL;
|
||||||
|
|
||||||
if (wndconfig->share)
|
if (ctxconfig->share)
|
||||||
share = wndconfig->share->glx.context;
|
share = ctxconfig->share->glx.context;
|
||||||
|
|
||||||
if (!chooseFBConfig(fbconfig, &native))
|
if (!chooseFBConfig(fbconfig, &native))
|
||||||
{
|
{
|
||||||
@ -328,7 +328,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||||
{
|
{
|
||||||
if (!_glfw.glx.ARB_create_context ||
|
if (!_glfw.glx.ARB_create_context ||
|
||||||
!_glfw.glx.ARB_create_context_profile ||
|
!_glfw.glx.ARB_create_context_profile ||
|
||||||
@ -341,7 +341,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glForward)
|
if (ctxconfig->forward)
|
||||||
{
|
{
|
||||||
if (!_glfw.glx.ARB_create_context)
|
if (!_glfw.glx.ARB_create_context)
|
||||||
{
|
{
|
||||||
@ -352,7 +352,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile)
|
if (ctxconfig->profile)
|
||||||
{
|
{
|
||||||
if (!_glfw.glx.ARB_create_context ||
|
if (!_glfw.glx.ARB_create_context ||
|
||||||
!_glfw.glx.ARB_create_context_profile)
|
!_glfw.glx.ARB_create_context_profile)
|
||||||
@ -370,46 +370,46 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
if (ctxconfig->api == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if (wndconfig->glForward)
|
if (ctxconfig->forward)
|
||||||
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||||
|
|
||||||
if (wndconfig->glDebug)
|
if (ctxconfig->debug)
|
||||||
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
||||||
|
|
||||||
if (wndconfig->glProfile)
|
if (ctxconfig->profile)
|
||||||
{
|
{
|
||||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
||||||
mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||||
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||||
|
|
||||||
if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
|
if (ctxconfig->robustness != GLFW_NO_ROBUSTNESS)
|
||||||
{
|
{
|
||||||
if (_glfw.glx.ARB_create_context_robustness)
|
if (_glfw.glx.ARB_create_context_robustness)
|
||||||
{
|
{
|
||||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||||
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
|
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
|
||||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||||
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
|
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
|
||||||
|
|
||||||
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
{
|
{
|
||||||
// NOTE: Only request an explicitly versioned context when
|
// NOTE: Only request an explicitly versioned context when
|
||||||
// necessary, as explicitly requesting version 1.0 does not
|
// necessary, as explicitly requesting version 1.0 does not
|
||||||
// always return the highest available version
|
// always return the highest available version
|
||||||
|
|
||||||
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||||
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
@ -437,9 +437,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
// context creation with a GLXBadProfileARB error in violation
|
// context creation with a GLXBadProfileARB error in violation
|
||||||
// of the extension spec
|
// of the extension spec
|
||||||
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
|
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
|
||||||
wndconfig->clientAPI == GLFW_OPENGL_API &&
|
ctxconfig->api == GLFW_OPENGL_API &&
|
||||||
wndconfig->glProfile == GLFW_OPENGL_ANY_PROFILE &&
|
ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
|
||||||
wndconfig->glForward == GL_FALSE)
|
ctxconfig->forward == GL_FALSE)
|
||||||
{
|
{
|
||||||
window->glx.context = createLegacyContext(window, native, share);
|
window->glx.context = createLegacyContext(window, native, share);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ typedef struct _GLFWlibraryGLX
|
|||||||
int _glfwInitContextAPI(void);
|
int _glfwInitContextAPI(void);
|
||||||
void _glfwTerminateContextAPI(void);
|
void _glfwTerminateContextAPI(void);
|
||||||
int _glfwCreateContext(_GLFWwindow* window,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyContext(_GLFWwindow* window);
|
void _glfwDestroyContext(_GLFWwindow* window);
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
typedef struct _GLFWhints _GLFWhints;
|
typedef struct _GLFWhints _GLFWhints;
|
||||||
typedef struct _GLFWwndconfig _GLFWwndconfig;
|
typedef struct _GLFWwndconfig _GLFWwndconfig;
|
||||||
|
typedef struct _GLFWctxconfig _GLFWctxconfig;
|
||||||
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
typedef struct _GLFWfbconfig _GLFWfbconfig;
|
||||||
typedef struct _GLFWwindow _GLFWwindow;
|
typedef struct _GLFWwindow _GLFWwindow;
|
||||||
typedef struct _GLFWlibrary _GLFWlibrary;
|
typedef struct _GLFWlibrary _GLFWlibrary;
|
||||||
@ -135,11 +136,11 @@ typedef struct _GLFWmonitor _GLFWmonitor;
|
|||||||
// Internal types
|
// Internal types
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
/*! @brief Window and context configuration.
|
/*! @brief Window configuration.
|
||||||
*
|
*
|
||||||
* Parameters relating to the creation of the context and window but not
|
* Parameters relating to the creation of the window but not directly related
|
||||||
* directly related to the framebuffer. This is used to pass window and
|
* to the framebuffer. This is used to pass context creation parameters from
|
||||||
* context creation parameters from shared code to the platform API.
|
* shared code to the platform API.
|
||||||
*/
|
*/
|
||||||
struct _GLFWwndconfig
|
struct _GLFWwndconfig
|
||||||
{
|
{
|
||||||
@ -149,14 +150,25 @@ struct _GLFWwndconfig
|
|||||||
GLboolean resizable;
|
GLboolean resizable;
|
||||||
GLboolean visible;
|
GLboolean visible;
|
||||||
GLboolean decorated;
|
GLboolean decorated;
|
||||||
int clientAPI;
|
|
||||||
int glMajor;
|
|
||||||
int glMinor;
|
|
||||||
GLboolean glForward;
|
|
||||||
GLboolean glDebug;
|
|
||||||
int glProfile;
|
|
||||||
int glRobustness;
|
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*! @brief Context configuration.
|
||||||
|
*
|
||||||
|
* Parameters relating to the creation of the context but not directly related
|
||||||
|
* to the framebuffer. This is used to pass context creation parameters from
|
||||||
|
* shared code to the platform API.
|
||||||
|
*/
|
||||||
|
struct _GLFWctxconfig
|
||||||
|
{
|
||||||
|
int api;
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
|
GLboolean forward;
|
||||||
|
GLboolean debug;
|
||||||
|
int profile;
|
||||||
|
int robustness;
|
||||||
_GLFWwindow* share;
|
_GLFWwindow* share;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,11 +228,14 @@ struct _GLFWwindow
|
|||||||
char key[GLFW_KEY_LAST + 1];
|
char key[GLFW_KEY_LAST + 1];
|
||||||
|
|
||||||
// OpenGL extensions and context attributes
|
// OpenGL extensions and context attributes
|
||||||
int clientAPI;
|
struct {
|
||||||
int glMajor, glMinor, glRevision;
|
int api;
|
||||||
GLboolean glForward, glDebug;
|
int major, minor, revision;
|
||||||
int glProfile;
|
GLboolean forward, debug;
|
||||||
int glRobustness;
|
int profile;
|
||||||
|
int robustness;
|
||||||
|
} context;
|
||||||
|
|
||||||
#if defined(_GLFW_USE_OPENGL)
|
#if defined(_GLFW_USE_OPENGL)
|
||||||
PFNGLGETSTRINGIPROC GetStringi;
|
PFNGLGETSTRINGIPROC GetStringi;
|
||||||
#endif
|
#endif
|
||||||
@ -293,13 +308,13 @@ struct _GLFWlibrary
|
|||||||
int samples;
|
int samples;
|
||||||
GLboolean sRGB;
|
GLboolean sRGB;
|
||||||
int refreshRate;
|
int refreshRate;
|
||||||
int clientAPI;
|
int api;
|
||||||
int glMajor;
|
int major;
|
||||||
int glMinor;
|
int minor;
|
||||||
GLboolean glForward;
|
GLboolean forward;
|
||||||
GLboolean glDebug;
|
GLboolean debug;
|
||||||
int glProfile;
|
int profile;
|
||||||
int glRobustness;
|
int robustness;
|
||||||
} hints;
|
} hints;
|
||||||
|
|
||||||
double cursorPosX, cursorPosY;
|
double cursorPosX, cursorPosY;
|
||||||
@ -457,6 +472,7 @@ void _glfwPlatformSetTime(double time);
|
|||||||
*/
|
*/
|
||||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
|
|
||||||
/*! @ingroup platform
|
/*! @ingroup platform
|
||||||
@ -728,14 +744,14 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
unsigned int count);
|
unsigned int count);
|
||||||
|
|
||||||
/*! @brief Retrieves the attributes of the current context.
|
/*! @brief Retrieves the attributes of the current context.
|
||||||
* @param[in] wndconfig The desired context attributes.
|
* @param[in] ctxconfig The desired context attributes.
|
||||||
* @return `GL_TRUE` if successful, or `GL_FALSE` if the context is unusable.
|
* @return `GL_TRUE` if successful, or `GL_FALSE` if the context is unusable.
|
||||||
* @ingroup utility
|
* @ingroup utility
|
||||||
*/
|
*/
|
||||||
GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig);
|
GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig);
|
||||||
|
|
||||||
/*! @brief Checks whether the desired context attributes are valid.
|
/*! @brief Checks whether the desired context attributes are valid.
|
||||||
* @param[in] wndconfig The context attributes to check.
|
* @param[in] ctxconfig The context attributes to check.
|
||||||
* @return `GL_TRUE` if the context attributes are valid, or `GL_FALSE`
|
* @return `GL_TRUE` if the context attributes are valid, or `GL_FALSE`
|
||||||
* otherwise.
|
* otherwise.
|
||||||
* @ingroup utility
|
* @ingroup utility
|
||||||
@ -744,16 +760,16 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig);
|
|||||||
* exists and whether all relevant options have supported and non-conflicting
|
* exists and whether all relevant options have supported and non-conflicting
|
||||||
* values.
|
* values.
|
||||||
*/
|
*/
|
||||||
GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig);
|
GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
|
||||||
|
|
||||||
/*! @brief Checks whether the current context fulfils the specified hard
|
/*! @brief Checks whether the current context fulfils the specified hard
|
||||||
* constraints.
|
* constraints.
|
||||||
* @param[in] wndconfig The desired context attributes.
|
* @param[in] ctxconfig The desired context attributes.
|
||||||
* @return `GL_TRUE` if the context fulfils the hard constraints, or `GL_FALSE`
|
* @return `GL_TRUE` if the context fulfils the hard constraints, or `GL_FALSE`
|
||||||
* otherwise.
|
* otherwise.
|
||||||
* @ingroup utility
|
* @ingroup utility
|
||||||
*/
|
*/
|
||||||
GLboolean _glfwIsValidContext(const _GLFWwndconfig* wndconfig);
|
GLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig);
|
||||||
|
|
||||||
/*! @ingroup utility
|
/*! @ingroup utility
|
||||||
*/
|
*/
|
||||||
|
@ -66,7 +66,7 @@ void _glfwTerminateContextAPI(void)
|
|||||||
// Create the OpenGL context
|
// Create the OpenGL context
|
||||||
//
|
//
|
||||||
int _glfwCreateContext(_GLFWwindow* window,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
unsigned int attributeCount = 0;
|
unsigned int attributeCount = 0;
|
||||||
@ -78,7 +78,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
else if (colorBits < 15)
|
else if (colorBits < 15)
|
||||||
colorBits = 15;
|
colorBits = 15;
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
if (ctxconfig->api == GLFW_OPENGL_ES_API)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSGL: This API does not support OpenGL ES");
|
"NSGL: This API does not support OpenGL ES");
|
||||||
@ -86,7 +86,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
if (wndconfig->glMajor == 3 && wndconfig->glMinor < 2)
|
if (ctxconfig->major == 3 && ctxconfig->minor < 2)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSGL: The targeted version of OS X does not "
|
"NSGL: The targeted version of OS X does not "
|
||||||
@ -94,9 +94,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glMajor > 2)
|
if (ctxconfig->major > 2)
|
||||||
{
|
{
|
||||||
if (!wndconfig->glForward)
|
if (!ctxconfig->forward)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSGL: The targeted version of OS X only "
|
"NSGL: The targeted version of OS X only "
|
||||||
@ -105,7 +105,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE)
|
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSGL: The targeted version of OS X only "
|
"NSGL: The targeted version of OS X only "
|
||||||
@ -116,7 +116,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Fail if OpenGL 3.0 or above was requested
|
// Fail if OpenGL 3.0 or above was requested
|
||||||
if (wndconfig->glMajor > 2)
|
if (ctxconfig->major > 2)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSGL: The targeted version of OS X does not "
|
"NSGL: The targeted version of OS X does not "
|
||||||
@ -126,7 +126,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
|
||||||
// Fail if a robustness strategy was requested
|
// Fail if a robustness strategy was requested
|
||||||
if (wndconfig->glRobustness)
|
if (ctxconfig->robustness)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"NSGL: OS X does not support OpenGL robustness "
|
"NSGL: OS X does not support OpenGL robustness "
|
||||||
@ -144,7 +144,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
if (wndconfig->glMajor > 2)
|
if (ctxconfig->major > 2)
|
||||||
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
|
||||||
@ -196,8 +196,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
|
|
||||||
NSOpenGLContext* share = NULL;
|
NSOpenGLContext* share = NULL;
|
||||||
|
|
||||||
if (wndconfig->share)
|
if (ctxconfig->share)
|
||||||
share = wndconfig->share->nsgl.context;
|
share = ctxconfig->share->nsgl.context;
|
||||||
|
|
||||||
window->nsgl.context =
|
window->nsgl.context =
|
||||||
[[NSOpenGLContext alloc] initWithFormat:window->nsgl.pixelFormat
|
[[NSOpenGLContext alloc] initWithFormat:window->nsgl.pixelFormat
|
||||||
|
@ -68,7 +68,7 @@ typedef struct _GLFWlibraryNSGL
|
|||||||
int _glfwInitContextAPI(void);
|
int _glfwInitContextAPI(void);
|
||||||
void _glfwTerminateContextAPI(void);
|
void _glfwTerminateContextAPI(void);
|
||||||
int _glfwCreateContext(_GLFWwindow* window,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyContext(_GLFWwindow* window);
|
void _glfwDestroyContext(_GLFWwindow* window);
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ void _glfwTerminateContextAPI(void)
|
|||||||
// Prepare for creation of the OpenGL context
|
// Prepare for creation of the OpenGL context
|
||||||
//
|
//
|
||||||
int _glfwCreateContext(_GLFWwindow* window,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
int attribs[40];
|
int attribs[40];
|
||||||
@ -355,8 +355,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
HGLRC share = NULL;
|
HGLRC share = NULL;
|
||||||
|
|
||||||
if (wndconfig->share)
|
if (ctxconfig->share)
|
||||||
share = wndconfig->share->wgl.context;
|
share = ctxconfig->share->wgl.context;
|
||||||
|
|
||||||
window->wgl.dc = GetDC(window->win32.handle);
|
window->wgl.dc = GetDC(window->win32.handle);
|
||||||
if (!window->wgl.dc)
|
if (!window->wgl.dc)
|
||||||
@ -388,42 +388,42 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
if (ctxconfig->api == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if (wndconfig->glForward)
|
if (ctxconfig->forward)
|
||||||
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||||
|
|
||||||
if (wndconfig->glDebug)
|
if (ctxconfig->debug)
|
||||||
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
||||||
|
|
||||||
if (wndconfig->glProfile)
|
if (ctxconfig->profile)
|
||||||
{
|
{
|
||||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
||||||
mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||||
mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
|
mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||||
|
|
||||||
if (wndconfig->glRobustness)
|
if (ctxconfig->robustness)
|
||||||
{
|
{
|
||||||
if (window->wgl.ARB_create_context_robustness)
|
if (window->wgl.ARB_create_context_robustness)
|
||||||
{
|
{
|
||||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||||
strategy = WGL_NO_RESET_NOTIFICATION_ARB;
|
strategy = WGL_NO_RESET_NOTIFICATION_ARB;
|
||||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||||
strategy = WGL_LOSE_CONTEXT_ON_RESET_ARB;
|
strategy = WGL_LOSE_CONTEXT_ON_RESET_ARB;
|
||||||
|
|
||||||
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
{
|
{
|
||||||
setWGLattrib(WGL_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
setWGLattrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||||
setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags)
|
if (flags)
|
||||||
@ -497,14 +497,14 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
|||||||
// Analyzes the specified context for possible recreation
|
// Analyzes the specified context for possible recreation
|
||||||
//
|
//
|
||||||
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
GLboolean required = GL_FALSE;
|
GLboolean required = GL_FALSE;
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
if (ctxconfig->api == GLFW_OPENGL_API)
|
||||||
{
|
{
|
||||||
if (wndconfig->glForward)
|
if (ctxconfig->forward)
|
||||||
{
|
{
|
||||||
if (!window->wgl.ARB_create_context)
|
if (!window->wgl.ARB_create_context)
|
||||||
{
|
{
|
||||||
@ -518,7 +518,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
|
|||||||
required = GL_TRUE;
|
required = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile)
|
if (ctxconfig->profile)
|
||||||
{
|
{
|
||||||
if (!window->wgl.ARB_create_context_profile)
|
if (!window->wgl.ARB_create_context_profile)
|
||||||
{
|
{
|
||||||
@ -546,13 +546,13 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
|
|||||||
required = GL_TRUE;
|
required = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
||||||
{
|
{
|
||||||
if (window->wgl.ARB_create_context)
|
if (window->wgl.ARB_create_context)
|
||||||
required = GL_TRUE;
|
required = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glDebug)
|
if (ctxconfig->debug)
|
||||||
{
|
{
|
||||||
if (window->wgl.ARB_create_context)
|
if (window->wgl.ARB_create_context)
|
||||||
required = GL_TRUE;
|
required = GL_TRUE;
|
||||||
|
@ -92,11 +92,11 @@ typedef struct _GLFWlibraryWGL
|
|||||||
int _glfwInitContextAPI(void);
|
int _glfwInitContextAPI(void);
|
||||||
void _glfwTerminateContextAPI(void);
|
void _glfwTerminateContextAPI(void);
|
||||||
int _glfwCreateContext(_GLFWwindow* window,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
void _glfwDestroyContext(_GLFWwindow* window);
|
void _glfwDestroyContext(_GLFWwindow* window);
|
||||||
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
|
|
||||||
#endif // _wgl_platform_h_
|
#endif // _wgl_platform_h_
|
||||||
|
@ -841,6 +841,7 @@ static ATOM registerWindowClass(void)
|
|||||||
//
|
//
|
||||||
static int createWindow(_GLFWwindow* window,
|
static int createWindow(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
int xpos, ypos, fullWidth, fullHeight;
|
int xpos, ypos, fullWidth, fullHeight;
|
||||||
@ -919,7 +920,7 @@ static int createWindow(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_glfwCreateContext(window, wndconfig, fbconfig))
|
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
@ -945,6 +946,7 @@ static void destroyWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
@ -956,10 +958,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!createWindow(window, wndconfig, fbconfig))
|
if (!createWindow(window, wndconfig, ctxconfig, fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
status = _glfwAnalyzeContext(window, wndconfig, fbconfig);
|
status = _glfwAnalyzeContext(window, ctxconfig, fbconfig);
|
||||||
|
|
||||||
if (status == _GLFW_RECREATION_IMPOSSIBLE)
|
if (status == _GLFW_RECREATION_IMPOSSIBLE)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -991,7 +993,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
destroyWindow(window);
|
destroyWindow(window);
|
||||||
|
|
||||||
// ...and then create them again, this time with better APIs
|
// ...and then create them again, this time with better APIs
|
||||||
if (!createWindow(window, wndconfig, fbconfig))
|
if (!createWindow(window, wndconfig, ctxconfig, fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
63
src/window.c
63
src/window.c
@ -146,6 +146,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
GLFWwindow* share)
|
GLFWwindow* share)
|
||||||
{
|
{
|
||||||
_GLFWfbconfig fbconfig;
|
_GLFWfbconfig fbconfig;
|
||||||
|
_GLFWctxconfig ctxconfig;
|
||||||
_GLFWwndconfig wndconfig;
|
_GLFWwndconfig wndconfig;
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
_GLFWwindow* previous;
|
_GLFWwindow* previous;
|
||||||
@ -181,18 +182,20 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE;
|
wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE;
|
wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.decorated = _glfw.hints.decorated ? GL_TRUE : GL_FALSE;
|
wndconfig.decorated = _glfw.hints.decorated ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.clientAPI = _glfw.hints.clientAPI;
|
|
||||||
wndconfig.glMajor = _glfw.hints.glMajor;
|
|
||||||
wndconfig.glMinor = _glfw.hints.glMinor;
|
|
||||||
wndconfig.glForward = _glfw.hints.glForward ? GL_TRUE : GL_FALSE;
|
|
||||||
wndconfig.glDebug = _glfw.hints.glDebug ? GL_TRUE : GL_FALSE;
|
|
||||||
wndconfig.glProfile = _glfw.hints.glProfile;
|
|
||||||
wndconfig.glRobustness = _glfw.hints.glRobustness;
|
|
||||||
wndconfig.monitor = (_GLFWmonitor*) monitor;
|
wndconfig.monitor = (_GLFWmonitor*) monitor;
|
||||||
wndconfig.share = (_GLFWwindow*) share;
|
|
||||||
|
// Set up desired context config
|
||||||
|
ctxconfig.api = _glfw.hints.api;
|
||||||
|
ctxconfig.major = _glfw.hints.major;
|
||||||
|
ctxconfig.minor = _glfw.hints.minor;
|
||||||
|
ctxconfig.forward = _glfw.hints.forward ? GL_TRUE : GL_FALSE;
|
||||||
|
ctxconfig.debug = _glfw.hints.debug ? GL_TRUE : GL_FALSE;
|
||||||
|
ctxconfig.profile = _glfw.hints.profile;
|
||||||
|
ctxconfig.robustness = _glfw.hints.robustness;
|
||||||
|
ctxconfig.share = (_GLFWwindow*) share;
|
||||||
|
|
||||||
// Check the OpenGL bits of the window config
|
// Check the OpenGL bits of the window config
|
||||||
if (!_glfwIsValidContextConfig(&wndconfig))
|
if (!_glfwIsValidContextConfig(&ctxconfig))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
window = calloc(1, sizeof(_GLFWwindow));
|
window = calloc(1, sizeof(_GLFWwindow));
|
||||||
@ -222,7 +225,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
previous = (_GLFWwindow*) glfwGetCurrentContext();
|
previous = (_GLFWwindow*) glfwGetCurrentContext();
|
||||||
|
|
||||||
// Open the actual window and create its context
|
// Open the actual window and create its context
|
||||||
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig))
|
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
@ -232,7 +235,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
glfwMakeContextCurrent((GLFWwindow*) window);
|
glfwMakeContextCurrent((GLFWwindow*) window);
|
||||||
|
|
||||||
// Retrieve the actual (as opposed to requested) context attributes
|
// Retrieve the actual (as opposed to requested) context attributes
|
||||||
if (!_glfwRefreshContextAttribs(&wndconfig))
|
if (!_glfwRefreshContextAttribs(&ctxconfig))
|
||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
@ -240,7 +243,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify the context against the requested parameters
|
// Verify the context against the requested parameters
|
||||||
if (!_glfwIsValidContext(&wndconfig))
|
if (!_glfwIsValidContext(&ctxconfig))
|
||||||
{
|
{
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
@ -268,9 +271,9 @@ void glfwDefaultWindowHints(void)
|
|||||||
memset(&_glfw.hints, 0, sizeof(_glfw.hints));
|
memset(&_glfw.hints, 0, sizeof(_glfw.hints));
|
||||||
|
|
||||||
// The default is OpenGL with minimum version 1.0
|
// The default is OpenGL with minimum version 1.0
|
||||||
_glfw.hints.clientAPI = GLFW_OPENGL_API;
|
_glfw.hints.api = GLFW_OPENGL_API;
|
||||||
_glfw.hints.glMajor = 1;
|
_glfw.hints.major = 1;
|
||||||
_glfw.hints.glMinor = 0;
|
_glfw.hints.minor = 0;
|
||||||
|
|
||||||
// The default is a visible, resizable window with decorations
|
// The default is a visible, resizable window with decorations
|
||||||
_glfw.hints.resizable = GL_TRUE;
|
_glfw.hints.resizable = GL_TRUE;
|
||||||
@ -347,25 +350,25 @@ GLFWAPI void glfwWindowHint(int target, int hint)
|
|||||||
_glfw.hints.sRGB = hint;
|
_glfw.hints.sRGB = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_CLIENT_API:
|
case GLFW_CLIENT_API:
|
||||||
_glfw.hints.clientAPI = hint;
|
_glfw.hints.api = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_CONTEXT_VERSION_MAJOR:
|
case GLFW_CONTEXT_VERSION_MAJOR:
|
||||||
_glfw.hints.glMajor = hint;
|
_glfw.hints.major = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_CONTEXT_VERSION_MINOR:
|
case GLFW_CONTEXT_VERSION_MINOR:
|
||||||
_glfw.hints.glMinor = hint;
|
_glfw.hints.minor = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_CONTEXT_ROBUSTNESS:
|
case GLFW_CONTEXT_ROBUSTNESS:
|
||||||
_glfw.hints.glRobustness = hint;
|
_glfw.hints.robustness = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_OPENGL_FORWARD_COMPAT:
|
case GLFW_OPENGL_FORWARD_COMPAT:
|
||||||
_glfw.hints.glForward = hint;
|
_glfw.hints.forward = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_OPENGL_DEBUG_CONTEXT:
|
case GLFW_OPENGL_DEBUG_CONTEXT:
|
||||||
_glfw.hints.glDebug = hint;
|
_glfw.hints.debug = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_OPENGL_PROFILE:
|
case GLFW_OPENGL_PROFILE:
|
||||||
_glfw.hints.glProfile = hint;
|
_glfw.hints.profile = hint;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
||||||
@ -555,21 +558,21 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|||||||
case GLFW_VISIBLE:
|
case GLFW_VISIBLE:
|
||||||
return window->visible;
|
return window->visible;
|
||||||
case GLFW_CLIENT_API:
|
case GLFW_CLIENT_API:
|
||||||
return window->clientAPI;
|
return window->context.api;
|
||||||
case GLFW_CONTEXT_VERSION_MAJOR:
|
case GLFW_CONTEXT_VERSION_MAJOR:
|
||||||
return window->glMajor;
|
return window->context.major;
|
||||||
case GLFW_CONTEXT_VERSION_MINOR:
|
case GLFW_CONTEXT_VERSION_MINOR:
|
||||||
return window->glMinor;
|
return window->context.minor;
|
||||||
case GLFW_CONTEXT_REVISION:
|
case GLFW_CONTEXT_REVISION:
|
||||||
return window->glRevision;
|
return window->context.revision;
|
||||||
case GLFW_CONTEXT_ROBUSTNESS:
|
case GLFW_CONTEXT_ROBUSTNESS:
|
||||||
return window->glRobustness;
|
return window->context.robustness;
|
||||||
case GLFW_OPENGL_FORWARD_COMPAT:
|
case GLFW_OPENGL_FORWARD_COMPAT:
|
||||||
return window->glForward;
|
return window->context.forward;
|
||||||
case GLFW_OPENGL_DEBUG_CONTEXT:
|
case GLFW_OPENGL_DEBUG_CONTEXT:
|
||||||
return window->glDebug;
|
return window->context.debug;
|
||||||
case GLFW_OPENGL_PROFILE:
|
case GLFW_OPENGL_PROFILE:
|
||||||
return window->glProfile;
|
return window->context.profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
||||||
|
@ -1054,9 +1054,10 @@ unsigned long _glfwGetWindowProperty(Window window,
|
|||||||
|
|
||||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
|
const _GLFWctxconfig* ctxconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
if (!_glfwCreateContext(window, wndconfig, fbconfig))
|
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
if (!createWindow(window, wndconfig))
|
if (!createWindow(window, wndconfig))
|
||||||
|
Loading…
Reference in New Issue
Block a user