This commit is contained in:
Isuru Samarathunga
2025-09-13 15:09:51 +05:30
parent 62edc71750
commit 3687a70aba
28 changed files with 120 additions and 108 deletions

View File

@ -25,9 +25,9 @@ namespace ia::iae
VOID QuadMesh::Initialize()
{
Vertex_Mesh vertices[6] = {{iam::Vec3f{-1, 1, 0}, iam::Vec2f{0, 0}}, {iam::Vec3f{1, 1, 0}, iam::Vec2f{1, 0}},
{iam::Vec3f{1, -1, 0}, iam::Vec2f{1, 1}}, {iam::Vec3f{-1, 1, 0}, iam::Vec2f{0, 0}},
{iam::Vec3f{1, -1, 0}, iam::Vec2f{1, 1}}, {iam::Vec3f{-1, -1, 0}, iam::Vec2f{0, 1}}};
Vertex_Mesh vertices[6] = {{glm::vec3{-1, 1, 0}, glm::vec2{0, 0}}, {glm::vec3{1, 1, 0}, glm::vec2{1, 0}},
{glm::vec3{1, -1, 0}, glm::vec2{1, 1}}, {glm::vec3{-1, 1, 0}, glm::vec2{0, 0}},
{glm::vec3{1, -1, 0}, glm::vec2{1, 1}}, {glm::vec3{-1, -1, 0}, glm::vec2{0, 1}}};
g_quadMeshVertexBuffer = GPUBuffer::Create(GPUBuffer::Usage::VERTEX, &vertices, sizeof(vertices));
}
@ -37,8 +37,8 @@ namespace ia::iae
g_quadMeshVertexBuffer.reset();
}
VOID QuadMesh::Draw(IN CONST iam::Vec3f &position, IN CONST iam::Vec3f &scale, IN FLOAT32 rotation)
VOID QuadMesh::Draw(IN CONST glm::vec3 &position, IN CONST glm::vec3 &scale, IN FLOAT32 rotation)
{
Renderer::Draw(g_quadMeshVertexBuffer->GetHandle(), 6);
Renderer::Draw(position, scale, rotation, g_quadMeshVertexBuffer->GetHandle(), 6);
}
} // namespace ia::iae

View File

@ -51,7 +51,7 @@ namespace ia::iae
{.location = 1,
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2,
.offset = sizeof(iam::Vec3f)}};
.offset = sizeof(glm::vec3)}};
SDL_GPUGraphicsPipelineCreateInfo createInfo = {
.vertex_shader = (SDL_GPUShader *) vertexShader,
.fragment_shader = (SDL_GPUShader *) pixelShader,

View File

@ -117,7 +117,7 @@ namespace ia::iae
SDL_DestroyGPUDevice(g_gpuDevice);
}
VOID Renderer::AddDebugUIWindow(IN PCCHAR title, IN CONST iam::Vec2f &position, IN CONST iam::Vec2f &size,
VOID Renderer::AddDebugUIWindow(IN PCCHAR title, IN CONST glm::vec2 &position, IN CONST glm::vec2 &size,
IN std::function<VOID()> contentDrawCallback)
{
s_debugUIWindows.pushBack(DebugUIWindow{title, position, size, contentDrawCallback});
@ -131,8 +131,8 @@ namespace ia::iae
for (const auto &w : s_debugUIWindows)
{
ImGui::Begin(w.Title);
ImGui::SetWindowPos({w.Position.X, w.Position.Y});
ImGui::SetWindowSize({w.Size.X, w.Size.Y});
ImGui::SetWindowPos({w.Position.x, w.Position.y});
ImGui::SetWindowSize({w.Size.x, w.Size.y});
w.ContentDrawCallback();
ImGui::End();
}
@ -179,11 +179,11 @@ namespace ia::iae
SDL_SubmitGPUCommandBuffer(g_cmdBuffer);
}
VOID Renderer::BindTexture(IN Handle handle, IN BOOL flipV, IN BOOL flipH, IN CONST iam::Vec4f &colorOverlay)
VOID Renderer::BindTexture(IN Handle handle, IN BOOL flipV, IN BOOL flipH, IN CONST glm::vec4 &colorOverlay)
{
STATIC struct
{
iam::Vec4f colorOverlay;
glm::vec4 colorOverlay;
UINT32 flipV;
UINT32 flipH;
} textureState;
@ -195,14 +195,14 @@ namespace ia::iae
SDL_PushGPUFragmentUniformData(g_cmdBuffer, 0, &textureState, sizeof(textureState));
}
VOID Renderer::Draw(IN CONST iam::Vec3f &position, IN CONST iam::Vec3f &scale, IN FLOAT32 rotation, IN Handle vertexBufferHandle, IN INT32 vertexCount)
VOID Renderer::Draw(IN CONST glm::vec3 &position, IN CONST glm::vec3 &scale, IN FLOAT32 rotation, IN Handle vertexBufferHandle, IN INT32 vertexCount)
{
SDL_GPUBufferBinding bindings[] = {{.buffer = (SDL_GPUBuffer *) vertexBufferHandle, .offset = 0}};
SDL_BindGPUVertexBuffers(g_renderPass, 0, bindings, 1);
SDL_DrawGPUPrimitives(g_renderPass, vertexCount, 1, 0, 0);
}
VOID Renderer::Draw(IN CONST iam::Vec3f &position, IN CONST iam::Vec3f &scale, IN FLOAT32 rotation, IN Handle vertexBufferHandle, IN Handle indexBufferHandle, IN INT32 indexCount)
VOID Renderer::Draw(IN CONST glm::vec3 &position, IN CONST glm::vec3 &scale, IN FLOAT32 rotation, IN Handle vertexBufferHandle, IN Handle indexBufferHandle, IN INT32 indexCount)
{
SDL_GPUBufferBinding bindings[] = {{.buffer = (SDL_GPUBuffer *) vertexBufferHandle, .offset = 0},
{.buffer = (SDL_GPUBuffer *) indexBufferHandle, .offset = 0}};