mirror of
https://github.com/love2d/love.git
synced 2026-08-21 13:09:56 +02:00
Use a more descriptive error message if love.graphics.newImage fails because the OpenGL texture can't be created.
This commit is contained in:
@@ -356,7 +356,7 @@ bool Image::loadVolatile()
|
|||||||
|
|
||||||
GLenum glerr = glGetError();
|
GLenum glerr = glGetError();
|
||||||
if (glerr != GL_NO_ERROR)
|
if (glerr != GL_NO_ERROR)
|
||||||
throw love::Exception("Cannot create image (error code 0x%x)", glerr);
|
throw love::Exception("Cannot create image (OpenGL error: %s)", OpenGL::errorString(glerr));
|
||||||
}
|
}
|
||||||
catch (love::Exception &)
|
catch (love::Exception &)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
// C
|
// C
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
// For SDL_GL_GetProcAddress.
|
// For SDL_GL_GetProcAddress.
|
||||||
#include <SDL_video.h>
|
#include <SDL_video.h>
|
||||||
@@ -652,6 +653,36 @@ OpenGL::Vendor OpenGL::getVendor() const
|
|||||||
return vendor;
|
return vendor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *OpenGL::errorString(GLenum errorcode)
|
||||||
|
{
|
||||||
|
switch (errorcode)
|
||||||
|
{
|
||||||
|
case GL_NO_ERROR:
|
||||||
|
return "no error";
|
||||||
|
case GL_INVALID_ENUM:
|
||||||
|
return "invalid enum";
|
||||||
|
case GL_INVALID_VALUE:
|
||||||
|
return "invalid value";
|
||||||
|
case GL_INVALID_OPERATION:
|
||||||
|
return "invalid operation";
|
||||||
|
case GL_OUT_OF_MEMORY:
|
||||||
|
return "out of memory";
|
||||||
|
case GL_INVALID_FRAMEBUFFER_OPERATION:
|
||||||
|
return "invalid framebuffer operation";
|
||||||
|
case GL_CONTEXT_LOST:
|
||||||
|
return "OpenGL context has been lost";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char text[64] = {};
|
||||||
|
|
||||||
|
memset(text, 0, sizeof(text));
|
||||||
|
sprintf(text, "0x%x", errorcode);
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
const char *OpenGL::debugSeverityString(GLenum severity)
|
const char *OpenGL::debugSeverityString(GLenum severity)
|
||||||
{
|
{
|
||||||
switch (severity)
|
switch (severity)
|
||||||
|
|||||||
@@ -339,6 +339,8 @@ public:
|
|||||||
**/
|
**/
|
||||||
Vendor getVendor() const;
|
Vendor getVendor() const;
|
||||||
|
|
||||||
|
static const char *errorString(GLenum errorcode);
|
||||||
|
|
||||||
// Get human-readable strings for debug info.
|
// Get human-readable strings for debug info.
|
||||||
static const char *debugSeverityString(GLenum severity);
|
static const char *debugSeverityString(GLenum severity);
|
||||||
static const char *debugSourceString(GLenum source);
|
static const char *debugSourceString(GLenum source);
|
||||||
|
|||||||
Reference in New Issue
Block a user