41 auto& registry = collect_ctx.
registry;
42 auto& frustum = collect_ctx.
frustum;
51 for (
auto entity : shapeView) {
53 if (!shape.enabled)
continue;
54 const f32 groupAlpha = groupOpacity.of(entity);
55 if (groupAlpha <= 0.0f)
continue;
59 const auto& rotation = transform.worldRotation;
60 const auto& scale = transform.worldScale;
65 glm::vec3(shape.size.x * scale.x, shape.size.y * scale.y, 0.0f) * 0.5f);
66 if (!frustum.intersectsAABB(position, halfExtents)) {
71 f32 angle = 2.0f * std::atan2(rotation.z, rotation.w);
72 f32 cosA = std::cos(angle);
73 f32 sinA = std::sin(angle);
75 glm::vec2 scale2 = glm::vec2(scale);
76 glm::vec2 halfSize = shape.size * scale2 * 0.5f;
77 glm::vec2 pos(position);
81 f32 cornerScale = 0.5f * (std::abs(scale2.x) + std::abs(scale2.y));
83 glm::vec2 localCorners[4] = {
84 {-halfSize.x, -halfSize.y},
85 { halfSize.x, -halfSize.y},
86 { halfSize.x, halfSize.y},
87 {-halfSize.x, halfSize.y},
90 glm::vec2 uvCorners[4] = {
98 for (
u32 v = 0; v < 4; ++v) {
99 f32 rx = localCorners[v].x * cosA - localCorners[v].y * sinA;
100 f32 ry = localCorners[v].x * sinA + localCorners[v].y * cosA;
102 verts[v].px = pos.x + rx;
103 verts[v].py = pos.y + ry;
104 verts[v].ux = uvCorners[v].x;
105 verts[v].uy = uvCorners[v].y;
106 verts[v].cr = shape.color.r;
107 verts[v].cg = shape.color.g;
108 verts[v].cb = shape.color.b;
109 verts[v].ca = shape.color.a * groupAlpha;
110 verts[v].shapeType =
static_cast<f32>(shape.shapeType);
111 verts[v].halfW = halfSize.x;
112 verts[v].halfH = halfSize.y;
113 verts[v].cornerRadius = shape.cornerRadius * cornerScale;
117 .stage =
ctx.current_stage,
118 .layer = shape.layer,
119 .shaderId = shape_shader_id_,
Rendering context containing all renderer state.
static std::string assembleStage(const ParsedShader &parsed, ShaderStage stage, const std::string &platform="", const std::vector< std::string > &features={}, ShaderTargetLanguage target=ShaderTargetLanguage::GLSL_ES300)
Assembles final GLSL source for a specific stage.
void appendIndexedDraw(TransientBufferPool &pool, DrawList &drawList, const ClipState &clips, const void *verts, u32 vertexCount, const u32 *localIndices, u32 indexCount, const BatchDrawKey &key)
Copies raw vertices into the key's stream, then pushes one DrawCommand spanning them.
const ClipState & clip_state
u32 culled
How many renderables this collect's frustum rejected.
RenderFrameContext & frame_context
TransientBufferPool & buffer_pool