Parse more context in windows build.

This commit is contained in:
Vincent Lejeune 2014-03-26 22:13:02 +01:00
parent 14500d65ab
commit b9d0088ff9

View File

@ -84,6 +84,52 @@ bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrr
return true; return true;
} }
static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB;
static HGLRC getMeAGLContext(HDC HDc)
{
HGLRC hrc = 0;
int ctx40[] =
{
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_COMPATIBILITY_PROFILE_BIT_ARB,
0
};
hrc = wglCreateContextAttribs_ARB(HDc, 0, ctx40);
if (hrc)
return hrc;
int ctx33[] =
{
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_COMPATIBILITY_PROFILE_BIT_ARB,
0
};
hrc = wglCreateContextAttribs_ARB(HDc, 0, ctx33);
if (hrc)
return hrc;
int ctx31[] =
{
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_COMPATIBILITY_PROFILE_BIT_ARB,
0
};
hrc = wglCreateContextAttribs_ARB(HDc, 0, ctx33);
if (hrc)
return hrc;
return NULL;
}
//! inits the open gl driver //! inits the open gl driver
bool COpenGLDriver::initDriver(CIrrDeviceWin32* device) bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
{ {
@ -339,7 +385,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
#endif #endif
AntiAlias=0; AntiAlias=0;
#ifdef WGL_ARB_create_context #ifdef WGL_ARB_create_context
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
#endif #endif
wglMakeCurrent(HDc, NULL); wglMakeCurrent(HDc, NULL);
wglDeleteContext(hrc); wglDeleteContext(hrc);
@ -409,22 +455,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
#ifdef WGL_ARB_create_context #ifdef WGL_ARB_create_context
if (wglCreateContextAttribs_ARB) if (wglCreateContextAttribs_ARB)
{ {
int iAttribs[] = hrc = getMeAGLContext(HDc);
{
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_COMPATIBILITY_PROFILE_BIT_ARB, //WGL_CONTEXT_CORE_PROFILE_BIT_ARB
0
};
// hd3000 only provides 3.1, so try all minor versions backwards, to find one that works.
for (int minor = 3; minor >= 0; minor--)
{
iAttribs[3] = minor;
hrc = wglCreateContextAttribs_ARB(HDc, 0, iAttribs);
if (hrc)
break;
}
} }
else else
#endif #endif