aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-04-02 09:15:30 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-04-02 09:15:30 +0100
commit21a147c3c1c2fad2819fe76becab320c51eb131f (patch)
tree9114123be1d9165a199d8b27af8f9b4e00333e71 /src/window.cpp
downloadYAGE-21a147c3c1c2fad2819fe76becab320c51eb131f.tar.gz
YAGE-21a147c3c1c2fad2819fe76becab320c51eb131f.zip
Adding initial files
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp39
1 files changed, 39 insertions, 0 deletions
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 <GL/glew.h>
+
+#include <iostream>
+#include <stdexcept>
+
+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: "<<glGetString(GL_VERSION)<<" ***\n";
+
+ SDL_GL_SetSwapInterval(1);
+
+ glClearColor(0.f, 0.f, 0.f, 1.f);
+}