#include #include SdlMainWindow::SdlMainWindow(int height, int width) : MainWindow() { this->width = width; this->height = height; this->window = NULL; this->context = NULL; } SdlMainWindow::~SdlMainWindow() { if (this->window) SDL_DestroyWindow(window); } void SdlMainWindow::show() { this->window = SDL_CreateWindow("OpenGL Playground", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, this->width, this->height, SDL_WINDOW_OPENGL); return; } void SdlMainWindow::swapBuffer() { if (this->window) SDL_GL_SwapWindow(this->window); } void SdlMainWindow::activateGlContext() { // OPENGL VERSION SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); if (this->context == NULL) this->context = SDL_GL_CreateContext(this->window); else SDL_GL_MakeCurrent(this->window, this->context); } SDL_Window *SdlMainWindow::getWindow() { return this->window; } SDL_GLContext SdlMainWindow::getContext() { return this->context; }