Add OpenGL Support

This commit is contained in:
Kirigaya Kazuto 2017-07-01 17:25:48 +08:00
parent ff862f1dea
commit 6a830fbfd3
2 changed files with 69 additions and 0 deletions

39
MiniEngine_OpenGL.cpp Normal file
View File

@ -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

30
MiniEngine_OpenGL.h Normal file
View File

@ -0,0 +1,30 @@
#pragma once
#include "MiniEngine_Config.h"
#include "GL/glew.h"
#include <SDL2/SDL_opengl.h>
#include <memory>
#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<void> _sp;
};
}/// End of namespace MiniEngine::OpenGL
}/// End of namespace MiniEngine