3 #include "../app/error.hpp"
12 Window::Window(int width, int height) {
13 window = SDL_CreateWindow(
15 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, // position
16 width, height, // size
17 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE // flags
20 throw SDLError("SDL_CreateWindow");
22 context = SDL_GL_CreateContext(window);
24 SDL_DestroyWindow(window);
25 throw SDLError("SDL_GL_CreateContext");
27 glewExperimental = GL_TRUE;
28 GLenum err = glewInit();
30 SDL_GL_DeleteContext(context);
31 SDL_DestroyWindow(window);
32 std::string msg("glewInit: ");
33 msg += reinterpret_cast<const char *>(glewGetErrorString(err));
34 throw std::runtime_error(msg);
38 Window::~Window() noexcept {
39 SDL_GL_DeleteContext(context);
40 SDL_DestroyWindow(window);
43 void Window::Flip() noexcept {
44 SDL_GL_SwapWindow(window);