From 057a37df3e574aafd9440661d1c9d2b4d19de46c Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 16 Mar 2015 11:48:00 +0300 Subject: [PATCH] Try creating OpenGL 2.1, 2.0 context if v3.2 context creation is failed --- src/dlangui/platforms/sdl/sdlapp.d | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index d9016227..3ec78bed 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -144,11 +144,28 @@ class SDLWindow : Window { } version(USE_OPENGL) { if (_enableOpengl) { + Log.i("Trying to create OpenGL 3.2 context"); _context = SDL_GL_CreateContext(_win); // Create the actual context and make it current if (!_context) { - Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError())); - _enableOpengl = false; - } else if (!_gl3Reloaded) { + Log.e("SDL_GL_CreateContext failed for version 3.2: ", fromStringz(SDL_GetError())); + Log.w("Trying to create OpenGL 2.1 context"); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,1); + _context = SDL_GL_CreateContext(_win); // Create the actual context and make it current + if (!_context) { + Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError())); + Log.w("Trying to create OpenGL 2.0 context"); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,0); + _context = SDL_GL_CreateContext(_win); // Create the actual context and make it current + if (!_context) { + Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError())); + _enableOpengl = false; + Log.w("OpenGL support is disabled"); + } + } + } + if (_context && !_gl3Reloaded) { DerelictGL3.reload(); _gl3Reloaded = true; if (!glSupport.valid && !glSupport.initShaders()) @@ -1387,7 +1404,7 @@ int sdlmain(string[] args) { int request = SDL_GetDesktopDisplayMode(0,&displayMode); version(USE_OPENGL) { - // we want OpenGL 3.3 + // we want OpenGL 3.2 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);