mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Fixed OpenGL context version checking when OpenGL ES is used.
--HG-- branch : minor
This commit is contained in:
@@ -306,7 +306,7 @@ void Window::setGLContextAttributes(const ContextAttribs &attribs)
|
||||
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 int GLenum;
|
||||
@@ -328,10 +328,15 @@ bool Window::checkGLVersion(int versionmajor, int versionminor)
|
||||
|
||||
// glGetString(GL_VERSION) returns a string with the format "major.minor",
|
||||
// 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;
|
||||
|
||||
if (glmajor < versionmajor || (glmajor == versionmajor && glminor < versionminor))
|
||||
if (glmajor < attribs.versionMajor
|
||||
|| (glmajor == attribs.versionMajor && glminor < attribs.versionMinor))
|
||||
return false;
|
||||
|
||||
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.
|
||||
if (context && !checkGLVersion(attribs.versionMajor, attribs.versionMinor))
|
||||
if (context && !checkGLVersion(attribs))
|
||||
{
|
||||
SDL_GL_DeleteContext(context);
|
||||
context = nullptr;
|
||||
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
|
||||
void setGLFramebufferAttributes(int msaa, bool sRGB);
|
||||
void setGLContextAttributes(const ContextAttribs &attribs);
|
||||
bool checkGLVersion(int versionmajor, int versionminor);
|
||||
bool checkGLVersion(const ContextAttribs &attribs);
|
||||
bool setContext(int msaa, bool vsync, bool sRGB);
|
||||
|
||||
// Update the saved window settings based on the window's actual state.
|
||||
|
||||
Reference in New Issue
Block a user