From 708384a6b1fca22c6352deb79e52422266dc307e Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Mon, 18 Apr 2005 15:53:56 +0000 Subject: Ok, of course the biggest problem to solve with OpenGL integration is loading and rendering of images. --- src/graphics.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/graphics.cpp') diff --git a/src/graphics.cpp b/src/graphics.cpp index 88ba744a..e0763c29 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -32,6 +32,16 @@ SDL_Surface *screen; Graphics::Graphics(): mouseCursor(NULL) { + if (useOpenGL) { + // Setup OpenGL + glViewport(0, 0, 800, 600); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + int gotDoubleBuffer; + SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer); + logger.log("Using OpenGL %s double buffering.", + (gotDoubleBuffer ? "with" : "without")); + } + #ifdef USE_OPENGL setTargetPlane(800, 600); #else @@ -125,12 +135,13 @@ void Graphics::updateScreen() SDL_GetMouseState(&mouseX, &mouseY); mouseCursor->draw(screen, mouseX - 5, mouseY - 2); -#ifdef USE_OPENGL - glFlush(); - glFinish(); - SDL_GL_SwapBuffers(); - glClear(GL_COLOR_BUFFER_BIT); -#else - SDL_Flip(screen); -#endif + if (useOpenGL) { + glFlush(); + glFinish(); + SDL_GL_SwapBuffers(); + glClear(GL_COLOR_BUFFER_BIT); + } + else { + SDL_Flip(screen); + } } -- cgit v1.2.3-60-g2f50