diff --git a/src/modules/graphics/opengl/Fbo.cpp b/src/modules/graphics/opengl/Framebuffer.cpp similarity index 91% rename from src/modules/graphics/opengl/Fbo.cpp rename to src/modules/graphics/opengl/Framebuffer.cpp index 4164289ad..1e5a76401 100644 --- a/src/modules/graphics/opengl/Fbo.cpp +++ b/src/modules/graphics/opengl/Framebuffer.cpp @@ -1,4 +1,4 @@ -#include "Fbo.h" +#include "Framebuffer.h" #include namespace love @@ -8,9 +8,9 @@ namespace graphics namespace opengl { - std::map Fbo::status_to_string; + std::map Framebuffer::status_to_string; - Fbo::Fbo(int width, int height) : + Framebuffer::Framebuffer(int width, int height) : width(width), height(height) { // maybe create status code messages @@ -77,19 +77,19 @@ namespace opengl glBindFramebuffer(GL_FRAMEBUFFER, 0); } - Fbo::~Fbo() + Framebuffer::~Framebuffer() { glDeleteTextures(1, &fbo); glDeleteRenderbuffers(1, &depthbuffer); glDeleteFramebuffers(1, &img); } - const char* Fbo::statusMessage() const + const char* Framebuffer::statusMessage() const { status_to_string[statusCode()]; } - void Fbo::bind() + void Framebuffer::bind() { glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindFramebuffer(GL_FRAMEBUFFER, fbo); @@ -98,13 +98,13 @@ namespace opengl glViewport(0, 0, width, height); } - void Fbo::unbind() + void Framebuffer::unbind() { glBindFramebuffer(GL_FRAMEBUFFER, 0); glPopAttrib(); } - void Fbo::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const + void Framebuffer::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const { static Matrix t; t.setTransformation(x, y, angle, sx, sy, ox, oy); diff --git a/src/modules/graphics/opengl/Fbo.h b/src/modules/graphics/opengl/Framebuffer.h similarity index 73% rename from src/modules/graphics/opengl/Fbo.h rename to src/modules/graphics/opengl/Framebuffer.h index 1f93242f5..53a9a5bc2 100644 --- a/src/modules/graphics/opengl/Fbo.h +++ b/src/modules/graphics/opengl/Framebuffer.h @@ -1,5 +1,5 @@ -#ifndef LOVE_GRAPHICS_FBO_H -#define LOVE_GRAPHICS_FBO_H +#ifndef LOVE_GRAPHICS_FRAMEBUFFER_H +#define LOVE_GRAPHICS_FRAMEBUFFER_H #include #include @@ -14,13 +14,13 @@ namespace graphics namespace opengl { - class Fbo : public Drawable // Fbo vs. FBO? + class Framebuffer : public Drawable { public: - Fbo(int width, int height); - virtual ~Fbo(); + Framebuffer(int width, int height); + virtual ~Framebuffer(); - // for internal use (w_newFbo <-> love.graphics.newFbo) only + // for internal use (w_newFramebuffer <-> love.graphics.newFramebuffer) only GLenum statusCode() const { return status_; } //SERIOUS DISLIKE HERE const char* statusMessage() const; @@ -48,4 +48,4 @@ namespace opengl } // graphics } // love -#endif // LOVE_GRAPHICS_FBO_H +#endif // LOVE_GRAPHICS_FRAMEBUFFER_H diff --git a/src/modules/graphics/opengl/wrap_Fbo.cpp b/src/modules/graphics/opengl/wrap_Fbo.cpp deleted file mode 100644 index 3af9e6be9..000000000 --- a/src/modules/graphics/opengl/wrap_Fbo.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "wrap_Fbo.h" - -namespace love -{ -namespace graphics -{ -namespace opengl -{ - Fbo * luax_checkfbo(lua_State * L, int idx) - { - return luax_checktype(L, idx, "Fbo", GRAPHICS_FBO_T); - } - - int w_Fbo_render(lua_State * L) - { - Fbo * fbo = luax_checkfbo(L, 1); - if (!lua_isfunction(L, 2)) - return luaL_error(L, "Need a function to render to fbo"); - - fbo->bind(); - - lua_settop(L, 2); // make sure the function is on top of the stack - lua_pcall(L, 0, 0, 0); - - fbo->unbind(); - - return 0; - } - - int w_Fbo_bind(lua_State * L) - { - Fbo * fbo = luax_checkfbo(L, 1); - fbo->bind(); - return 0; - } - - int w_Fbo_unbind(lua_State * L) - { - Fbo * fbo = luax_checkfbo(L, 1); - fbo->unbind(); - return 0; - } - - static const luaL_Reg functions[] = { - { "render", w_Fbo_render }, - { "bind", w_Fbo_bind }, - { "unbind", w_Fbo_unbind }, - { 0, 0 } - }; - - int luaopen_fbo(lua_State * L) - { - return luax_register_type(L, "Fbo", functions); - } - -} // opengl -} // graphics -} // love diff --git a/src/modules/graphics/opengl/wrap_Fbo.h b/src/modules/graphics/opengl/wrap_Fbo.h deleted file mode 100644 index 03454a74e..000000000 --- a/src/modules/graphics/opengl/wrap_Fbo.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LOVE_GRAPHICS_OPENGL_WRAP_FBO_H -#define LOVE_GRAPHICS_OPENGL_WRAP_FBO_H - -// LOVE -#include -#include "Fbo.h" - -namespace love -{ -namespace graphics -{ -namespace opengl -{ - //see Fbo.h - Fbo * luax_checkfbo(lua_State * L, int idx); - int w_Fbo_render(lua_State * L); - int w_Fbo_bind(lua_State * L); - int w_Fbo_unbind(lua_State * L); - int luaopen_fbo(lua_State * L); - -} // opengl -} // graphics -} // love - -#endif // LOVE_GRAPHICS_OPENGL_WRAP_FBO_H diff --git a/src/modules/graphics/opengl/wrap_Framebuffer.cpp b/src/modules/graphics/opengl/wrap_Framebuffer.cpp new file mode 100644 index 000000000..d8c44a384 --- /dev/null +++ b/src/modules/graphics/opengl/wrap_Framebuffer.cpp @@ -0,0 +1,58 @@ +#include "wrap_Framebuffer.h" + +namespace love +{ +namespace graphics +{ +namespace opengl +{ + Framebuffer * luax_checkfbo(lua_State * L, int idx) + { + return luax_checktype(L, idx, "Framebuffer", GRAPHICS_FRAMEBUFFER_T); + } + + int w_Framebuffer_render(lua_State * L) + { + Framebuffer * fbo = luax_checkfbo(L, 1); + if (!lua_isfunction(L, 2)) + return luaL_error(L, "Need a function to render to fbo"); + + fbo->bind(); + + lua_settop(L, 2); // make sure the function is on top of the stack + lua_pcall(L, 0, 0, 0); + + fbo->unbind(); + + return 0; + } + + int w_Framebuffer_bind(lua_State * L) + { + Framebuffer * fbo = luax_checkfbo(L, 1); + fbo->bind(); + return 0; + } + + int w_Framebuffer_unbind(lua_State * L) + { + Framebuffer * fbo = luax_checkfbo(L, 1); + fbo->unbind(); + return 0; + } + + static const luaL_Reg functions[] = { + { "render", w_Framebuffer_render }, + { "bind", w_Framebuffer_bind }, + { "unbind", w_Framebuffer_unbind }, + { 0, 0 } + }; + + int luaopen_framebuffer(lua_State * L) + { + return luax_register_type(L, "Framebuffer", functions); + } + +} // opengl +} // graphics +} // love diff --git a/src/modules/graphics/opengl/wrap_Framebuffer.h b/src/modules/graphics/opengl/wrap_Framebuffer.h new file mode 100644 index 000000000..0bdf9964f --- /dev/null +++ b/src/modules/graphics/opengl/wrap_Framebuffer.h @@ -0,0 +1,25 @@ +#ifndef LOVE_GRAPHICS_OPENGL_WRAP_FBO_H +#define LOVE_GRAPHICS_OPENGL_WRAP_FBO_H + +// LOVE +#include +#include "Framebuffer.h" + +namespace love +{ +namespace graphics +{ +namespace opengl +{ + //see Framebuffer.h + Framebuffer * luax_checkfbo(lua_State * L, int idx); + int w_Framebuffer_render(lua_State * L); + int w_Framebuffer_bind(lua_State * L); + int w_Framebuffer_unbind(lua_State * L); + int luaopen_framebuffer(lua_State * L); + +} // opengl +} // graphics +} // love + +#endif // LOVE_GRAPHICS_OPENGL_WRAP_FBO_H