Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarCinematic.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-30 04:34:10 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-30 04:34:10 +1000
commitd5fbd2001b0ad3591a7f969dfd75c809ab55b40e (patch)
treeb6b9361bfa854daf3e6be45d572407508340d12d /source/frontend/StarCinematic.cpp
parent47a527ebbff91cf530cb8758828679ef0e3334f2 (diff)
RenderPrimitive micro-optimizations
Diffstat (limited to 'source/frontend/StarCinematic.cpp')
-rw-r--r--source/frontend/StarCinematic.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/frontend/StarCinematic.cpp b/source/frontend/StarCinematic.cpp
index 7408264..7470410 100644
--- a/source/frontend/StarCinematic.cpp
+++ b/source/frontend/StarCinematic.cpp
@@ -245,15 +245,17 @@ void Cinematic::render() {
void Cinematic::drawDrawable(Drawable const& drawable, float drawableScale, Vec2F const& drawableTranslation) {
auto& guiContext = GuiContext::singleton();
- auto renderer = guiContext.renderer();
- auto textureGroup = guiContext.assetTextureGroup();
+ auto& renderer = guiContext.renderer();
+ auto& textureGroup = guiContext.assetTextureGroup();
+
+ auto& primitives = renderer->immediatePrimitives();
if (drawable.isImage()) {
auto const& imagePart = drawable.imagePart();
auto texture = textureGroup->loadTexture(imagePart.image);
- auto textureSize = Vec2F(texture->size());
+ auto size = Vec2F(texture->size());
- RectF imageRect(Vec2F(), textureSize);
+ RectF imageRect(Vec2F(), size);
Vec2F screenTranslation = drawable.position * drawableScale + drawableTranslation;
@@ -272,11 +274,12 @@ void Cinematic::drawDrawable(Drawable const& drawable, float drawableScale, Vec2
Vec4B drawableColor = drawable.color.toRgba();
- renderer->render(RenderQuad{move(texture),
- RenderVertex{lowerLeft, Vec2F(0, 0), drawableColor, 0.0f},
- RenderVertex{lowerRight, Vec2F(textureSize[0], 0), drawableColor, 0.0f},
- RenderVertex{upperRight, Vec2F(textureSize[0], textureSize[1]), drawableColor, 0.0f},
- RenderVertex{upperLeft, Vec2F(0, textureSize[1]), drawableColor, 0.0f}});
+ primitives.emplace_back(std::in_place_type_t<RenderQuad>(), move(texture),
+ lowerLeft, Vec2F{0, 0},
+ lowerRight, Vec2F{size[0], 0},
+ upperRight, Vec2F{size[0], size[1]},
+ upperLeft, Vec2F{0, size[1]},
+ drawableColor, 0.0f);
} else {
starAssert(drawable.part.empty());
}