Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
UltimateZoneBuilder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alam Ed Arias
UltimateZoneBuilder
Commits
d49a6e22
Commit
d49a6e22
authored
5 years ago
by
Magnus Norddahl
Browse files
Options
Downloads
Patches
Plain Diff
Work a little harder to find an usable OpenGL version
parent
e4e05542
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Source/Native/OpenGL/OpenGLContext.cpp
+47
-38
47 additions, 38 deletions
Source/Native/OpenGL/OpenGLContext.cpp
with
47 additions
and
38 deletions
Source/Native/OpenGL/OpenGLContext.cpp
+
47
−
38
View file @
d49a6e22
...
...
@@ -119,7 +119,7 @@ public:
OpenGLCreationHelper
(
HWND
window
);
~
OpenGLCreationHelper
();
HGLRC
CreateContext
(
HDC
hdc
,
int
major_version
,
int
minor_version
,
HGLRC
share_context
=
0
);
HGLRC
CreateContext
(
HDC
hdc
,
HGLRC
share_context
=
0
);
private:
HWND
window
;
...
...
@@ -142,7 +142,7 @@ OpenGLContext::OpenGLContext(void* windowptr) : window((HWND)windowptr)
{
dc
=
GetDC
(
window
);
OpenGLCreationHelper
helper
(
window
);
context
=
helper
.
CreateContext
(
dc
,
3
,
2
);
context
=
helper
.
CreateContext
(
dc
);
if
(
context
)
{
MakeCurrent
();
...
...
@@ -253,7 +253,7 @@ OpenGLCreationHelper::~OpenGLCreationHelper()
DestroyWindow
(
query_window
);
}
HGLRC
OpenGLCreationHelper
::
CreateContext
(
HDC
hdc
,
int
major_version
,
int
minor_version
,
HGLRC
share_context
)
HGLRC
OpenGLCreationHelper
::
CreateContext
(
HDC
hdc
,
HGLRC
share_context
)
{
if
(
query_context
==
0
)
return
0
;
...
...
@@ -281,22 +281,27 @@ HGLRC OpenGLCreationHelper::CreateContext(HDC hdc, int major_version, int minor_
HGLRC
opengl3_context
=
0
;
if
(
wglCreateContextAttribsARB
)
{
std
::
vector
<
int
>
int_attributes
;
int_attributes
.
push_back
(
WGL_CONTEXT_MAJOR_VERSION_ARB
);
int_attributes
.
push_back
(
major_version
);
int_attributes
.
push_back
(
WGL_CONTEXT_MINOR_VERSION_ARB
);
int_attributes
.
push_back
(
minor_version
);
int_attributes
.
push_back
(
0x2094
);
// WGL_CONTEXT_FLAGS_ARB
int_attributes
.
push_back
(
0x2
);
// WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
int_attributes
.
push_back
(
0x9126
);
// WGL_CONTEXT_PROFILE_MASK_ARB
int_attributes
.
push_back
(
0x1
);
// WGL_CONTEXT_CORE_PROFILE_BIT_ARB
int_attributes
.
push_back
(
0
);
for
(
int
profile
:
{
1
/*WGL_CONTEXT_CORE_PROFILE_BIT_ARB*/
,
2
/*WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB*/
})
{
for
(
int
version
:
{
46
,
45
,
44
,
43
,
42
,
41
,
40
,
33
,
32
})
{
std
::
vector
<
int
>
int_attributes
;
int_attributes
.
push_back
(
WGL_CONTEXT_MAJOR_VERSION_ARB
);
int_attributes
.
push_back
(
version
/
10
);
int_attributes
.
push_back
(
WGL_CONTEXT_MINOR_VERSION_ARB
);
int_attributes
.
push_back
(
version
%
10
);
int_attributes
.
push_back
(
0x9126
);
// WGL_CONTEXT_PROFILE_MASK_ARB
int_attributes
.
push_back
(
0x1
);
// WGL_CONTEXT_CORE_PROFILE_BIT_ARB
int_attributes
.
push_back
(
0
);
opengl3_context
=
wglCreateContextAttribsARB
(
hdc
,
share_context
,
int_attributes
.
data
());
if
(
opengl3_context
)
break
;
}
opengl3_context
=
wglCreateContextAttribsARB
(
hdc
,
share_context
,
int_attributes
.
data
());
if
(
opengl3_context
)
break
;
}
}
wglMakeCurrent
(
0
,
0
);
...
...
@@ -809,32 +814,36 @@ GLXContext OpenGLContext::create_context_glx_1_3(GLXContext shared_context)
// threads issuing X commands while this code is running.
int
(
*
oldHandler
)(
::
Display
*
,
XErrorEvent
*
)
=
XSetErrorHandler
(
&
cl_ctxErrorHandler
);
std
::
vector
<
int
>
int_attributes
;
int_attributes
.
push_back
(
0x2091
);
// GLX_CONTEXT_MAJOR_VERSION_ARB
int_attributes
.
push_back
(
major_version
);
int_attributes
.
push_back
(
0x2092
);
// GLX_CONTEXT_MINOR_VERSION_ARB
int_attributes
.
push_back
(
minor_version
);
int_attributes
.
push_back
(
0x2094
);
// GLX_CONTEXT_FLAGS_ARB
int_attributes
.
push_back
(
0x2
);
// GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
GLXContext
context_gl3
=
0
;
for
(
int
profile
:
{
1
/*GLX_CONTEXT_CORE_PROFILE_BIT_ARB*/
,
2
/*GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB*/
})
{
for
(
int
version
:
{
46
,
45
,
44
,
43
,
42
,
41
,
40
,
33
,
32
})
{
std
::
vector
<
int
>
int_attributes
;
int_attributes
.
push_back
(
0x2091
);
// GLX_CONTEXT_MAJOR_VERSION_ARB
int_attributes
.
push_back
(
version
/
10
);
int_attributes
.
push_back
(
0x2092
);
// GLX_CONTEXT_MINOR_VERSION_ARB
int_attributes
.
push_back
(
version
%
10
);
int_attributes
.
push_back
(
0x9126
);
// GLX_CONTEXT_PROFILE_MASK_ARB
int_attributes
.
push_back
(
profile
);
int_attributes
.
push_back
(
None
);
int_attributes
.
push_back
(
0x9126
);
// GLX_CONTEXT_PROFILE_MASK_ARB
int_attributes
.
push_back
(
0x1
);
// GLX_CONTEXT_CORE_PROFILE_BIT_ARB
cl_ctxErrorOccurred
=
false
;
int_attributes
.
push_back
(
None
);
context_gl3
=
glXCreateContextAttribs
(
disp
,
fbconfig
,
shared_context
,
True
,
int_attributes
.
data
()
);
cl_ctxErrorOccurred
=
false
;
if
(
cl_ctxErrorOccurred
&&
context_gl3
)
{
glx
.
glXDestroyContext
(
disp
,
context_gl3
);
context_gl3
=
nullptr
;
}
GLXContext
context_gl3
=
glXCreateContextAttribs
(
disp
,
fbconfig
,
shared_context
,
True
,
&
int_attributes
[
0
]);
if
(
context_gl3
)
break
;
}
if
(
cl_ctxErrorOccurred
)
{
if
(
context_gl3
)
{
glx
.
glXDestroyContext
(
disp
,
context_gl3
);
context_gl3
=
nullptr
;
}
break
;
}
// Restore the original error handler
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment