From 6a830fbfd3812136a1fa2b901038f44923b250f6 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Sat, 1 Jul 2017 17:25:48 +0800 Subject: [PATCH] Add OpenGL Support --- MiniEngine_OpenGL.cpp | 39 +++++++++++++++++++++++++++++++++++++++ MiniEngine_OpenGL.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 MiniEngine_OpenGL.cpp create mode 100644 MiniEngine_OpenGL.h 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