From 21a147c3c1c2fad2819fe76becab320c51eb131f Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sun, 2 Apr 2017 09:15:30 +0100 Subject: Adding initial files --- src/window.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/window.cpp (limited to 'src/window.cpp') diff --git a/src/window.cpp b/src/window.cpp new file mode 100644 index 00000000..dd993d19 --- /dev/null +++ b/src/window.cpp @@ -0,0 +1,39 @@ +#include "window.hpp" + +#include + +#include +#include + +Window::Window() +{} + +Window::~Window() +{} + +void Window::create(const std::string &window_name, int width, int height, WindowFlags flags) +{ + // SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 4); + // SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 5); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + + window_ = SDL_CreateWindow("Arider", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + width_, height_, SDL_WINDOW_OPENGL); + if(window_ == nullptr) + throw std::runtime_error("SDL_CreateWindow failed"); + + SDL_GLContext gl_context = SDL_GL_CreateContext(window_); + if(gl_context == nullptr) + throw std::runtime_error("SDL_GL_CreateContext failed"); + + GLenum error = glewInit(); + if(error != GLEW_OK) + throw std::runtime_error("glewInit failed"); + + std::cout<<"*** OpenGL version: "<