From: Ingo Ruhnke Date: Wed, 30 Jul 2014 16:57:03 +0000 (+0200) Subject: Fixed OpenGL renderer, starts now up and game seems playable X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bd6237d3bf7a8146f91547e71097d23013aad071;p=supertux.git Fixed OpenGL renderer, starts now up and game seems playable --- diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp index 41575c05e..9d2010850 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -69,12 +69,12 @@ GLRenderer::GLRenderer() : #endif #ifdef OLD_SDL1 - SDL_GL_SetSwapInterval(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - // FIXME: Hu? 16bit rendering? - SDL_GL_SetSwapInterval(5); - SDL_GL_SetSwapInterval(5); - SDL_GL_SetSwapInterval(5); + // FIXME: Hu? 16bit rendering? + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); #endif if(g_config->use_fullscreen) @@ -118,6 +118,8 @@ GLRenderer::GLRenderer() : GLRenderer::~GLRenderer() { + SDL_GL_DeleteContext(glcontext); + SDL_DestroyWindow(window); } void @@ -464,9 +466,7 @@ void GLRenderer::flip() { assert_gl("drawing"); -#ifdef OLD_SDL1 - SDL_GL_SwapWindow(screen)(); -#endif + SDL_GL_SwapWindow(window); } void @@ -623,20 +623,22 @@ GLRenderer::apply_video_mode(const Size& size, bool fullscreen) flags |= SDL_WINDOW_RESIZABLE; } -#ifdef OLD_SDL1 - if (SDL_Surface *screen = SDL_CreateWindow(size.width, size.height, 0, flags)) - { - SDL_GL_CreateContext(screen); - screen_size = Size(screen->w, screen->h); - fullscreen_active = fullscreen; - } - else + window = SDL_CreateWindow("SuperTux", + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + size.width, size.height, + flags); + if (!window) { std::ostringstream msg; msg << "Couldn't set video mode " << size.width << "x" << size.height << ": " << SDL_GetError(); throw std::runtime_error(msg.str()); } -#endif + else + { + glcontext = SDL_GL_CreateContext(window); + screen_size = size; + fullscreen_active = fullscreen; + } } } diff --git a/src/video/gl/gl_renderer.hpp b/src/video/gl/gl_renderer.hpp index e164696e3..028222504 100644 --- a/src/video/gl/gl_renderer.hpp +++ b/src/video/gl/gl_renderer.hpp @@ -21,6 +21,7 @@ #include "video/drawing_request.hpp" #include "video/renderer.hpp" +#include "SDL.h" #include namespace { @@ -106,6 +107,8 @@ inline void intern_draw(float left, float top, float right, float bottom, class GLRenderer : public Renderer { private: + SDL_Window* window; + SDL_GLContext glcontext; Size desktop_size; Size screen_size; bool fullscreen_active;