mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
Add OpenGL Support
This commit is contained in:
parent
ff862f1dea
commit
6a830fbfd3
39
MiniEngine_OpenGL.cpp
Normal file
39
MiniEngine_OpenGL.cpp
Normal 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
30
MiniEngine_OpenGL.h
Normal 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
|
Loading…
Reference in New Issue
Block a user