Skip to content

Commit 984174d

Browse files
committed
fix(ApiVk): fixed vertex shader
1 parent 92e7900 commit 984174d

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Content/GLSL/Unlit/RGBVertex.vert

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ layout(location = 0) out vec3 vertColor;
1313

1414
void main()
1515
{
16-
gl_Position = PROJ * VIEW * MODEL * vec4(position, 1.0);
16+
gl_Position = vec4(position, 1.0) * MODEL * VIEW * PROJ;
1717

1818
float normalisedIndex = mod(float(gl_VertexIndex), 3.0f);
1919
float r = step(normalisedIndex, 0.0f);

src/examples/demo/DemoApp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class DemoApp : public system::BaseApp
9898
{
9999
m_Camera.Transform().Rotate(rotationYaw);
100100
}
101-
lepus::types::Quaternion rotationPitch = lepus::types::Quaternion(m_Camera.Transform().Right(), deltaY);
101+
lepus::types::Quaternion rotationPitch = lepus::types::Quaternion(m_Camera.Transform().Right(), -deltaY);
102102
angle = rotationPitch.Angle();
103103
if (abs(angle) > 0.001f)
104104
{
@@ -117,7 +117,7 @@ class DemoApp : public system::BaseApp
117117

118118
inline int Run() override
119119
{
120-
const uint32_t width = 800, height = 600;
120+
const uint32_t width = 1280, height = 720;
121121
std::shared_ptr<system::WindowingGLFW> windowing = std::make_shared<system::WindowingGLFW>(width, height, false);
122122

123123
gfx::GraphicsApiVkOptions options = {};

src/lepus/gfx/GraphicsEngine/Apis/ApiVk/ApiVk.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ void GraphicsApiVk::Init(GraphicsApiOptions* options)
313313
vmaCreateBuffer(m_vmaAllocator, &vertBufferCreateInfo, &allocCreateInfo, &m_vkVertBuffer, &m_vmaAllocation, VK_NULL_HANDLE);
314314
m_vkMemory = m_vmaAllocation->GetMemory();
315315
float verts[3 * 3] = {
316-
-0.75f, 0.75f, 0.5f,
317-
0.75f, 0.75f, 0.5f,
318-
0.f, -0.75f, 0.5f};
316+
-0.75f, 0.75f, .5f,
317+
0.75f, 0.75f, .5f,
318+
0.f, -0.75f, .5f};
319319
void* data;
320320
vkMapMemory(m_vkDevice, m_vkMemory, 0, sizeof(float) * 3 * 3, 0, &data);
321321
memcpy(data, verts, sizeof(float) * 3 * 3);
@@ -408,11 +408,12 @@ void GraphicsApiVk::ClearFrameBuffer(float r, float g, float b)
408408

409409
void GraphicsApiVk::UpdateUniforms(const SceneGraph& scene)
410410
{
411-
lepus::math::Matrix4x4 proj = lepus::math::Matrix4x4::Identity(), view = lepus::math::Matrix4x4::Identity(), model = lepus::math::Matrix4x4::Identity();
411+
lepus::math::Matrix4x4 model = lepus::math::Matrix4x4::Identity();
412+
auto camera = scene.Camera();
412413

413414
vkCmdBindPipeline(m_CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_vkGraphicsPipeline);
414-
vkCmdPushConstants(m_CommandBuffer, m_vkGraphicsPipelineLayout, VK_SHADER_STAGE_ALL, 0, sizeof(float) * 4 * 4, proj.data());
415-
vkCmdPushConstants(m_CommandBuffer, m_vkGraphicsPipelineLayout, VK_SHADER_STAGE_ALL, sizeof(float) * 4 * 4, sizeof(float) * 4 * 4, view.data());
415+
vkCmdPushConstants(m_CommandBuffer, m_vkGraphicsPipelineLayout, VK_SHADER_STAGE_ALL, 0, sizeof(float) * 4 * 4, camera->BuildPerspectiveMatrix().data());
416+
vkCmdPushConstants(m_CommandBuffer, m_vkGraphicsPipelineLayout, VK_SHADER_STAGE_ALL, sizeof(float) * 4 * 4, sizeof(float) * 4 * 4, camera->BuildViewMatrix().data());
416417
vkCmdPushConstants(m_CommandBuffer, m_vkGraphicsPipelineLayout, VK_SHADER_STAGE_ALL, 2 * (sizeof(float) * 4 * 4), sizeof(float) * 4 * 4, model.data());
417418
size_t offsets = 0;
418419
vkCmdBindVertexBuffers(m_CommandBuffer, 0, 1, &m_vkVertBuffer, &offsets);

0 commit comments

Comments
 (0)