diff --git a/src/context.c b/src/context.c index a105aaad..739a14bc 100644 --- a/src/context.c +++ b/src/context.c @@ -34,56 +34,6 @@ #include -// Parses the client API version string and extracts the version number -// -static GLFWbool parseVersionString(int* api, int* major, int* minor, int* rev) -{ - int i; - _GLFWwindow* window; - const char* version; - const char* prefixes[] = - { - "OpenGL ES-CM ", - "OpenGL ES-CL ", - "OpenGL ES ", - NULL - }; - - *api = GLFW_OPENGL_API; - - window = _glfwPlatformGetCurrentContext(); - - version = (const char*) window->context.GetString(GL_VERSION); - if (!version) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Client API version string retrieval is broken"); - return GLFW_FALSE; - } - - for (i = 0; prefixes[i]; i++) - { - const size_t length = strlen(prefixes[i]); - - if (strncmp(version, prefixes[i], length) == 0) - { - version += length; - *api = GLFW_OPENGL_ES_API; - break; - } - } - - if (!sscanf(version, "%d.%d.%d", major, minor, rev)) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "No version found in client API version string"); - return GLFW_FALSE; - } - - return GLFW_TRUE; -} - - ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// @@ -369,7 +319,21 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig) { - _GLFWwindow* window = _glfwPlatformGetCurrentContext(); + int i; + _GLFWwindow* window; + const char* version; + const char* prefixes[] = + { + "OpenGL ES-CM ", + "OpenGL ES-CL ", + "OpenGL ES ", + NULL + }; + + window = _glfwPlatformGetCurrentContext(); + + window->context.source = ctxconfig->source; + window->context.client = GLFW_OPENGL_API; window->context.GetIntegerv = (PFNGLGETINTEGERVPROC) window->context.getProcAddress("glGetIntegerv"); @@ -381,15 +345,35 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig) return GLFW_FALSE; } - if (!parseVersionString(&window->context.client, - &window->context.major, - &window->context.minor, - &window->context.revision)) + version = (const char*) window->context.GetString(GL_VERSION); + if (!version) { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Client API version string retrieval is broken"); return GLFW_FALSE; } - window->context.source = ctxconfig->source; + for (i = 0; prefixes[i]; i++) + { + const size_t length = strlen(prefixes[i]); + + if (strncmp(version, prefixes[i], length) == 0) + { + version += length; + window->context.client = GLFW_OPENGL_ES_API; + break; + } + } + + if (!sscanf(version, "%d.%d.%d", + &window->context.major, + &window->context.minor, + &window->context.revision)) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "No version found in client API version string"); + return GLFW_FALSE; + } if (window->context.major < ctxconfig->major || (window->context.major == ctxconfig->major &&