diff --git a/src/framework/graphics/framebuffer.cpp b/src/framework/graphics/framebuffer.cpp index cd0e6ffc..21102fc5 100644 --- a/src/framework/graphics/framebuffer.cpp +++ b/src/framework/graphics/framebuffer.cpp @@ -34,6 +34,8 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC oglCheckFramebufferStatus = 0; FrameBuffer::FrameBuffer(int width, int height) { + g_graphics.disableDrawing(); + m_fbo = 0; m_width = width; m_height = height; @@ -50,7 +52,7 @@ FrameBuffer::FrameBuffer(int width, int height) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // use FBO ext only if supported - if(g_graphics.isExtensionSupported("ARB_framebuffer_object")) { + if(g_graphics.isExtensionSupported("GL_ARB_framebuffer_object")) { m_fallbackOldImp = false; if(!oglGenFramebuffers) { oglGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)Platform::getExtensionProcAddress("glGenFramebuffers"); @@ -84,6 +86,8 @@ FrameBuffer::FrameBuffer(int width, int height) FrameBuffer::~FrameBuffer() { + g_graphics.disableDrawing(); + glDeleteTextures(1, &m_fboTexture); if(m_fbo) oglDeleteFramebuffers(1, &m_fbo); @@ -91,6 +95,8 @@ FrameBuffer::~FrameBuffer() void FrameBuffer::bind() { + g_graphics.disableDrawing(); + if(!m_fallbackOldImp) { // bind framebuffer oglBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); @@ -113,6 +119,8 @@ void FrameBuffer::bind() void FrameBuffer::unbind() { + g_graphics.disableDrawing(); + if(!m_fallbackOldImp) { // bind back buffer again oglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); @@ -137,6 +145,8 @@ void FrameBuffer::unbind() void FrameBuffer::draw(int x, int y, int width, int height) { + g_graphics.disableDrawing(); + glBindTexture(GL_TEXTURE_2D, m_fboTexture); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex2i(x, y); diff --git a/src/framework/graphics/framebuffer.h b/src/framework/graphics/framebuffer.h index 3386885d..b99a9661 100644 --- a/src/framework/graphics/framebuffer.h +++ b/src/framework/graphics/framebuffer.h @@ -27,6 +27,9 @@ #include +class FrameBuffer; +typedef std::shared_ptr FrameBufferPtr; + class FrameBuffer { public: diff --git a/src/map.cpp b/src/map.cpp index 7b4fd9b7..41d665c2 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3,6 +3,11 @@ void Map::draw(int x, int y, int width, int heigth) { + if(!m_framebuffer) + m_framebuffer = FrameBufferPtr(new FrameBuffer(19*32, 15*32)); + + m_framebuffer->bind(); + Position playerPos = g_game.getPlayer()->getPosition(); for(int ix = 0; ix < 19; ++ix) { for(int iy = 0; iy < 15; ++iy) { @@ -13,6 +18,9 @@ void Map::draw(int x, int y, int width, int heigth) } } } + + m_framebuffer->unbind(); + m_framebuffer->draw(0, 0, width, heigth); } void Map::addThing(Thing *thing, const Position& pos) diff --git a/src/map.h b/src/map.h index 44c6ba6c..f828bfa4 100644 --- a/src/map.h +++ b/src/map.h @@ -3,6 +3,7 @@ #include "position.h" #include "tile.h" +#include class Map { @@ -14,6 +15,8 @@ public: private: // Visible tiles are 15x11, but we have a +3 value. We have 15 floors. Tile m_map[19][15][15]; + + FrameBufferPtr m_framebuffer; }; #endif // MAP_H