diff --git a/Hazel/src/Hazel/Renderer/Renderer2D.cpp b/Hazel/src/Hazel/Renderer/Renderer2D.cpp index 3de9362af..e1f63dbf4 100644 --- a/Hazel/src/Hazel/Renderer/Renderer2D.cpp +++ b/Hazel/src/Hazel/Renderer/Renderer2D.cpp @@ -213,11 +213,6 @@ namespace Hazel { s_Data.Stats.QuadCount++; } - void Renderer2D::DrawRotatedQuad(const glm::vec2& position, const glm::vec2& size, float rotation, const glm::vec4& color) - { - DrawRotatedQuad({ position.x, position.y, 0.0f }, size, rotation, color); - } - void Renderer2D::DrawQuad(const glm::mat4& transform, const Ref& texture, float tilingFactor, const glm::vec4& tintColor) { HZ_PROFILE_FUNCTION(); @@ -263,35 +258,20 @@ namespace Hazel { s_Data.Stats.QuadCount++; } + void Renderer2D::DrawRotatedQuad(const glm::vec2& position, const glm::vec2& size, float rotation, const glm::vec4& color) + { + DrawRotatedQuad({ position.x, position.y, 0.0f }, size, rotation, color); + } + void Renderer2D::DrawRotatedQuad(const glm::vec3& position, const glm::vec2& size, float rotation, const glm::vec4& color) { HZ_PROFILE_FUNCTION(); - constexpr size_t quadVertexCount = 4; - const float textureIndex = 0.0f; // White Texture - constexpr glm::vec2 textureCoords[] = { { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f } }; - const float tilingFactor = 1.0f; - - if (s_Data.QuadIndexCount >= Renderer2DData::MaxIndices) - FlushAndReset(); - glm::mat4 transform = glm::translate(glm::mat4(1.0f), position) * glm::rotate(glm::mat4(1.0f), glm::radians(rotation), { 0.0f, 0.0f, 1.0f }) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }); - for (size_t i = 0; i < quadVertexCount; i++) - { - s_Data.QuadVertexBufferPtr->Position = transform * s_Data.QuadVertexPositions[i]; - s_Data.QuadVertexBufferPtr->Color = color; - s_Data.QuadVertexBufferPtr->TexCoord = textureCoords[i]; - s_Data.QuadVertexBufferPtr->TexIndex = textureIndex; - s_Data.QuadVertexBufferPtr->TilingFactor = tilingFactor; - s_Data.QuadVertexBufferPtr++; - } - - s_Data.QuadIndexCount += 6; - - s_Data.Stats.QuadCount++; + DrawQuad(transform, color); } void Renderer2D::DrawRotatedQuad(const glm::vec2& position, const glm::vec2& size, float rotation, const Ref& texture, float tilingFactor, const glm::vec4& tintColor) @@ -303,49 +283,11 @@ namespace Hazel { { HZ_PROFILE_FUNCTION(); - constexpr size_t quadVertexCount = 4; - constexpr glm::vec2 textureCoords[] = { { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f } }; - - if (s_Data.QuadIndexCount >= Renderer2DData::MaxIndices) - FlushAndReset(); - - float textureIndex = 0.0f; - for (uint32_t i = 1; i < s_Data.TextureSlotIndex; i++) - { - if (*s_Data.TextureSlots[i].get() == *texture.get()) - { - textureIndex = (float)i; - break; - } - } - - if (textureIndex == 0.0f) - { - if (s_Data.TextureSlotIndex >= Renderer2DData::MaxTextureSlots) - FlushAndReset(); - - textureIndex = (float)s_Data.TextureSlotIndex; - s_Data.TextureSlots[s_Data.TextureSlotIndex] = texture; - s_Data.TextureSlotIndex++; - } - glm::mat4 transform = glm::translate(glm::mat4(1.0f), position) * glm::rotate(glm::mat4(1.0f), glm::radians(rotation), { 0.0f, 0.0f, 1.0f }) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }); - for (size_t i = 0; i < quadVertexCount; i++) - { - s_Data.QuadVertexBufferPtr->Position = transform * s_Data.QuadVertexPositions[i]; - s_Data.QuadVertexBufferPtr->Color = tintColor; - s_Data.QuadVertexBufferPtr->TexCoord = textureCoords[i]; - s_Data.QuadVertexBufferPtr->TexIndex = textureIndex; - s_Data.QuadVertexBufferPtr->TilingFactor = tilingFactor; - s_Data.QuadVertexBufferPtr++; - } - - s_Data.QuadIndexCount += 6; - - s_Data.Stats.QuadCount++; + DrawQuad(transform, texture, tilingFactor, tintColor); } void Renderer2D::ResetStats() diff --git a/premake5.lua b/premake5.lua index 0f358f1df..81377a1d3 100644 --- a/premake5.lua +++ b/premake5.lua @@ -123,7 +123,8 @@ project "Sandbox" "Hazel/vendor/spdlog/include", "Hazel/src", "Hazel/vendor", - "%{IncludeDir.glm}" + "%{IncludeDir.glm}", + "%{IncludeDir.entt}" } links