1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00

Context property fixes.

This commit is contained in:
Camilla Berglund 2012-08-02 14:42:24 +02:00
parent f274b329d1
commit 59896c327a
3 changed files with 46 additions and 25 deletions

View File

@ -363,9 +363,9 @@ int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
const _GLFWfbconfig* alternatives,
unsigned int count);
void _glfwRefreshContextParams(void);
GLboolean _glfwRefreshContextParams(void);
GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig);
GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig);
GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig);
#endif // _internal_h_

View File

@ -38,7 +38,7 @@
// Parses the OpenGL version string and extracts the version number
//========================================================================
static void parseGLVersion(int* major, int* minor, int* rev)
static GLboolean parseGLVersion(int* major, int* minor, int* rev)
{
GLuint _major, _minor = 0, _rev = 0;
const GLubyte* version;
@ -47,7 +47,10 @@ static void parseGLVersion(int* major, int* minor, int* rev)
version = glGetString(GL_VERSION);
if (!version)
{
_glfwSetError(GLFW_PLATFORM_ERROR, "Failed to retrieve version string");
return;
}
if (strncmp((const char*) version, glesPrefix, strlen(glesPrefix)) == 0)
{
@ -81,6 +84,8 @@ static void parseGLVersion(int* major, int* minor, int* rev)
*major = _major;
*minor = _minor;
*rev = _rev;
return GL_TRUE;
}
@ -348,13 +353,34 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
//========================================================================
// Reads back context properties
// It blames glfwOpenWindow because that's the only caller
//========================================================================
void _glfwRefreshContextParams(void)
GLboolean _glfwRefreshContextParams(void)
{
_GLFWwindow* window = _glfwLibrary.currentWindow;
parseGLVersion(&window->glMajor, &window->glMinor, &window->glRevision);
if (!parseGLVersion(&window->glMajor,
&window->glMinor,
&window->glRevision))
{
return GL_FALSE;
}
if (window->glMajor > 2)
{
// OpenGL 3.0+ uses a different function for extension string retrieval
// We cache it here instead of in glfwExtensionSupported mostly to alert
// users as early as possible that their build may be broken
window->GetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi");
if (!window->GetStringi)
{
_glfwSetError(GLFW_PLATFORM_ERROR,
"glfwOpenWindow: Entry point retrieval is broken");
return GL_FALSE;
}
}
// Read back forward-compatibility flag
{
@ -408,16 +434,20 @@ void _glfwRefreshContextParams(void)
glGetIntegerv(GL_SAMPLES_ARB, &window->samples);
else
window->samples = 0;
return GL_TRUE;
}
//========================================================================
// Checks whether the specified context fulfils the requirements
// Checks whether the current context fulfils the specified requirements
// It blames glfwOpenWindow because that's the only caller
//========================================================================
GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
{
_GLFWwindow* window = _glfwLibrary.currentWindow;
if (window->glMajor < wndconfig->glMajor ||
(window->glMajor == wndconfig->glMajor &&
window->glMinor < wndconfig->glMinor))
@ -434,21 +464,6 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
return GL_FALSE;
}
if (window->glMajor > 2)
{
// OpenGL 3.0+ uses a different function for extension string retrieval
// We cache it here instead of in glfwExtensionSupported mostly to alert
// users as early as possible that their build may be broken
window->GetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi");
if (!window->GetStringi)
{
_glfwSetError(GLFW_PLATFORM_ERROR,
"glfwOpenWindow: Entry point retrieval is broken");
return GL_FALSE;
}
}
return GL_TRUE;
}

View File

@ -319,11 +319,17 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
}
// Cache the actual (as opposed to desired) window parameters
glfwMakeContextCurrent(window);
_glfwRefreshContextParams();
_glfwPlatformRefreshWindowParams();
if (!_glfwIsValidContext(window, &wndconfig))
glfwMakeContextCurrent(window);
if (!_glfwRefreshContextParams())
{
glfwCloseWindow(window);
return GL_FALSE;
}
if (!_glfwIsValidContext(&wndconfig))
{
glfwCloseWindow(window);
return GL_FALSE;