载入中...
搜索中...
未找到
DrawItem2D.h
浏览该文件的文档.
1#pragma once
2
3#include "graphics/Canvas.h"
5#include "graphics/Quad.h"
6#include "graphics/Shader.h"
7#include "graphics/Texture.h"
8
9#include <algorithm>
10#include <cstdint>
11#include <vector>
12
13namespace eve::graphics {
14
15class Camera2D;
16
18struct DrawItem2D {
19 float x = 0.f;
20 float y = 0.f;
21 float w = 0.f;
22 float h = 0.f;
23 float depthY = 0.f;
25 float rotation = 0.f;
28 int order = 0;
29 bool hasOrder = false;
30 Color color{1.f, 1.f, 1.f, 1.f};
31 int layer = 0;
34 Texture *texture = nullptr;
35 Texture *normal = nullptr;
36 Quad *quad = nullptr;
37 Shader *shader = nullptr;
38 Canvas *canvas = nullptr;
39 Camera2D *camera = nullptr;
40 bool receiveLight = true;
41 bool litPath = false;
42 bool hasUV = false;
44 bool rotatedUV = false;
45 float u0 = 0.f, v0 = 0.f, u1 = 1.f, v1 = 1.f;
47 float camX = 0.f, camY = 0.f, camZoom = 1.f;
48 bool camValid = false;
49 Color camClear{0.1f, 0.1f, 0.12f, 1.f};
50 float camAmbientR = 0.15f, camAmbientG = 0.15f, camAmbientB = 0.18f;
51};
52
53inline void sortDrawItems2D(std::vector<DrawItem2D> &items) {
54 std::stable_sort(items.begin(), items.end(), [](const DrawItem2D &a, const DrawItem2D &b) {
55 const bool aOff = a.canvas != nullptr;
56 const bool bOff = b.canvas != nullptr;
57 if (aOff != bOff) return aOff && !bOff;
58 if (a.canvas != b.canvas) return a.canvas < b.canvas;
59 if (a.layer != b.layer) return a.layer < b.layer;
60 if (a.hasOrder && b.hasOrder && a.order != b.order) return a.order < b.order;
61 if (a.depthY != b.depthY) return a.depthY < b.depthY;
62 if (a.litPath != b.litPath) return !a.litPath && b.litPath;
63 if (a.shader != b.shader) return a.shader < b.shader;
64 if (a.blend != b.blend) return a.blend < b.blend;
65 if (a.texture != b.texture) return a.texture < b.texture;
66 return a.normal < b.normal;
67 });
68}
69
70} // namespace eve::graphics
uint32_t a
uint32_t b
Declarative 2D camera (viewport center + zoom).
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:9
Custom GPU program.
Definition Shader.h:30
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:17
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6
glm::vec4 Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
BlendMode
2D quad blend mode (drawn in draw order within a layer).
Definition BlendMode.h:6
void sortDrawItems2D(std::vector< DrawItem2D > &items)
Definition DrawItem2D.h:53
Shared 2D draw queue item (sprites + tiles).
Definition DrawItem2D.h:18
BlendMode blend
2D quad blending (alpha / additive / opaque).
Definition DrawItem2D.h:33
bool rotatedUV
Atlas-packed rotated region: corner UVs are remapped (rotated 90°).
Definition DrawItem2D.h:44
float camX
Screen-space camera already resolved; if cameraEntity set, RenderSystem resolves.
Definition DrawItem2D.h:47
float rotation
Degrees, clockwise, around the rectangle center (screen Y-down).
Definition DrawItem2D.h:25