summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-04-18 15:53:56 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-04-18 15:53:56 +0000
commit708384a6b1fca22c6352deb79e52422266dc307e (patch)
tree99fc89b50c1cae19d053e8bd30723ba964792820 /src/graphics.cpp
parent1f03c67e2c81c75d83053dbabb1afca646a35ad6 (diff)
downloadmana-client-708384a6b1fca22c6352deb79e52422266dc307e.tar.gz
mana-client-708384a6b1fca22c6352deb79e52422266dc307e.tar.bz2
mana-client-708384a6b1fca22c6352deb79e52422266dc307e.tar.xz
mana-client-708384a6b1fca22c6352deb79e52422266dc307e.zip
Ok, of course the biggest problem to solve with OpenGL integration is loading
and rendering of images.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp27
1 files changed, 19 insertions, 8 deletions
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);
+ }
}