#include "gl_context.hpp" #include namespace bookmouse { GlContext::GlContext(SdlMainWindow& mainWindow) { m_context = SDL_GL_CreateContext(mainWindow.window()); if (m_context == nullptr) { auto error = SDL_GetError(); throw std::runtime_error{error}; } auto status = SDL_GL_MakeCurrent(mainWindow.window(), m_context); if (status != 0) { auto error = SDL_GetError(); throw std::runtime_error{error}; } status = SDL_GL_SetSwapInterval(1); // Enable vsync if (status != 0) { auto error = SDL_GetError(); throw std::runtime_error{error}; } } GlContext::~GlContext() { SDL_GL_DeleteContext(m_context); } } // namespace bookmouse