--- /dev/null
+#include "window.hpp"
+
+#include "../app/error.hpp"
+
+#include <stdexcept>
+#include <string>
+#include <GL/glew.h>
+
+
+namespace tacos {
+
+Window::Window(int width, int height) {
+ window = SDL_CreateWindow(
+ "tacos", // title
+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, // position
+ width, height, // size
+ SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE // flags
+ );
+ if (!window) {
+ throw SDLError("SDL_CreateWindow");
+ }
+ context = SDL_GL_CreateContext(window);
+ if (!context) {
+ SDL_DestroyWindow(window);
+ throw SDLError("SDL_GL_CreateContext");
+ }
+ glewExperimental = GL_TRUE;
+ GLenum err = glewInit();
+ if (err != GLEW_OK) {
+ SDL_GL_DeleteContext(context);
+ SDL_DestroyWindow(window);
+ std::string msg("glewInit: ");
+ msg += reinterpret_cast<const char *>(glewGetErrorString(err));
+ throw std::runtime_error(msg);
+ }
+}
+
+Window::~Window() noexcept {
+ SDL_GL_DeleteContext(context);
+ SDL_DestroyWindow(window);
+}
+
+void Window::Flip() noexcept {
+ SDL_GL_SwapWindow(window);
+}
+
+
+}