This repository has been archived on 2022-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
space-war/include/tinyengine/renderer.hpp

61 lines
1.9 KiB
C++
Raw Normal View History

2022-01-30 21:24:16 +08:00
#pragma once
#include "pch.hpp"
2022-01-30 21:24:16 +08:00
#include "libmath.hpp"
#include "texture.hpp"
#include "glhelpfunc.hpp"
#include "shader.hpp"
#include "camera.hpp"
#include "tilesheet.hpp"
struct Vertex {
Point pos;
Point texcoord;
};
2022-01-30 21:24:16 +08:00
class Renderer final {
public:
enum FlipFlag {
NoFlip = 0,
Vertical = 0x01,
Horizontal = 0x02,
Both = 0x03,
};
2022-01-30 21:24:16 +08:00
static void Init();
static void Shutdown();
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);
static void DrawTile(const Tile& tile,
const Point& pos,
const Size& = {0, 0},
float degree = 0,
FlipFlag = NoFlip,
const Color& = {1, 1, 1, 1});
static void DrawTexture(const Texture* texture,
const Rect* srcrect,
const Point& pos,
const Size& = Size{0, 0},
float degree = 0,
FlipFlag = NoFlip,
const Color& = {1, 1, 1, 1});
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);
static const Color& GetDrawColor();
static void SetCamera(Camera& camera);
private:
static Color color_;
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
};