mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
File moves
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "Fbo.h"
|
||||
#include "Framebuffer.h"
|
||||
#include <common/Matrix.h>
|
||||
|
||||
namespace love
|
||||
@@ -8,9 +8,9 @@ namespace graphics
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
std::map<GLenum, const char*> Fbo::status_to_string;
|
||||
std::map<GLenum, const char*> 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);
|
||||
@@ -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 <graphics/Drawable.h>
|
||||
#include <graphics/Volatile.h>
|
||||
@@ -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
|
||||
@@ -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<Fbo>(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
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_FBO_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_FBO_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#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
|
||||
@@ -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<Framebuffer>(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
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_FBO_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_FBO_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#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
|
||||
Reference in New Issue
Block a user