static public void DrawQuad(vec2 position, vec2 size, SubTexture SubTexture) { if (IndexCount >= MaxIndexCount || TextureSlotIndex > MaxTextures - 1) { EndBatch(); Flush(); BeginBatch(); } float textureIndex = 0.0f; for (UInt32 i = 1; i < TextureSlotIndex; i++) { if (TextureSlots[i] == SubTexture.textureId) { textureIndex = (float)i; break; } } if (textureIndex == 0.0f) { textureIndex = (float)TextureSlotIndex; TextureSlots[TextureSlotIndex] = SubTexture.textureId; TextureSlotIndex++; } FillVertices(position, size, new vec4(1.0f, 1.0f, 1.0f, 1.0f), SubTexture.texCoord, textureIndex); IndexCount += 6; }
static public void DrawQuad(vec2 position, vec2 size, float rotation, SubTexture SubTexture, vec3?axis = null) { if (IndexCount >= MaxIndexCount || TextureSlotIndex > MaxTextures - 1) { EndBatch(); Flush(); BeginBatch(); } float textureIndex = 0.0f; for (UInt32 i = 1; i < TextureSlotIndex; i++) { if (TextureSlots[i] == SubTexture.textureId) { textureIndex = (float)i; break; } } if (textureIndex == 0.0f) { textureIndex = (float)TextureSlotIndex; TextureSlots[TextureSlotIndex] = SubTexture.textureId; TextureSlotIndex++; } vec3[] rectangleVertices = { new vec3(position.x, position.y, 0.0f), new vec3(position.x + size.x, position.y, 0.0f), new vec3(position.x + size.x, position.y + size.y, 0.0f), new vec3(position.x, position.y + size.y, 0.0f) }; vec3 axiss; if (axis != null) { axiss = (vec3)axis; } else { axiss = new vec3(0.0f, 0.0f, 1.0f); } RotateVertices(ref rectangleVertices, rotation, new vec3(position.x + (size.x / 2), position.y + (size.y / 2), 0.0f), axiss); FillVertices(rectangleVertices, new vec4(1.0f, 1.0f, 1.0f, 1.0f), SubTexture.texCoord, textureIndex); IndexCount += 6; }