Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
RoboGuide
scigl_render
Commits
5f2ef2d9
Commit
5f2ef2d9
authored
Mar 06, 2019
by
Tim Übelhör
Browse files
allowing the user to require an opengl version.
default is 4.3
parent
35f3ae7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/scigl_render/gl_context.hpp
View file @
5f2ef2d9
...
...
@@ -15,7 +15,8 @@ The copy constructor is deleted, use a shard_ptr.
class
GLContext
{
public:
GLContext
(
bool
visible
,
bool
fullscreen
,
int
width
,
int
height
);
GLContext
(
bool
visible
,
bool
fullscreen
,
int
width
,
int
height
,
int
version_major
=
4
,
int
version_minor
=
3
);
GLContext
(
const
GLContext
&
)
=
delete
;
~
GLContext
();
...
...
src/gl_context.cpp
View file @
5f2ef2d9
...
...
@@ -6,13 +6,14 @@
namespace
scigl_render
{
GLContext
::
GLContext
(
bool
visible
,
bool
fullscreen
,
int
width
,
int
height
)
GLContext
::
GLContext
(
bool
visible
,
bool
fullscreen
,
int
width
,
int
height
,
int
version_major
,
int
version_minor
)
:
width
(
width
),
height
(
height
)
{
glfwInit
();
// compability requirements
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MAJOR
,
4
);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MINOR
,
2
);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MAJOR
,
version_major
);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MINOR
,
version_minor
);
glfwWindowHint
(
GLFW_OPENGL_PROFILE
,
GLFW_OPENGL_CORE_PROFILE
);
glfwWindowHint
(
GLFW_OPENGL_FORWARD_COMPAT
,
GL_TRUE
);
glfwWindowHint
(
GLFW_RESIZABLE
,
GL_FALSE
);
...
...
@@ -39,9 +40,10 @@ GLContext::GLContext(bool visible, bool fullscreen, int width, int height)
{
throw
std
::
runtime_error
(
"Failed to initialize OpenGL"
);
}
if
(
!
gl3wIsSupported
(
4
,
2
))
if
(
!
gl3wIsSupported
(
version_major
,
version_minor
))
{
throw
std
::
runtime_error
(
"OpenGL 4.2 not supported"
);
throw
std
::
runtime_error
(
"OpenGL "
+
std
::
to_string
(
version_major
)
+
"."
+
std
::
to_string
(
version_minor
)
+
" not supported"
);
}
std
::
cout
<<
"OpenGL Version: "
<<
glGetString
(
GL_VERSION
)
<<
" GLSL Version: "
<<
glGetString
(
GL_SHADING_LANGUAGE_VERSION
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment