载入中...
搜索中...
未找到
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;
27 float anchorX = 0.5f, anchorY = 0.5f;
28 bool flipX = false, flipY = false;
31 int order = 0;
32 bool hasOrder = false;
33 Color color{1.f, 1.f, 1.f, 1.f};
34 int layer = 0;
37 Texture *texture = nullptr;
38 Texture *normal = nullptr;
39 Quad *quad = nullptr;
40 Shader *shader = nullptr;
41 Canvas *canvas = nullptr;
42 Camera2D *camera = nullptr;
43 bool receiveLight = true;
44 bool litPath = false;
48 float distortionStrength = 0.f;
49 bool hasUV = false;
51 bool rotatedUV = false;
52 float u0 = 0.f, v0 = 0.f, u1 = 1.f, v1 = 1.f;
54 float camX = 0.f, camY = 0.f, camZoom = 1.f;
55 bool camValid = false;
56 Color camClear{0.1f, 0.1f, 0.12f, 1.f};
57 float camAmbientR = 0.15f, camAmbientG = 0.15f, camAmbientB = 0.18f;
58};
59
61inline void sortDrawItems2D(std::vector<DrawItem2D> &items) {
63 std::stable_sort(items.begin(), items.end(), [](const DrawItem2D &a, const DrawItem2D &b) {
64 const bool aOff = a.canvas != nullptr;
65 const bool bOff = b.canvas != nullptr;
66 if (aOff != bOff) return aOff && !bOff;
67 if (a.canvas != b.canvas) return a.canvas < b.canvas;
68 if (a.layer != b.layer) return a.layer < b.layer;
69 if (a.hasOrder && b.hasOrder && a.order != b.order) return a.order < b.order;
70 if (a.depthY != b.depthY) return a.depthY < b.depthY;
71 // Do not use pipeline/texture state as a tie-breaker: alpha compositing is
72 // order-dependent. stable_sort preserves submission order for equal visual keys,
73 // while the backend still batches adjacent compatible items.
74 return false;
75 });
76}
77
78} // namespace eve::graphics
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
Declarative 2D camera (viewport center + zoom).
Canvas public API.
Definition Canvas.h:17
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:11
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
void sortDrawItems2D(std::vector< DrawItem2D > &items)
Sort draw items 2 d.
Definition DrawItem2D.h:61
BlendMode
Render-neutral 2D blend mode shared by graphics-facing modules.
Definition RenderTypes.h:11
Shared 2D draw queue item (sprites + tiles).
Definition DrawItem2D.h:18
BlendMode blend
2D quad blending (alpha / additive / opaque).
Definition DrawItem2D.h:36
bool rotatedUV
Atlas-packed rotated region: corner UVs are remapped (rotated 90°).
Definition DrawItem2D.h:51
bool sceneColorDistortion
Sample and perturb the resolved 3D scene instead of drawing the texture color.
Definition DrawItem2D.h:46
float camX
Screen-space camera already resolved; if cameraEntity set, RenderSystem resolves.
Definition DrawItem2D.h:54
float distortionStrength
Maximum displacement in screen pixels for sceneColorDistortion.
Definition DrawItem2D.h:48
float anchorX
Normalized transform pivot; (0,0) top-left, (0.5,0.5) center.
Definition DrawItem2D.h:27
float rotation
Degrees, clockwise, around the rectangle center (screen Y-down).
Definition DrawItem2D.h:25