This repository has been archived on 2023-06-25. You can view files and clone it, but cannot push or open issues or pull requests.
2023-06-24 18:38:24 +08:00
|
|
|
#pragma once
|
|
|
|
#include "pch.hpp"
|
|
|
|
#include "window.hpp"
|
|
|
|
|
2023-06-25 11:20:06 +08:00
|
|
|
inline auto RendererDestroy = [](SDL_Renderer* renderer) {
|
|
|
|
SDL_DestroyRenderer(renderer);
|
|
|
|
};
|
|
|
|
|
2023-06-24 18:38:24 +08:00
|
|
|
class Renderer final {
|
|
|
|
public:
|
|
|
|
friend struct Context;
|
|
|
|
|
|
|
|
Renderer(const Window&);
|
|
|
|
|
|
|
|
void SetColor(const SDL_Color&);
|
|
|
|
void Clear();
|
|
|
|
void Present();
|
|
|
|
void DrawRect(const SDL_Rect& rect);
|
|
|
|
void FillRect(const SDL_Rect& rect);
|
|
|
|
void DrawLine(const SDL_Point& p1, const SDL_Point& p2);
|
|
|
|
void DrawTexture(SDL_Texture*, const SDL_Rect&, int x, int y);
|
|
|
|
|
|
|
|
private:
|
2023-06-25 11:20:06 +08:00
|
|
|
std::unique_ptr<SDL_Renderer, decltype(RendererDestroy)> renderer_;
|
2023-06-24 18:38:24 +08:00
|
|
|
};
|