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
+2 -2
View File
@@ -89,7 +89,7 @@ namespace opengl
status_to_string[statusCode()];
}
void Framebuffer::bind()
void Framebuffer::grab()
{
glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -98,7 +98,7 @@ namespace opengl
glViewport(0, 0, width, height);
}
void Framebuffer::unbind()
void Framebuffer::stop()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glPopAttrib();
+2 -4
View File
@@ -24,10 +24,8 @@ namespace opengl
GLenum statusCode() const { return status_; } //SERIOUS DISLIKE HERE
const char* statusMessage() const;
void bind(); //DOUBTFUL ABOUT NAME
void unbind(); //Maybe start/stop?
//And what about clearing, clear() isn't entirely what I want either
//maybe make bind/start autoclear?
void grab();
void stop();
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))
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_pcall(L, 0, 0, 0);
fbo->unbind();
fbo->stop();
return 0;
}
int w_Framebuffer_bind(lua_State * L)
int w_Framebuffer_grab(lua_State * L)
{
Framebuffer * fbo = luax_checkfbo(L, 1);
fbo->bind();
fbo->grab();
return 0;
}
int w_Framebuffer_unbind(lua_State * L)
int w_Framebuffer_stop(lua_State * L)
{
Framebuffer * fbo = luax_checkfbo(L, 1);
fbo->unbind();
fbo->stop();
return 0;
}
static const luaL_Reg functions[] = {
{ "render", w_Framebuffer_render },
{ "bind", w_Framebuffer_bind },
{ "unbind", w_Framebuffer_unbind },
{ "grab", w_Framebuffer_grab },
{ "stop", w_Framebuffer_stop },
{ 0, 0 }
};