Fixed OpenGL context version checking when OpenGL ES is used.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2015-01-30 04:48:09 -04:00
parent 6c11443a04
commit 84a6dd3b1c
2 changed files with 10 additions and 5 deletions
+9 -4
View File
@@ -306,7 +306,7 @@ void Window::setGLContextAttributes(const ContextAttribs &attribs)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, contextflags); SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, contextflags);
} }
bool Window::checkGLVersion(int versionmajor, int versionminor) bool Window::checkGLVersion(const ContextAttribs &attribs)
{ {
typedef unsigned char GLubyte; typedef unsigned char GLubyte;
typedef unsigned int GLenum; typedef unsigned int GLenum;
@@ -328,10 +328,15 @@ bool Window::checkGLVersion(int versionmajor, int versionminor)
// glGetString(GL_VERSION) returns a string with the format "major.minor", // glGetString(GL_VERSION) returns a string with the format "major.minor",
// or "OpenGL ES major.minor" in GLES contexts. // or "OpenGL ES major.minor" in GLES contexts.
if (sscanf(glversion, "%d.%d", &glmajor, &glminor) != 2) const char *format = "%d.%d";
if (attribs.gles)
format = "OpenGL ES %d.%d";
if (sscanf(glversion, format, &glmajor, &glminor) != 2)
return false; return false;
if (glmajor < versionmajor || (glmajor == versionmajor && glminor < versionminor)) if (glmajor < attribs.versionMajor
|| (glmajor == attribs.versionMajor && glminor < attribs.versionMinor))
return false; return false;
return true; return true;
@@ -424,7 +429,7 @@ bool Window::setContext(int msaa, bool vsync, bool sRGB)
} }
// Make sure the context's version is at least what we requested. // Make sure the context's version is at least what we requested.
if (context && !checkGLVersion(attribs.versionMajor, attribs.versionMinor)) if (context && !checkGLVersion(attribs))
{ {
SDL_GL_DeleteContext(context); SDL_GL_DeleteContext(context);
context = nullptr; context = nullptr;
+1 -1
View File
@@ -113,7 +113,7 @@ private:
void setGLFramebufferAttributes(int msaa, bool sRGB); void setGLFramebufferAttributes(int msaa, bool sRGB);
void setGLContextAttributes(const ContextAttribs &attribs); void setGLContextAttributes(const ContextAttribs &attribs);
bool checkGLVersion(int versionmajor, int versionminor); bool checkGLVersion(const ContextAttribs &attribs);
bool setContext(int msaa, bool vsync, bool sRGB); bool setContext(int msaa, bool vsync, bool sRGB);
// Update the saved window settings based on the window's actual state. // Update the saved window settings based on the window's actual state.