diff --git a/MiniEngine_OpenGL.cpp b/MiniEngine_OpenGL.cpp new file mode 100644 index 0000000..98888c3 --- /dev/null +++ b/MiniEngine_OpenGL.cpp @@ -0,0 +1,39 @@ +#include "MiniEngine_OpenGL.h" + +namespace MiniEngine +{ + +namespace OpenGL +{ + +//private +void GLContext::_clear() +{ + _sp.reset(); +} +//private +void GLContext::_set(SDL_GLContext Context) +{ + _sp.reset(Context,SDL_GL_DeleteContext); +} +//private +SDL_GLContext GLContext::_get() const +{ + return _sp.get(); +} + +GLContext::GLContext(Window& wnd) throw (ErrorViewer) +{ + SDL_GLContext context=SDL_GL_CreateContext(_internal::Plugin::get(wnd)); + if(!context) + { + ErrorViewer e; + e.fetch(); + throw e; + } + _set(context); +} + +}/// End of namespace MiniEngine::OpenGL + +}/// End of namespace MiniEngine diff --git a/MiniEngine_OpenGL.h b/MiniEngine_OpenGL.h new file mode 100644 index 0000000..0a9c851 --- /dev/null +++ b/MiniEngine_OpenGL.h @@ -0,0 +1,30 @@ +#pragma once +#include "MiniEngine_Config.h" +#include "GL/glew.h" +#include +#include +#include "SDLWrapper/Window.h" + +namespace MiniEngine +{ + +namespace OpenGL +{ + +class GLContext +{ +public: + GLContext(Window& wnd) throw (ErrorViewer); +private: + void _clear(); + void _set(SDL_GLContext); + SDL_GLContext _get() const; + + /// SDL_GLContext is void* + std::shared_ptr _sp; +}; + + +}/// End of namespace MiniEngine::OpenGL + +}/// End of namespace MiniEngine