diff --git a/lib/irrlicht/include/SIrrCreationParameters.h b/lib/irrlicht/include/SIrrCreationParameters.h index a0bc65277..ec36a5ad4 100644 --- a/lib/irrlicht/include/SIrrCreationParameters.h +++ b/lib/irrlicht/include/SIrrCreationParameters.h @@ -47,6 +47,7 @@ namespace irr DisplayAdapter(0), DriverMultithreaded(false), UsePerformanceTimer(true), + ForceLegacyDevice(false), SDK_version_do_not_use(IRRLICHT_SDK_VERSION) { } @@ -79,6 +80,7 @@ namespace irr DriverMultithreaded = other.DriverMultithreaded; DisplayAdapter = other.DisplayAdapter; UsePerformanceTimer = other.UsePerformanceTimer; + ForceLegacyDevice = other.ForceLegacyDevice; return *this; } @@ -289,6 +291,11 @@ namespace irr */ bool UsePerformanceTimer; + //! For opengl: forces a opengl 2.1 context, even if an + /** opengl 3 context is available. + */ + bool ForceLegacyDevice; + //! Don't use or change this parameter. /** Always set it to IRRLICHT_SDK_VERSION, which is done by default. This is needed for sdk version checks. */ diff --git a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp index 79dd45682..f2f527ec1 100644 --- a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp +++ b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp @@ -83,93 +83,96 @@ bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrr static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB; -static HGLRC getMeAGLContext(HDC HDc) +static HGLRC getMeAGLContext(HDC HDc, bool force_legacy_context) { - useCoreContext = true; - HGLRC hrc = 0; - int ctx44debug[] = + if (!force_legacy_context) { - WGL_CONTEXT_MAJOR_VERSION_ARB, 4, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + useCoreContext = true; + HGLRC hrc = 0; + int ctx44debug[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - int ctx44[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 4, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + int ctx44[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx44debug : ctx44); - if (hrc) - return hrc; + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx44debug : ctx44); + if (hrc) + return hrc; - int ctx40debug[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 4, - WGL_CONTEXT_MINOR_VERSION_ARB, 0, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + int ctx40debug[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, 0, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - int ctx40[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 4, - WGL_CONTEXT_MINOR_VERSION_ARB, 0, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + int ctx40[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, 0, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx40debug : ctx40); - if (hrc) - return hrc; + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx40debug : ctx40); + if (hrc) + return hrc; - int ctx33debug[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + int ctx33debug[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - int ctx33[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + int ctx33[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx33debug : ctx33); - if (hrc) - return hrc; + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx33debug : ctx33); + if (hrc) + return hrc; - int ctx31debug[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 1, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + int ctx31debug[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 1, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - int ctx31[] = - { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3, - WGL_CONTEXT_MINOR_VERSION_ARB, 1, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - 0 - }; + int ctx31[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 1, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 + }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx31debug : ctx31); - if (hrc) - return hrc; + hrc = wglCreateContextAttribs_ARB(HDc, 0, GLContextDebugBit ? ctx31debug : ctx31); + if (hrc) + return hrc; + } // if (!force_legacy_context) useCoreContext = false; int legacyctx[] = @@ -178,7 +181,7 @@ static HGLRC getMeAGLContext(HDC HDc) WGL_CONTEXT_MINOR_VERSION_ARB, 1, 0 }; - hrc = wglCreateContextAttribs_ARB(HDc, 0, legacyctx); + HGLRC hrc = wglCreateContextAttribs_ARB(HDc, 0, legacyctx); if (hrc) return hrc; @@ -510,7 +513,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device) #ifdef WGL_ARB_create_context if (wglCreateContextAttribs_ARB) { - hrc = getMeAGLContext(HDc); + hrc = getMeAGLContext(HDc, Params.ForceLegacyDevice); } else #endif diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 9ef1df30f..4b75e1e23 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -440,6 +440,10 @@ namespace UserConfigParams PARAM_PREFIX IntUserConfigParam m_max_fps PARAM_DEFAULT( IntUserConfigParam(120, "max_fps", &m_video_group, "Maximum fps, should be at least 60") ); + PARAM_PREFIX BoolUserConfigParam m_force_legacy_device + PARAM_DEFAULT(BoolUserConfigParam(false, "force_legacy_device", + &m_video_group, "Force OpenGL 2 context, even if OpenGL 3 is available.")); + PARAM_PREFIX BoolUserConfigParam m_texture_compression PARAM_DEFAULT(BoolUserConfigParam(true, "enable_texture_compression", &m_video_group, "Enable Texture Compression")); diff --git a/src/graphics/central_settings.cpp b/src/graphics/central_settings.cpp index 3b793a3f0..b4b7bc888 100644 --- a/src/graphics/central_settings.cpp +++ b/src/graphics/central_settings.cpp @@ -46,7 +46,8 @@ void CentralVideoSettings::init() Log::info("IrrDriver", "OpenGL renderer: %s", glGetString(GL_RENDERER)); Log::info("IrrDriver", "OpenGL version string: %s", glGetString(GL_VERSION)); } - m_glsl = (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version >= 1)); + m_glsl = (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version >= 1)) + && !UserConfigParams::m_force_legacy_device; if (!ProfileWorld::isNoGraphics()) initGL(); diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index c2995d097..3db7aebb3 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -397,6 +397,7 @@ void IrrDriver::initDevice() m_device = NULL; SIrrlichtCreationParameters params; + params.ForceLegacyDevice = UserConfigParams::m_force_legacy_device; // Try 32 and, upon failure, 24 then 16 bit per pixels for (int bits=32; bits>15; bits -=8)