Added some support to enable a legacy (2.1) opengl context. Many

things don't work with that atm (rtt, some transparent textures).
Needs to be manually set in the user's config file.
This commit is contained in:
hiker 2015-03-11 16:45:20 +11:00
parent acd66f46ff
commit 98671b620d
5 changed files with 93 additions and 77 deletions

View File

@ -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. */

View File

@ -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

View File

@ -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"));

View File

@ -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();

View File

@ -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)