MCPcopy Create free account
hub / github.com/DavidColson/Polybox / DrawSpriteRect

Function DrawSpriteRect

source/graphics.cpp:958–985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

956// ***********************************************************************
957
958void DrawSpriteRect(sg_image image, Vec4f rect, Vec2f position) {
959 f32 w = (f32)(rect.z - rect.x);
960 f32 h = (f32)(rect.w - rect.y);
961
962 Translate(Vec3f::Embed2D(position));
963
964 BindTexture(image);
965 BeginObject2D(EPrimitiveType::Triangles);
966 TexCoord(Vec2f(rect.x, rect.w));
967 Vertex(Vec2f(0.0f, 0.0f));
968
969 TexCoord(Vec2f(rect.z, rect.w));
970 Vertex(Vec2f(w, 0.0f));
971
972 TexCoord(Vec2f(rect.z, rect.y));
973 Vertex(Vec2f(w, h));
974
975 TexCoord(Vec2f(rect.z, rect.y));
976 Vertex(Vec2f(w, h));
977
978 TexCoord(Vec2f(rect.x, rect.w));
979 Vertex(Vec2f(0.0f, 0.0f));
980
981 TexCoord(Vec2f(rect.x, rect.y));
982 Vertex(Vec2f(0.f, h));
983 EndObject2D();
984 UnbindTexture();
985}
986

Callers 2

LuaDrawSpriteRectFunction · 0.85
DrawSpriteFunction · 0.85

Calls 7

TranslateFunction · 0.85
BindTextureFunction · 0.85
BeginObject2DFunction · 0.85
TexCoordFunction · 0.85
VertexFunction · 0.85
EndObject2DFunction · 0.85
UnbindTextureFunction · 0.85

Tested by

no test coverage detected