87 lines
2.7 KiB
C++
87 lines
2.7 KiB
C++
#pragma once
|
|
#include "Color.h"
|
|
#include "Vector2.h"
|
|
#include "Triangle.h"
|
|
#include "Image.h"
|
|
#include "Sprite.h"
|
|
#include "Tilemap.h"
|
|
#include "BitmapFont.h"
|
|
#include <cstdint>
|
|
|
|
namespace Core
|
|
{
|
|
class FrameBuffer;
|
|
class DepthBuffer;
|
|
}
|
|
|
|
namespace Rasterizer
|
|
{
|
|
class Rasterizer;
|
|
class TriangleRasterizer;
|
|
}
|
|
|
|
namespace Platform
|
|
{
|
|
class IDisplay;
|
|
}
|
|
|
|
namespace Core
|
|
{
|
|
class DrawContext
|
|
{
|
|
private:
|
|
Core::FrameBuffer* frameBuffer;
|
|
Core::DepthBuffer* depthBuffer;
|
|
Rasterizer::Rasterizer* rasterizer;
|
|
Rasterizer::TriangleRasterizer* triangleRasterizer;
|
|
|
|
void draw_font_mask_region(const RenderData::BitmapFont& font,
|
|
int32_t src_x, int32_t src_y,
|
|
int32_t src_w, int32_t src_h,
|
|
int32_t dst_x, int32_t dst_y,
|
|
uint16_t pixel);
|
|
|
|
void blit_sprite_pixels(int32_t dst_x, int32_t dst_y,
|
|
const RenderData::Image& image,
|
|
int32_t src_x, int32_t src_y,
|
|
int32_t src_w, int32_t src_h,
|
|
int32_t scale, bool flip_h, bool flip_v);
|
|
|
|
public:
|
|
DrawContext(int32_t width, int32_t height);
|
|
~DrawContext();
|
|
|
|
DrawContext(const DrawContext&) = delete;
|
|
DrawContext& operator=(const DrawContext&) = delete;
|
|
|
|
int32_t get_width() const;
|
|
int32_t get_height() const;
|
|
|
|
void clear(const RenderData::Color& color);
|
|
void clear_color(const RenderData::Color& color);
|
|
void clear_depth();
|
|
|
|
void draw_line(const Math::Vector2Int& from, const Math::Vector2Int& to, const RenderData::Color& color);
|
|
void draw_triangle(const RenderData::Triangle& triangle, const RenderData::Color& color);
|
|
|
|
void draw_sprite(int32_t dst_x, int32_t dst_y, const RenderData::Sprite& sprite);
|
|
void draw_sprite_ex(int32_t dst_x, int32_t dst_y, const RenderData::Sprite& sprite,
|
|
int32_t scale, bool flip_h, bool flip_v);
|
|
void draw_tilemap(const RenderData::Tilemap& tilemap,
|
|
int32_t screen_x, int32_t screen_y,
|
|
int32_t camera_x, int32_t camera_y);
|
|
void draw_tilemap(const RenderData::Tilemap& tilemap,
|
|
int32_t screen_x, int32_t screen_y,
|
|
int32_t viewport_w, int32_t viewport_h,
|
|
int32_t camera_x, int32_t camera_y);
|
|
|
|
void fill_rect(int32_t x, int32_t y, int32_t w, int32_t h, const RenderData::Color& color);
|
|
void draw_text(const RenderData::BitmapFont& font, int32_t x, int32_t y,
|
|
const RenderData::Color& color, const char* text);
|
|
void draw_text(const RenderData::BitmapFont& font, int32_t x, int32_t y,
|
|
const RenderData::Color& color, const RenderData::Color& bg_color, const char* text);
|
|
|
|
void present(Platform::IDisplay* display);
|
|
};
|
|
}
|