love.graphics object creation functions (love.graphics.new*) now cause an error instead of hard-crashing, if called when the window has not been created yet.

This commit is contained in:
Alex Szpakowski
2016-02-11 22:34:33 -04:00
parent ab4cfb4a35
commit 7c4edf2efc
4 changed files with 41 additions and 10 deletions
+8 -5
View File
@@ -842,11 +842,14 @@ ParticleSystem *Graphics::newParticleSystem(Texture *texture, int size)
Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int msaa)
{
if (!Canvas::isSupported())
throw love::Exception("Canvases are not supported by your OpenGL drivers!");
if (!Canvas::isFormatSupported(format))
{
const char *fstr = "rgba8";
Canvas::getConstant(format, fstr);
throw love::Exception("The %s canvas format is not supported by your OpenGL implementation.", fstr);
Canvas::getConstant(Canvas::getSizedFormat(format), fstr);
throw love::Exception("The %s canvas format is not supported by your OpenGL drivers.", fstr);
}
if (width > gl.getMaxTextureSize())
@@ -870,7 +873,7 @@ Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int ms
switch (err)
{
case GL_FRAMEBUFFER_UNSUPPORTED:
error_string << "Not supported by your OpenGL implementation.";
error_string << "Not supported by your OpenGL drivers.";
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
error_string << "Texture format cannot be rendered to on this system.";
@@ -881,14 +884,14 @@ Canvas *Graphics::newCanvas(int width, int height, Canvas::Format format, int ms
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
error_string << "Error in implementation.";
error_string << "Error in graphics driver.";
break;
default:
// my intel hda card wrongly returns 0 to glCheckFramebufferStatus() but sets
// no error flag. I think it meant to return GL_FRAMEBUFFER_UNSUPPORTED, but who
// knows.
if (glGetError() == GL_NO_ERROR)
error_string << "May not be supported by your OpenGL implementation.";
error_string << "May not be supported by your OpenGL drivers.";
// the remaining error is an indication of a serious fuckup since it should
// only be returned if glCheckFramebufferStatus() was called with the wrong
// arguments.