just fixes

* fix battle rendering
* fix rendering glitch when following creatures
* properly throw exceptions from C++ to lua and avoid exception crashs
* fixes rendering states in framebuffer
This commit is contained in:
Eduardo Bart
2012-06-06 11:10:35 -03:00
parent 7a529d23be
commit bb1fb939c4
17 changed files with 70 additions and 90 deletions

View File

@@ -81,27 +81,15 @@ void FrameBuffer::resize(const Size& size)
}
}
void FrameBuffer::clear(const Color& color, const Rect& rect)
{
bool clip = rect.isValid();
if(clip)
g_painter->setClipRect(Rect(0, 0, m_texture->getSize()));
glClearColor(color.rF(), color.gF(), color.bF(), color.aF());
glClear(GL_COLOR_BUFFER_BIT);
if(clip)
g_painter->resetClipRect();
}
void FrameBuffer::bind()
{
g_painter->saveAndResetState();
internalBind();
Matrix3 projectionMatrix = { 2.0f/m_texture->getWidth(), 0.0f, 0.0f,
0.0f, -2.0f/m_texture->getHeight(), 0.0f,
-1.0f, 1.0f, 1.0f };
g_painter->saveAndResetState();
g_painter->setProjectionMatrix(projectionMatrix);
m_oldViewportSize = g_graphics.getViewportSize();
@@ -111,8 +99,8 @@ void FrameBuffer::bind()
void FrameBuffer::release()
{
internalRelease();
g_painter->restoreSavedState();
g_graphics.setViewportSize(m_oldViewportSize);
g_painter->restoreSavedState();
}
void FrameBuffer::draw()
@@ -157,9 +145,10 @@ void FrameBuffer::internalRelease()
m_texture->copyFromScreen(screenRect);
// restore screen original content
Painter::CompositionMode oldComposition = g_painter->getCompositionMode();
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
g_painter->drawTexturedRect(screenRect, m_screenBackup, screenRect);
g_painter->resetCompositionMode();
g_painter->setCompositionMode(oldComposition);
}
}

View File

@@ -35,7 +35,6 @@ public:
void resize(const Size& size);
void bind();
void clear(const Color& color = Color::black, const Rect& rect = Rect());
void release();
void draw();
void draw(const Rect& dest);

View File

@@ -235,8 +235,7 @@ void Graphics::resize(const Size& size)
void Graphics::beginRender()
{
//glClearColor(0, 0, 0, 1);
//glClear(GL_COLOR_BUFFER_BIT);
//g_painter->clear(Color::black);
}
void Graphics::endRender()

View File

@@ -86,12 +86,21 @@ void Painter::restoreSavedState()
setTexture(m_olderStates[m_oldStateIndex].texture);
}
void Painter::clearScreen()
void Painter::clear(const Color& color)
{
glClearColor(0,0,0,1);
glClearColor(color.rF(), color.gF(), color.bF(), color.aF());
glClear(GL_COLOR_BUFFER_BIT);
}
void Painter::clearRect(const Color& color, const Rect& rect)
{
Rect oldClipRect = m_clipRect;
setClipRect(rect);
glClearColor(color.rF(), color.gF(), color.bF(), color.aF());
glClear(GL_COLOR_BUFFER_BIT);
setClipRect(oldClipRect);
}
void Painter::setCompositionMode(Painter::CompositionMode compositionMode)
{
if(m_compositionMode == compositionMode)

View File

@@ -65,7 +65,9 @@ public:
void saveState();
void saveAndResetState();
void restoreSavedState();
void clearScreen();
void clear(const Color& color);
void clearRect(const Color& color, const Rect& rect);
virtual void drawCoords(CoordsBuffer& coordsBuffer, DrawMode drawMode = Triangles) = 0;
virtual void drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture) = 0;