Skip to content

Commit f9bf70d

Browse files
committed
GLSupport: make sure we request the maximum available GL context
1 parent 2dc0861 commit f9bf70d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

RenderSystems/GLSupport/src/win32/OgreWin32GLSupport.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@
3636
#include "OgreWin32Window.h"
3737
#include "OgreGLUtil.h"
3838

39+
#include <GL/gl.h>
3940
#include <GL/wglext.h>
4041

4142
static PFNWGLCREATECONTEXTATTRIBSARBPROC _wglCreateContextAttribsARB = 0;
4243

44+
static int glMajorMax = 0;
45+
static int glMinorMax = 0;
46+
4347
namespace Ogre {
4448
GLNativeSupport* getGLSupport(int profile)
4549
{
@@ -303,6 +307,11 @@ namespace Ogre {
303307
// if wglMakeCurrent fails, wglGetProcAddress will return null
304308
wglMakeCurrent(hdc, hrc);
305309

310+
// the default context is created with maximum version
311+
// use GL3 query type, as it is the only consumer
312+
glGetIntegerv(0x821B, &glMajorMax);
313+
glGetIntegerv(0x821C, &glMinorMax);
314+
306315
_wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
307316
wglGetProcAddress("wglCreateContextAttribsARB");
308317

@@ -473,8 +482,8 @@ namespace Ogre {
473482
break;
474483
default:
475484
profile = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
476-
majorVersion = 3;
477-
minorVersion = 3; // 3.1 would be sufficient per spec, but we need 3.3 anyway..
485+
majorVersion = std::max(glMajorMax, 3);
486+
minorVersion = std::max(glMinorMax, 3); // 3.1 would be sufficient per spec, but we need 3.3 anyway..
478487
break;
479488
}
480489

0 commit comments

Comments
 (0)