From 34279cbb4ea6506c3d64a62e20cd97643999ce61 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 23 Jun 2014 23:18:36 +0300 Subject: Add manual OpenGL context creation. For SDL2 set attributes for context version. For SDL1.2 in X11 create own context. For SDL1.2 and other platforms not implimented for now. Also try fallback if need to older context versions. --- src/render/graphics.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/render/graphics.cpp') diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 5bb90e753..5cb45e8ca 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -71,6 +71,8 @@ #include "graphicsmanager.h" #include "logger.h" +#include "render/mglxinit.h" + #include "resources/imagehelper.h" #include "resources/openglimagehelper.h" @@ -99,9 +101,9 @@ Graphics::Graphics() : mWindow(nullptr), #ifdef USE_SDL2 mRenderer(nullptr), +#endif #ifdef USE_OPENGL mGLContext(nullptr), -#endif #endif mBpp(0), mAlpha(false), @@ -252,11 +254,15 @@ bool Graphics::setOpenGLMode() mActualWidth, mActualHeight, mBpp, getOpenGLFlags()))) { + logger->log("Window/context creation failed"); mRect.w = 0; mRect.h = 0; return false; } +#if defined(USE_OPENGL) && defined(USE_X11) + Glx::initFunctions(); +#endif #ifdef USE_SDL2 int w1 = 0; int h1 = 0; @@ -264,10 +270,10 @@ bool Graphics::setOpenGLMode() mRect.w = static_cast(w1 / mScale); mRect.h = static_cast(h1 / mScale); - mGLContext = SDL_GL_CreateContext(mWindow); - + createGLContext(); #else // USE_SDL2 + createGLContext(); mRect.w = static_cast(mWindow->w / mScale); mRect.h = static_cast(mWindow->h / mScale); @@ -353,6 +359,14 @@ int Graphics::getSoftwareFlags() const return displayFlags; } +#ifdef USE_OPENGL +void Graphics::createGLContext() +{ +#ifdef USE_SDL2 + mGLContext = SDL_GL_CreateContext(mWindow); +#endif +} +#endif void Graphics::updateMemoryInfo() { -- cgit v1.2.3-70-g09d2