MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / drawDrawable

Method drawDrawable

source/frontend/StarCinematic.cpp:247–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247void Cinematic::drawDrawable(Drawable const& drawable, float drawableScale, Vec2F const& drawableTranslation) {
248 auto& guiContext = GuiContext::singleton();
249 auto& renderer = guiContext.renderer();
250 auto& textureGroup = guiContext.assetTextureGroup();
251
252 auto& primitives = renderer->immediatePrimitives();
253
254 if (drawable.isImage()) {
255 auto const& imagePart = drawable.imagePart();
256 auto texture = textureGroup->loadTexture(imagePart.image);
257 auto size = Vec2F(texture->size());
258
259 RectF imageRect(Vec2F(), size);
260
261 Vec2F screenTranslation = drawable.position * drawableScale + drawableTranslation;
262
263 Vec2F lowerLeft =
264 imagePart.transformation.transformVec2(Vec2F(imageRect.xMin(), imageRect.yMin())) * drawableScale
265 + screenTranslation;
266 Vec2F lowerRight =
267 imagePart.transformation.transformVec2(Vec2F(imageRect.xMax(), imageRect.yMin())) * drawableScale
268 + screenTranslation;
269 Vec2F upperRight =
270 imagePart.transformation.transformVec2(Vec2F(imageRect.xMax(), imageRect.yMax())) * drawableScale
271 + screenTranslation;
272 Vec2F upperLeft =
273 imagePart.transformation.transformVec2(Vec2F(imageRect.xMin(), imageRect.yMax())) * drawableScale
274 + screenTranslation;
275
276 Vec4B drawableColor = drawable.color.toRgba();
277
278 primitives.emplace_back(std::in_place_type_t<RenderQuad>(), std::move(texture),
279 lowerLeft, Vec2F{0, 0},
280 lowerRight, Vec2F{size[0], 0},
281 upperRight, Vec2F{size[0], size[1]},
282 upperLeft, Vec2F{0, size[1]},
283 drawableColor, 0.0f);
284 } else {
285 starAssert(drawable.part.empty());
286 }
287}
288
289void Cinematic::updateCamera(float timecode) {
290 float startZoom = 1.0f;

Callers 6

updateMethod · 0.45
renderMethod · 0.45
renderCursorMethod · 0.45
renderCursorMethod · 0.45
renderCursorMethod · 0.45

Calls 12

singletonClass · 0.85
isImageMethod · 0.80
loadTextureMethod · 0.80
transformVec2Method · 0.80
xMinMethod · 0.80
yMinMethod · 0.80
xMaxMethod · 0.80
yMaxMethod · 0.80
toRgbaMethod · 0.80
sizeMethod · 0.45
emplace_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected