render fix

This commit is contained in:
Eduardo Bart 2011-04-17 17:39:03 -03:00
parent 44a7f6ab90
commit 8ef534e7b7
3 changed files with 9 additions and 14 deletions

View File

@ -90,12 +90,19 @@ void Engine::run()
} }
} }
render(); // render
g_graphics.beginRender();
if(m_currentState)
m_currentState->render();
UIContainer::getRootContainer()->render();
// render fps // render fps
if(m_calculateFps) if(m_calculateFps)
defaultFont->renderText(fpsText, Point(g_graphics.getScreenSize().width() - fpsTextSize.width() - 10, 10)); defaultFont->renderText(fpsText, Point(g_graphics.getScreenSize().width() - fpsTextSize.width() - 10, 10));
g_graphics.endRender();
// swap buffers // swap buffers
Platform::swapBuffers(); Platform::swapBuffers();
} }
@ -119,15 +126,6 @@ void Engine::changeState(GameState* newState)
m_currentState->onEnter(); m_currentState->onEnter();
} }
void Engine::render()
{
g_graphics.beginRender();
if(m_currentState)
m_currentState->render();
UIContainer::getRootContainer()->render();
g_graphics.endRender();
}
void Engine::onClose() void Engine::onClose()
{ {
if(m_currentState) if(m_currentState)

View File

@ -65,9 +65,6 @@ public:
int getCurrentFrameTicks() const { return m_lastFrameTicks; } int getCurrentFrameTicks() const { return m_lastFrameTicks; }
private: private:
/// Called to render every frame
void render();
bool m_stopping; bool m_stopping;
bool m_running; bool m_running;
bool m_calculateFps; bool m_calculateFps;

View File

@ -41,6 +41,7 @@ void Graphics::init()
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
logInfo("GPU %s", (const char*)glGetString(GL_RENDERER)); logInfo("GPU %s", (const char*)glGetString(GL_RENDERER));
logInfo("OpenGL %s", (const char*)glGetString(GL_VERSION)); logInfo("OpenGL %s", (const char*)glGetString(GL_VERSION));
@ -115,7 +116,6 @@ void Graphics::restoreViewport()
void Graphics::beginRender() void Graphics::beginRender()
{ {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity(); glLoadIdentity();