1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-07 00:10:43 +00:00
OpenDiablo2/src/OpenDiablo2.SDL2/include/OpenDiablo2.System/D2Graphics.h

50 lines
795 B
C++

#ifndef OPENDIABLO2_D2GRAPHICS_H
#define OPENDIABLO2_D2GRAPHICS_H
#include <memory>
#include <spdlog/spdlog.h>
#include <SDL2/SDL.h>
namespace OpenDiablo2::System
{
struct SDLWindowDestroyer
{
void operator()(SDL_Window *w) const
{
spdlog::debug("Destroying SDL window");
if (w)
SDL_DestroyWindow(w);
}
};
struct SDLRendererDestroyer
{
void operator()(SDL_Renderer *r) const
{
spdlog::debug("Destroying SDL renderer");
if (r)
SDL_DestroyRenderer(r);
}
};
class D2Graphics
{
public:
typedef std::unique_ptr<D2Graphics> Ptr;
D2Graphics();
void InitializeWindow();
void Clear();
void Present();
private:
std::unique_ptr<SDL_Window, SDLWindowDestroyer> window;
std::unique_ptr<SDL_Renderer, SDLRendererDestroyer> renderer;
};
}
#endif //OPENDIABLO2_D2GRAPHICS_H