2022-01-30 21:24:16 +08:00
|
|
|
#pragma once
|
2022-02-03 22:33:33 +08:00
|
|
|
#include "pch.hpp"
|
2022-01-30 21:24:16 +08:00
|
|
|
#include "libmath.hpp"
|
|
|
|
#include "texture.hpp"
|
|
|
|
#include "glhelpfunc.hpp"
|
2022-02-03 22:33:33 +08:00
|
|
|
#include "shader.hpp"
|
|
|
|
#include "camera.hpp"
|
2022-02-05 20:52:01 +08:00
|
|
|
#include "tilesheet.hpp"
|
|
|
|
|
|
|
|
struct Vertex {
|
|
|
|
Point pos;
|
|
|
|
Point texcoord;
|
|
|
|
};
|
2022-01-30 21:24:16 +08:00
|
|
|
|
|
|
|
class Renderer final {
|
|
|
|
public:
|
2022-02-05 20:52:01 +08:00
|
|
|
enum FlipFlag {
|
|
|
|
NoFlip = 0,
|
|
|
|
Vertical = 0x01,
|
|
|
|
Horizontal = 0x02,
|
|
|
|
Both = 0x03,
|
|
|
|
};
|
|
|
|
|
2022-01-30 21:24:16 +08:00
|
|
|
static void Init();
|
|
|
|
static void Shutdown();
|
2022-02-03 22:33:33 +08:00
|
|
|
static void SetClearColor(const Color&);
|
|
|
|
static void SetDrawColor(const Color&);
|
2022-01-30 21:24:16 +08:00
|
|
|
static void Clear();
|
|
|
|
static void DrawLine(const Point& p1, const Point& p2);
|
|
|
|
static void DrawRect(const Rect& rect);
|
|
|
|
static void FillRect(const Rect& rect);
|
2022-02-05 20:52:01 +08:00
|
|
|
static void DrawTile(const Tile& tile,
|
|
|
|
const Point& pos,
|
|
|
|
const Size& size = {0, 0},
|
|
|
|
float degree = 0,
|
|
|
|
FlipFlag flip = NoFlip);
|
|
|
|
static void DrawTexture(const Texture* texture,
|
|
|
|
const Rect* srcrect,
|
|
|
|
const Point& pos,
|
|
|
|
const Size& size = Size{0, 0},
|
|
|
|
float degree = 0,
|
|
|
|
FlipFlag flip = NoFlip);
|
|
|
|
static void DrawTexture(const Texture* texture,
|
|
|
|
const Rect* rect,
|
|
|
|
const Mat44& transform,
|
|
|
|
const Color& color = Color{1, 1, 1, 1});
|
2022-01-30 21:24:16 +08:00
|
|
|
static void SetViewport(int x, int y, int w, int h);
|
2022-02-03 22:33:33 +08:00
|
|
|
static const Color& GetDrawColor();
|
|
|
|
static void SetCamera(Camera& camera);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static Color color_;
|
2022-02-05 20:52:01 +08:00
|
|
|
|
|
|
|
static void drawRectFrag(const Texture* texture,
|
|
|
|
const std::array<Vertex, 6>& vertices,
|
|
|
|
const Mat44& transform,
|
|
|
|
const Color& color);
|
2022-01-30 21:24:16 +08:00
|
|
|
};
|