Zen 0.3.0
Loading...
Searching...
No Matches
ZEN_OpenGLContext.cpp
1#include <iostream>
2#include <zen/platform/OpenGL/ZEN_OpenGLContext.h>
3
4namespace Zen {
5 OpenGLContext::OpenGLContext(SDL_Window *window) : m_window(window) {
6 ZEN_LOG_DEBUG("OpenGL context bound");
7 };
8
9 OpenGLContext::~OpenGLContext() { shutdown(); };
10
11 void OpenGLContext::init() {
12 m_glContext = SDL_GL_CreateContext(m_window);
13 ZEN_LOG_DEBUG("OpenGL context initialized");
14 };
15
16 void OpenGLContext::swapBuffers() { SDL_GL_SwapWindow(m_window); }
17
18 void OpenGLContext::shutdown() {
19 if (m_glContext != nullptr) {
20 SDL_GL_DestroyContext(m_glContext);
21 m_glContext = nullptr;
22 ZEN_LOG_DEBUG("OpenGL context destroyed");
23 }
24 }
25
26 void *OpenGLContext::nativeContext() const { return m_glContext; };
27}; // namespace Zen