Commit 5f2ef2d9 authored by Tim Übelhör's avatar Tim Übelhör

allowing the user to require an opengl version.

default is 4.3
parent 35f3ae7a
......@@ -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();
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment