Framebuffer status handling

Remove Framebuffer::statusCode() and Framebuffer::statusMessage().
Introduce Framebuffer:getStatus() returning the value of
glCheckFramebufferStatus().

Test if creation was successful in w_newFramebuffer(L), on failure throw
useful error message.
This commit is contained in:
vrld
2010-08-25 17:28:51 +02:00
parent ce0006d04c
commit f97d087158
3 changed files with 19 additions and 38 deletions
+18 -4
View File
@@ -297,12 +297,26 @@ namespace opengl
int width, height;
width = luaL_checkint(L, 1);
height = luaL_checkint(L, 2);
Framebuffer * Framebuffer = instance->newFramebuffer(width, height);
Framebuffer * framebuffer = instance->newFramebuffer(width, height);
//and there we go with the status... still disliked
if (Framebuffer->statusCode() != GL_FRAMEBUFFER_COMPLETE_EXT)
return luaL_error(L, "Cannot create Framebuffer: %s", Framebuffer->statusMessage());
luax_newtype(L, "Framebuffer", GRAPHICS_FRAMEBUFFER_T, (void*)Framebuffer);
if (framebuffer->getStatus() != GL_FRAMEBUFFER_COMPLETE) {
switch (framebuffer->getStatus()) {
case GL_FRAMEBUFFER_UNSUPPORTED:
return luaL_error(L, "Cannot create Framebuffer: "
"Not supported by your OpenGL implementation");
// remaining error codes are highly unlikely:
// GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT,
// GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER
// GL_FRAMEBUFFER_UNDEFINED
// GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
// GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER
// GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
default:
return luaL_error(L, "Cannot create Framebuffer: Aliens did it");
}
}
luax_newtype(L, "Framebuffer", GRAPHICS_FRAMEBUFFER_T, (void*)framebuffer);
return 1;
}