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:
Camilla Berglund 2014-03-06 20:05:32 +01:00
parent 0701d4ce6e
commit 6d8e78cc95
12 changed files with 196 additions and 173 deletions

View File

@ -971,6 +971,7 @@ static GLboolean createWindow(_GLFWwindow* window,
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
if (!initializeAppKit())
@ -1005,7 +1006,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!createWindow(window, wndconfig))
return GL_FALSE;
if (!_glfwCreateContext(window, wndconfig, fbconfig))
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
return GL_FALSE;
[window->nsgl.context setView:window->ns.view];

View File

@ -87,21 +87,21 @@ static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev)
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
{
if (wndconfig->clientAPI != GLFW_OPENGL_API &&
wndconfig->clientAPI != GLFW_OPENGL_ES_API)
if (ctxconfig->api != GLFW_OPENGL_API &&
ctxconfig->api != GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid client API requested");
return GL_FALSE;
}
if (wndconfig->clientAPI == GLFW_OPENGL_API)
if (ctxconfig->api == GLFW_OPENGL_API)
{
if ((wndconfig->glMajor < 1 || wndconfig->glMinor < 0) ||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 5) ||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 1) ||
(wndconfig->glMajor == 3 && wndconfig->glMinor > 3))
if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
(ctxconfig->major == 1 && ctxconfig->minor > 5) ||
(ctxconfig->major == 2 && ctxconfig->minor > 1) ||
(ctxconfig->major == 3 && ctxconfig->minor > 3))
{
// OpenGL 1.0 is the smallest valid version
// OpenGL 1.x series ended with version 1.5
@ -110,7 +110,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL version %i.%i requested",
wndconfig->glMajor, wndconfig->glMinor);
ctxconfig->major, ctxconfig->minor);
return GL_FALSE;
}
else
@ -118,18 +118,18 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
// For now, let everything else through
}
if (wndconfig->glProfile)
if (ctxconfig->profile)
{
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE &&
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid OpenGL profile requested");
return GL_FALSE;
}
if (wndconfig->glMajor < 3 ||
(wndconfig->glMajor == 3 && wndconfig->glMinor < 2))
if (ctxconfig->major < 3 ||
(ctxconfig->major == 3 && ctxconfig->minor < 2))
{
// Desktop OpenGL context profiles are only defined for version 3.2
// 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
_glfwInputError(GLFW_INVALID_VALUE,
@ -150,11 +150,11 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
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 ||
(wndconfig->glMajor == 1 && wndconfig->glMinor > 1) ||
(wndconfig->glMajor == 2 && wndconfig->glMinor > 0))
if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
(ctxconfig->major == 1 && ctxconfig->minor > 1) ||
(ctxconfig->major == 2 && ctxconfig->minor > 0))
{
// OpenGL ES 1.0 is the smallest valid version
// OpenGL ES 1.x series ended with version 1.1
@ -162,7 +162,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL ES version %i.%i requested",
wndconfig->glMajor, wndconfig->glMinor);
ctxconfig->major, ctxconfig->minor);
return GL_FALSE;
}
else
@ -170,7 +170,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
// For now, let everything else through
}
if (wndconfig->glProfile)
if (ctxconfig->profile)
{
// OpenGL ES does not support profiles
_glfwInputError(GLFW_INVALID_VALUE,
@ -178,7 +178,7 @@ GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig)
return GL_FALSE;
}
if (wndconfig->glForward)
if (ctxconfig->forward)
{
// OpenGL ES does not support forward-compatibility
_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 &&
wndconfig->glRobustness != GLFW_LOSE_CONTEXT_ON_RESET)
if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid context robustness mode requested");
@ -358,20 +358,20 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
return closest;
}
GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
if (!parseGLVersion(&window->clientAPI,
&window->glMajor,
&window->glMinor,
&window->glRevision))
if (!parseGLVersion(&window->context.api,
&window->context.major,
&window->context.minor,
&window->context.revision))
{
return GL_FALSE;
}
#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
// 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)
if (window->glMajor >= 3)
if (window->context.major >= 3)
{
GLint flags;
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
window->glForward = GL_TRUE;
window->context.forward = GL_TRUE;
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
window->glDebug = GL_TRUE;
window->context.debug = GL_TRUE;
else if (glfwExtensionSupported("GL_ARB_debug_output") &&
wndconfig->glDebug)
ctxconfig->debug)
{
// HACK: This is a workaround for older drivers (pre KHR_debug)
// not setting the debug bit in the context flags for
// debug contexts
window->glDebug = GL_TRUE;
window->context.debug = GL_TRUE;
}
}
// Read back OpenGL context profile (OpenGL 3.2 and above)
if (window->glMajor > 3 ||
(window->glMajor == 3 && window->glMinor >= 2))
if (window->context.major > 3 ||
(window->context.major == 3 && window->context.minor >= 2))
{
GLint mask;
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
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)
window->glProfile = GLFW_OPENGL_CORE_PROFILE;
window->context.profile = GLFW_OPENGL_CORE_PROFILE;
else if (glfwExtensionSupported("GL_ARB_compatibility"))
{
// HACK: This is a workaround for the compatibility profile bit
// not being set in the context flags if an OpenGL 3.2+
// context was created without having requested a specific
// 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);
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)
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
}
}
else
@ -457,9 +457,9 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
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)
window->glRobustness = GLFW_NO_RESET_NOTIFICATION;
window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
}
}
#endif // _GLFW_USE_OPENGL
@ -467,13 +467,13 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig)
return GL_TRUE;
}
GLboolean _glfwIsValidContext(const _GLFWwndconfig* wndconfig)
GLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig)
{
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
if (window->glMajor < wndconfig->glMajor ||
(window->glMajor == wndconfig->glMajor &&
window->glMinor < wndconfig->glMinor))
if (window->context.major < ctxconfig->major ||
(window->context.major == ctxconfig->major &&
window->context.minor < ctxconfig->minor))
{
// The desired OpenGL version is greater than the actual version
// 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;
}
if (window->glMajor < 3)
if (window->context.major < 3)
{
// Check if extension is in the old style OpenGL extensions string

View File

@ -301,15 +301,15 @@ void _glfwTerminateContextAPI(void)
// Prepare for creation of the OpenGL context
//
int _glfwCreateContext(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int attribs[40];
GLXFBConfig native;
GLXContext share = NULL;
if (wndconfig->share)
share = wndconfig->share->glx.context;
if (ctxconfig->share)
share = ctxconfig->share->glx.context;
if (!chooseFBConfig(fbconfig, &native))
{
@ -328,7 +328,7 @@ int _glfwCreateContext(_GLFWwindow* window,
return GL_FALSE;
}
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
if (ctxconfig->api == GLFW_OPENGL_ES_API)
{
if (!_glfw.glx.ARB_create_context ||
!_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)
{
@ -352,7 +352,7 @@ int _glfwCreateContext(_GLFWwindow* window,
}
}
if (wndconfig->glProfile)
if (ctxconfig->profile)
{
if (!_glfw.glx.ARB_create_context ||
!_glfw.glx.ARB_create_context_profile)
@ -370,46 +370,46 @@ int _glfwCreateContext(_GLFWwindow* window,
{
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;
if (wndconfig->glDebug)
if (ctxconfig->debug)
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;
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
}
}
else
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 (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
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;
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
// necessary, as explicitly requesting version 1.0 does not
// always return the highest available version
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
}
if (mask)
@ -437,9 +437,9 @@ int _glfwCreateContext(_GLFWwindow* window,
// context creation with a GLXBadProfileARB error in violation
// of the extension spec
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
wndconfig->clientAPI == GLFW_OPENGL_API &&
wndconfig->glProfile == GLFW_OPENGL_ANY_PROFILE &&
wndconfig->glForward == GL_FALSE)
ctxconfig->api == GLFW_OPENGL_API &&
ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
ctxconfig->forward == GL_FALSE)
{
window->glx.context = createLegacyContext(window, native, share);
}

View File

@ -124,7 +124,7 @@ typedef struct _GLFWlibraryGLX
int _glfwInitContextAPI(void);
void _glfwTerminateContextAPI(void);
int _glfwCreateContext(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
void _glfwDestroyContext(_GLFWwindow* window);

View File

@ -60,6 +60,7 @@
typedef struct _GLFWhints _GLFWhints;
typedef struct _GLFWwndconfig _GLFWwndconfig;
typedef struct _GLFWctxconfig _GLFWctxconfig;
typedef struct _GLFWfbconfig _GLFWfbconfig;
typedef struct _GLFWwindow _GLFWwindow;
typedef struct _GLFWlibrary _GLFWlibrary;
@ -135,11 +136,11 @@ typedef struct _GLFWmonitor _GLFWmonitor;
// Internal types
//========================================================================
/*! @brief Window and context configuration.
/*! @brief Window configuration.
*
* Parameters relating to the creation of the context and window but not
* directly related to the framebuffer. This is used to pass window and
* context creation parameters from shared code to the platform API.
* Parameters relating to the creation of the window but not directly related
* to the framebuffer. This is used to pass context creation parameters from
* shared code to the platform API.
*/
struct _GLFWwndconfig
{
@ -149,14 +150,25 @@ struct _GLFWwndconfig
GLboolean resizable;
GLboolean visible;
GLboolean decorated;
int clientAPI;
int glMajor;
int glMinor;
GLboolean glForward;
GLboolean glDebug;
int glProfile;
int glRobustness;
_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;
};
@ -216,11 +228,14 @@ struct _GLFWwindow
char key[GLFW_KEY_LAST + 1];
// OpenGL extensions and context attributes
int clientAPI;
int glMajor, glMinor, glRevision;
GLboolean glForward, glDebug;
int glProfile;
int glRobustness;
struct {
int api;
int major, minor, revision;
GLboolean forward, debug;
int profile;
int robustness;
} context;
#if defined(_GLFW_USE_OPENGL)
PFNGLGETSTRINGIPROC GetStringi;
#endif
@ -293,13 +308,13 @@ struct _GLFWlibrary
int samples;
GLboolean sRGB;
int refreshRate;
int clientAPI;
int glMajor;
int glMinor;
GLboolean glForward;
GLboolean glDebug;
int glProfile;
int glRobustness;
int api;
int major;
int minor;
GLboolean forward;
GLboolean debug;
int profile;
int robustness;
} hints;
double cursorPosX, cursorPosY;
@ -457,6 +472,7 @@ void _glfwPlatformSetTime(double time);
*/
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
/*! @ingroup platform
@ -728,14 +744,14 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
unsigned int count);
/*! @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.
* @ingroup utility
*/
GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig);
GLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig);
/*! @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`
* otherwise.
* @ingroup utility
@ -744,16 +760,16 @@ GLboolean _glfwRefreshContextAttribs(const _GLFWwndconfig* wndconfig);
* exists and whether all relevant options have supported and non-conflicting
* values.
*/
GLboolean _glfwIsValidContextConfig(const _GLFWwndconfig* wndconfig);
GLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
/*! @brief Checks whether the current context fulfils the specified hard
* 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`
* otherwise.
* @ingroup utility
*/
GLboolean _glfwIsValidContext(const _GLFWwndconfig* wndconfig);
GLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig);
/*! @ingroup utility
*/

View File

@ -66,7 +66,7 @@ void _glfwTerminateContextAPI(void)
// Create the OpenGL context
//
int _glfwCreateContext(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
unsigned int attributeCount = 0;
@ -78,7 +78,7 @@ int _glfwCreateContext(_GLFWwindow* window,
else if (colorBits < 15)
colorBits = 15;
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
if (ctxconfig->api == GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"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 (wndconfig->glMajor == 3 && wndconfig->glMinor < 2)
if (ctxconfig->major == 3 && ctxconfig->minor < 2)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X does not "
@ -94,9 +94,9 @@ int _glfwCreateContext(_GLFWwindow* window,
return GL_FALSE;
}
if (wndconfig->glMajor > 2)
if (ctxconfig->major > 2)
{
if (!wndconfig->glForward)
if (!ctxconfig->forward)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X only "
@ -105,7 +105,7 @@ int _glfwCreateContext(_GLFWwindow* window,
return GL_FALSE;
}
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE)
if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X only "
@ -116,7 +116,7 @@ int _glfwCreateContext(_GLFWwindow* window,
}
#else
// Fail if OpenGL 3.0 or above was requested
if (wndconfig->glMajor > 2)
if (ctxconfig->major > 2)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of OS X does not "
@ -126,7 +126,7 @@ int _glfwCreateContext(_GLFWwindow* window,
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
// Fail if a robustness strategy was requested
if (wndconfig->glRobustness)
if (ctxconfig->robustness)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: OS X does not support OpenGL robustness "
@ -144,7 +144,7 @@ int _glfwCreateContext(_GLFWwindow* window,
ADD_ATTR(NSOpenGLPFAClosestPolicy);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (wndconfig->glMajor > 2)
if (ctxconfig->major > 2)
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
@ -196,8 +196,8 @@ int _glfwCreateContext(_GLFWwindow* window,
NSOpenGLContext* share = NULL;
if (wndconfig->share)
share = wndconfig->share->nsgl.context;
if (ctxconfig->share)
share = ctxconfig->share->nsgl.context;
window->nsgl.context =
[[NSOpenGLContext alloc] initWithFormat:window->nsgl.pixelFormat

View File

@ -68,7 +68,7 @@ typedef struct _GLFWlibraryNSGL
int _glfwInitContextAPI(void);
void _glfwTerminateContextAPI(void);
int _glfwCreateContext(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
void _glfwDestroyContext(_GLFWwindow* window);

View File

@ -347,7 +347,7 @@ void _glfwTerminateContextAPI(void)
// Prepare for creation of the OpenGL context
//
int _glfwCreateContext(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int attribs[40];
@ -355,8 +355,8 @@ int _glfwCreateContext(_GLFWwindow* window,
PIXELFORMATDESCRIPTOR pfd;
HGLRC share = NULL;
if (wndconfig->share)
share = wndconfig->share->wgl.context;
if (ctxconfig->share)
share = ctxconfig->share->wgl.context;
window->wgl.dc = GetDC(window->win32.handle);
if (!window->wgl.dc)
@ -388,42 +388,42 @@ int _glfwCreateContext(_GLFWwindow* window,
{
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;
if (wndconfig->glDebug)
if (ctxconfig->debug)
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;
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
}
}
else
mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
if (wndconfig->glRobustness)
if (ctxconfig->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;
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;
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_MINOR_VERSION_ARB, wndconfig->glMinor);
setWGLattrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
}
if (flags)
@ -497,14 +497,14 @@ void _glfwDestroyContext(_GLFWwindow* window)
// Analyzes the specified context for possible recreation
//
int _glfwAnalyzeContext(const _GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
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)
{
@ -518,7 +518,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
required = GL_TRUE;
}
if (wndconfig->glProfile)
if (ctxconfig->profile)
{
if (!window->wgl.ARB_create_context_profile)
{
@ -546,13 +546,13 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
required = GL_TRUE;
}
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
{
if (window->wgl.ARB_create_context)
required = GL_TRUE;
}
if (wndconfig->glDebug)
if (ctxconfig->debug)
{
if (window->wgl.ARB_create_context)
required = GL_TRUE;

View File

@ -92,11 +92,11 @@ typedef struct _GLFWlibraryWGL
int _glfwInitContextAPI(void);
void _glfwTerminateContextAPI(void);
int _glfwCreateContext(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
void _glfwDestroyContext(_GLFWwindow* window);
int _glfwAnalyzeContext(const _GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
#endif // _wgl_platform_h_

View File

@ -841,6 +841,7 @@ static ATOM registerWindowClass(void)
//
static int createWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int xpos, ypos, fullWidth, fullHeight;
@ -919,7 +920,7 @@ static int createWindow(_GLFWwindow* window,
return GL_FALSE;
}
if (!_glfwCreateContext(window, wndconfig, fbconfig))
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
return GL_FALSE;
return GL_TRUE;
@ -945,6 +946,7 @@ static void destroyWindow(_GLFWwindow* window)
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
int status;
@ -956,10 +958,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
return GL_FALSE;
}
if (!createWindow(window, wndconfig, fbconfig))
if (!createWindow(window, wndconfig, ctxconfig, fbconfig))
return GL_FALSE;
status = _glfwAnalyzeContext(window, wndconfig, fbconfig);
status = _glfwAnalyzeContext(window, ctxconfig, fbconfig);
if (status == _GLFW_RECREATION_IMPOSSIBLE)
return GL_FALSE;
@ -991,7 +993,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
destroyWindow(window);
// ...and then create them again, this time with better APIs
if (!createWindow(window, wndconfig, fbconfig))
if (!createWindow(window, wndconfig, ctxconfig, fbconfig))
return GL_FALSE;
}

View File

@ -146,6 +146,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
GLFWwindow* share)
{
_GLFWfbconfig fbconfig;
_GLFWctxconfig ctxconfig;
_GLFWwndconfig wndconfig;
_GLFWwindow* window;
_GLFWwindow* previous;
@ -181,18 +182,20 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.visible = _glfw.hints.visible ? 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.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
if (!_glfwIsValidContextConfig(&wndconfig))
if (!_glfwIsValidContextConfig(&ctxconfig))
return NULL;
window = calloc(1, sizeof(_GLFWwindow));
@ -222,7 +225,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
previous = (_GLFWwindow*) glfwGetCurrentContext();
// Open the actual window and create its context
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig))
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
glfwMakeContextCurrent((GLFWwindow*) previous);
@ -232,7 +235,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
glfwMakeContextCurrent((GLFWwindow*) window);
// Retrieve the actual (as opposed to requested) context attributes
if (!_glfwRefreshContextAttribs(&wndconfig))
if (!_glfwRefreshContextAttribs(&ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
glfwMakeContextCurrent((GLFWwindow*) previous);
@ -240,7 +243,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
}
// Verify the context against the requested parameters
if (!_glfwIsValidContext(&wndconfig))
if (!_glfwIsValidContext(&ctxconfig))
{
glfwDestroyWindow((GLFWwindow*) window);
glfwMakeContextCurrent((GLFWwindow*) previous);
@ -268,9 +271,9 @@ void glfwDefaultWindowHints(void)
memset(&_glfw.hints, 0, sizeof(_glfw.hints));
// The default is OpenGL with minimum version 1.0
_glfw.hints.clientAPI = GLFW_OPENGL_API;
_glfw.hints.glMajor = 1;
_glfw.hints.glMinor = 0;
_glfw.hints.api = GLFW_OPENGL_API;
_glfw.hints.major = 1;
_glfw.hints.minor = 0;
// The default is a visible, resizable window with decorations
_glfw.hints.resizable = GL_TRUE;
@ -347,25 +350,25 @@ GLFWAPI void glfwWindowHint(int target, int hint)
_glfw.hints.sRGB = hint;
break;
case GLFW_CLIENT_API:
_glfw.hints.clientAPI = hint;
_glfw.hints.api = hint;
break;
case GLFW_CONTEXT_VERSION_MAJOR:
_glfw.hints.glMajor = hint;
_glfw.hints.major = hint;
break;
case GLFW_CONTEXT_VERSION_MINOR:
_glfw.hints.glMinor = hint;
_glfw.hints.minor = hint;
break;
case GLFW_CONTEXT_ROBUSTNESS:
_glfw.hints.glRobustness = hint;
_glfw.hints.robustness = hint;
break;
case GLFW_OPENGL_FORWARD_COMPAT:
_glfw.hints.glForward = hint;
_glfw.hints.forward = hint;
break;
case GLFW_OPENGL_DEBUG_CONTEXT:
_glfw.hints.glDebug = hint;
_glfw.hints.debug = hint;
break;
case GLFW_OPENGL_PROFILE:
_glfw.hints.glProfile = hint;
_glfw.hints.profile = hint;
break;
default:
_glfwInputError(GLFW_INVALID_ENUM, NULL);
@ -555,21 +558,21 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
case GLFW_VISIBLE:
return window->visible;
case GLFW_CLIENT_API:
return window->clientAPI;
return window->context.api;
case GLFW_CONTEXT_VERSION_MAJOR:
return window->glMajor;
return window->context.major;
case GLFW_CONTEXT_VERSION_MINOR:
return window->glMinor;
return window->context.minor;
case GLFW_CONTEXT_REVISION:
return window->glRevision;
return window->context.revision;
case GLFW_CONTEXT_ROBUSTNESS:
return window->glRobustness;
return window->context.robustness;
case GLFW_OPENGL_FORWARD_COMPAT:
return window->glForward;
return window->context.forward;
case GLFW_OPENGL_DEBUG_CONTEXT:
return window->glDebug;
return window->context.debug;
case GLFW_OPENGL_PROFILE:
return window->glProfile;
return window->context.profile;
}
_glfwInputError(GLFW_INVALID_ENUM, NULL);

View File

@ -1054,9 +1054,10 @@ unsigned long _glfwGetWindowProperty(Window window,
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
if (!_glfwCreateContext(window, wndconfig, fbconfig))
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
return GL_FALSE;
if (!createWindow(window, wndconfig))