载入中...
搜索中...
未找到
IGraphics2D.h
浏览该文件的文档.
1#pragma once
2
3// Narrow 2D-drawing interface of the Graphics backend.
4//
5// Consumers that only draw 2D (map tiles, particles, UI, camera previews)
6// depend on this interface instead of the full graphics::Graphics god class:
7// changing the 2D surface no longer ripples into 3D consumers and vice versa.
8// The concrete backend class implements all facets; methods here are pure
9// virtual so no backend can silently skip a draw.
10
11#include "graphics/BlendMode.h"
12#include "graphics/Color.h"
13
14#include <glm/mat4x4.hpp>
15#include <glm/vec2.hpp>
16
17#include <cstdint>
18#include <string>
19#include <vector>
20
21namespace eve::graphics {
22
23class Canvas;
24class Camera2D;
25class Drawable;
26class Font;
27class Shader;
28class Texture;
29class PrimitiveCanvas2D;
30struct Lighting2DUBO;
31
34public:
36 virtual ~IGraphics2D() = default;
37
39 virtual void clearScreen() = 0;
41 virtual void setBackgroundColorRGBA(float r, float g, float b, float a = 1.f) = 0;
43 virtual void drawSolidRectRGBA(float x, float y, float w, float h, float r, float g, float b,
44 float a = 1.f) = 0;
46 virtual void drawTexturedRectRGBA(Texture *texture, float x, float y, float w, float h,
47 float r, float g, float b, float a = 1.f) = 0;
48
50 virtual void drawSolidRect(float x, float y, float w, float h, const Color &color,
53 virtual void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees,
54 const Color &color,
61 virtual void drawPrimitiveCanvas(const PrimitiveCanvas2D &canvas) = 0;
62
64 virtual void drawTexturedRect(Texture *texture, float x, float y, float w, float h,
65 const Color &color) = 0;
67 virtual void drawTexturedRectShader(Texture *texture, Shader *shader, float x, float y, float w,
68 float h, const Color &color) = 0;
70 virtual void drawTexturedRectUV(Texture *texture, float x, float y, float w, float h, float u0,
71 float v0, float u1, float v1, const Color &color) = 0;
73 virtual void drawTexturedRectShaderUV(Texture *texture, Shader *shader, float x, float y,
74 float w, float h, float u0, float v0, float u1, float v1,
75 const Color &color, bool rotatedUV = false,
78 virtual void drawTexturedRectShaderUVRotated(Texture *texture, Shader *shader, float cx,
79 float cy, float w, float h, float degrees,
80 float u0, float v0, float u1, float v1,
81 const Color &color, bool rotatedUV = false,
85 float x, float y, float w, float h,
86 const Color &tint) = 0;
87
89 virtual void drawTexturedRectLitUV(Texture *albedo, Texture *normal, float x, float y, float w, float h, float u0,
90 float v0, float u1, float v1, const Color &color,
98 virtual void drawTexturedRectLitUVRotated(Texture *albedo, Texture *normal, float cx, float cy, float w, float h,
99 float degrees, float u0, float v0, float u1, float v1, const Color &color,
102 virtual void setLighting2D(const Lighting2DUBO &ubo) = 0;
103
105 virtual void setCanvas(Canvas *canvas) = 0;
107 virtual bool isCanvasActive() const = 0;
109 virtual Canvas *getCanvas() const = 0;
110
112 virtual void setShader(Shader *shader) = 0;
114 virtual void setShader() = 0;
116 virtual Shader *getShader() const = 0;
117
119 virtual void setFont(Font *font) = 0;
121 virtual Font *getFont() const = 0;
132 virtual void print(const std::string &text, float x, float y,
133 const Color &color = Color(1.f, 1.f, 1.f, 1.f), float scale = 1.f) = 0;
146 virtual void drawText(Font *font, const std::string &text, float x, float y,
147 const Color &color = Color(1.f, 1.f, 1.f, 1.f), float scale = 1.f) = 0;
148
150 virtual void draw(Drawable *drawable, const glm::mat4 &m) = 0;
152 virtual void drawOcclusion(Drawable *drawable, const glm::mat4 &m) = 0;
154 virtual void drawOcclusionSolid(float x, float y, float w, float h) = 0;
156 virtual void drawOcclusionTexture(Texture *texture, float x, float y, float w, float h) = 0;
157
159 virtual void pushValidationScope() = 0;
161 virtual void popValidationScope() = 0;
162};
163
164} // namespace eve::graphics
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float cx
Definition CardTypes.cpp:33
float cy
Definition CardTypes.cpp:34
float degrees
Definition CardTypes.cpp:35
graphics::Texture * albedo
tensor::Graph g
Definition GpuGraph.cpp:7
glm::vec4 tint
double r
float blend
int h
std::string text
std::array< float, 3 > scale
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
Texture * normal
Shader * shader
std::uint32_t depth
float m[16]
Canvas public API.
Definition Canvas.h:17
Drawable base (textures, meshes, canvases).
Definition Drawable.h:17
GPU-side font: wraps a decoded font::FontData and rasterizes a fixed set of codepoints into a single ...
Definition Font.h:35
2D immediate-mode drawing surface (screen or offscreen Canvas).
Definition IGraphics2D.h:33
virtual void setLighting2D(const Lighting2DUBO &ubo)=0
Upload per-frame / per-canvas 2D lighting constants.
virtual void setFont(Font *font)=0
Optional shared font used by legacy consumers; nullptr = none set.
virtual void drawTexturedRectRGBA(Texture *texture, float x, float y, float w, float h, float r, float g, float b, float a=1.f)=0
Draws textured rect rgba.
virtual void drawSolidRectRGBA(float x, float y, float w, float h, float r, float g, float b, float a=1.f)=0
Draws solid rect rgba.
virtual void drawTexturedRect(Texture *texture, float x, float y, float w, float h, const Color &color)=0
Draws textured rect.
virtual void pushValidationScope()=0
Backend GPU validation scopes (WebGPU).
virtual void setShader()=0
Sets the shader.
virtual void setBackgroundColorRGBA(float r, float g, float b, float a=1.f)=0
Sets the background color rgba.
virtual void drawTexturedRectUV(Texture *texture, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color)=0
Draws textured rect uv.
virtual void print(const std::string &text, float x, float y, const Color &color=Color(1.f, 1.f, 1.f, 1.f), float scale=1.f)=0
Draws UTF-8 text with the font selected by setFont().
virtual Font * getFont() const =0
Returns the font.
virtual void drawTexturedRectShader(Texture *texture, Shader *shader, float x, float y, float w, float h, const Color &color)=0
Draws textured rect shader.
virtual void popValidationScope()=0
Pops validation scope.
virtual void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Draws solid rect rotated.
virtual void drawText(Font *font, const std::string &text, float x, float y, const Color &color=Color(1.f, 1.f, 1.f, 1.f), float scale=1.f)=0
Draws UTF-8 text with an explicitly supplied GPU font.
virtual void drawSolidRect(float x, float y, float w, float h, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Draws solid rect.
virtual void drawTexturedRectShaderDepth(Texture *color, Texture *depth, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Draws textured rect shader depth.
virtual void clearScreen()=0
Clears the current draw target to the background color.
virtual void drawPrimitiveCanvas(const PrimitiveCanvas2D &canvas)=0
Resolves and queues one frame-local primitive Canvas.
virtual void draw(Drawable *drawable, const glm::mat4 &m)=0
Draws .
virtual void setCanvas(Canvas *canvas)=0
Draw target; nullptr → screen.
virtual Canvas * getCanvas() const =0
Returns the canvas.
virtual void drawOcclusionSolid(float x, float y, float w, float h)=0
Draws occlusion solid.
virtual void drawTexturedRectLitUVRotated(Texture *albedo, Texture *normal, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Lit 2D draw rotated degrees clockwise (screen Y-down) around (cx, cy).
virtual bool isCanvasActive() const =0
True when canvas active.
virtual void setShader(Shader *shader)=0
Custom fragment pipeline for subsequent textured 2D draws.
virtual void drawOcclusion(Drawable *drawable, const glm::mat4 &m)=0
Draws occlusion.
virtual void drawOcclusionTexture(Texture *texture, float x, float y, float w, float h)=0
Draws occlusion texture.
virtual ~IGraphics2D()=default
Releases IGraphics2D resources.
virtual Shader * getShader() const =0
Returns the shader.
virtual void drawTexturedRectShaderUV(Texture *texture, Shader *shader, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color, bool rotatedUV=false, BlendMode blend=BlendMode::Alpha)=0
Draws textured rect shader uv.
virtual void drawTexturedRectShaderUVRotated(Texture *texture, Shader *shader, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, const Color &color, bool rotatedUV=false, BlendMode blend=BlendMode::Alpha)=0
Draws textured rect shader uv rotated.
virtual void drawTexturedRectLitUV(Texture *albedo, Texture *normal, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Lit 2D draw (albedo + normal map); normal may be null → flat.
Frame-local Skia-style recorder for 2D line primitives.
Custom GPU program.
Definition Shader.h:39
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:18
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
BlendMode
Render-neutral 2D blend mode shared by graphics-facing modules.
Definition RenderTypes.h:11
Lighting2DUBO public API.
Definition Light.h:53
glm::vec4 color