Change bind/unbind to grab/stop

This commit is contained in:
vrld
2010-08-13 18:50:00 +02:00
parent 6400273a73
commit 35093a5c45
4 changed files with 16 additions and 14 deletions
+4
View File
@@ -7,6 +7,10 @@ glob:extra/reshax/Debug/
glob:extra/reshax/resources.h glob:extra/reshax/resources.h
glob:extra/reshax/resources.cpp glob:extra/reshax/resources.cpp
glob:*.obj glob:*.obj
glob:*.o
glob:*.dirstamp
glob:*.m4
glob:*.Po
glob:*.dll glob:*.dll
glob:*.user glob:*.user
glob:*.suo glob:*.suo
+2 -2
View File
@@ -89,7 +89,7 @@ namespace opengl
status_to_string[statusCode()]; status_to_string[statusCode()];
} }
void Framebuffer::bind() void Framebuffer::grab()
{ {
glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindFramebuffer(GL_FRAMEBUFFER, fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -98,7 +98,7 @@ namespace opengl
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
} }
void Framebuffer::unbind() void Framebuffer::stop()
{ {
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glPopAttrib(); glPopAttrib();
+2 -4
View File
@@ -24,10 +24,8 @@ namespace opengl
GLenum statusCode() const { return status_; } //SERIOUS DISLIKE HERE GLenum statusCode() const { return status_; } //SERIOUS DISLIKE HERE
const char* statusMessage() const; const char* statusMessage() const;
void bind(); //DOUBTFUL ABOUT NAME void grab();
void unbind(); //Maybe start/stop? void stop();
//And what about clearing, clear() isn't entirely what I want either
//maybe make bind/start autoclear?
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const; virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
@@ -17,34 +17,34 @@ namespace opengl
if (!lua_isfunction(L, 2)) if (!lua_isfunction(L, 2))
return luaL_error(L, "Need a function to render to fbo"); return luaL_error(L, "Need a function to render to fbo");
fbo->bind(); fbo->grab();
lua_settop(L, 2); // make sure the function is on top of the stack lua_settop(L, 2); // make sure the function is on top of the stack
lua_pcall(L, 0, 0, 0); lua_pcall(L, 0, 0, 0);
fbo->unbind(); fbo->stop();
return 0; return 0;
} }
int w_Framebuffer_bind(lua_State * L) int w_Framebuffer_grab(lua_State * L)
{ {
Framebuffer * fbo = luax_checkfbo(L, 1); Framebuffer * fbo = luax_checkfbo(L, 1);
fbo->bind(); fbo->grab();
return 0; return 0;
} }
int w_Framebuffer_unbind(lua_State * L) int w_Framebuffer_stop(lua_State * L)
{ {
Framebuffer * fbo = luax_checkfbo(L, 1); Framebuffer * fbo = luax_checkfbo(L, 1);
fbo->unbind(); fbo->stop();
return 0; return 0;
} }
static const luaL_Reg functions[] = { static const luaL_Reg functions[] = {
{ "render", w_Framebuffer_render }, { "render", w_Framebuffer_render },
{ "bind", w_Framebuffer_bind }, { "grab", w_Framebuffer_grab },
{ "unbind", w_Framebuffer_unbind }, { "stop", w_Framebuffer_stop },
{ 0, 0 } { 0, 0 }
}; };