mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Show the detected OpenGL version in the popup dialog when GL2.1 or GLES2 isn't available when the window is created.
This commit is contained in:
@@ -132,7 +132,7 @@ void Window::setGLContextAttributes(const ContextAttribs &attribs)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, contextflags);
|
||||
}
|
||||
|
||||
bool Window::checkGLVersion(const ContextAttribs &attribs)
|
||||
bool Window::checkGLVersion(const ContextAttribs &attribs, std::string &outversion)
|
||||
{
|
||||
typedef unsigned char GLubyte;
|
||||
typedef unsigned int GLenum;
|
||||
@@ -149,6 +149,8 @@ bool Window::checkGLVersion(const ContextAttribs &attribs)
|
||||
if (!glversion)
|
||||
return false;
|
||||
|
||||
outversion = glversion;
|
||||
|
||||
int glmajor = 0;
|
||||
int glminor = 0;
|
||||
|
||||
@@ -229,6 +231,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
||||
}
|
||||
|
||||
std::string windowerror;
|
||||
std::string glversion;
|
||||
|
||||
// Try each context profile in order.
|
||||
for (ContextAttribs attribs : attribslist)
|
||||
@@ -320,7 +323,7 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
||||
}
|
||||
|
||||
// Make sure the context's version is at least what we requested.
|
||||
if (context && !checkGLVersion(attribs))
|
||||
if (context && !checkGLVersion(attribs, glversion))
|
||||
{
|
||||
SDL_GL_DeleteContext(context);
|
||||
context = nullptr;
|
||||
@@ -354,6 +357,9 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
||||
std::string title = "Unable to initialize OpenGL";
|
||||
std::string message = "This program requires a graphics card and video drivers which support OpenGL 2.1 or OpenGL ES 2.";
|
||||
|
||||
if (!glversion.empty())
|
||||
message += " \n(Detected OpenGL version: " + glversion + ")";
|
||||
|
||||
std::cerr << title << std::endl << message << std::endl;
|
||||
|
||||
// Display a message box with the error, but only once.
|
||||
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
|
||||
void setGLFramebufferAttributes(int msaa, bool sRGB);
|
||||
void setGLContextAttributes(const ContextAttribs &attribs);
|
||||
bool checkGLVersion(const ContextAttribs &attribs);
|
||||
bool checkGLVersion(const ContextAttribs &attribs, std::string &outversion);
|
||||
bool createWindowAndContext(int x, int y, int w, int h, Uint32 windowflags, int msaa);
|
||||
|
||||
// Update the saved window settings based on the window's actual state.
|
||||
|
||||
Reference in New Issue
Block a user