Skip to content

Commit

Permalink
fix issues in editor mode
Browse files Browse the repository at this point in the history
  • Loading branch information
goopey7 committed Dec 27, 2023
1 parent 08f9312 commit ba45e7f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ file(GLOB STB_IMAGE_HEADER "libs/stb/stb_image.h")
add_executable(${PROJECT_NAME} ${ENGINE_SRC_FILES} ${STB_VORBIS_SOURCE})

#define app type
#target_compile_definitions(${PROJECT_NAME} PRIVATE GOOP_APPTYPE_EDITOR=1)
target_compile_definitions(${PROJECT_NAME} PRIVATE GOOP_APPTYPE_EDITOR=1)

# define systems
target_compile_definitions(${PROJECT_NAME} PRIVATE GOOP_RENDERER_VULKAN)
Expand Down
7 changes: 4 additions & 3 deletions game/GameApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ void GameApp::init()

void GameApp::update(float dt)
{
//glm::mat4& transform =
// scene->getEntity("Viking Room").getComponent<goop::TransformComponent>().transform;
timeElapsed += dt;
glm::mat4& transform =
scene->getEntity("Viking Room").getComponent<goop::TransformComponent>().transform;

//transform = glm::rotate(transform, dt, glm::vec3(0.0f, 1.0f, 0.0f));
transform = glm::rotate(glm::mat4(1.f), timeElapsed, glm::vec3(0.0f, 1.0f, 0.0f));
}
1 change: 1 addition & 0 deletions game/GameApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ class GameApp : public goop::App
private:
bool shouldSpawnHouse = true;
bool shouldSpawnCow = true;
float timeElapsed = 0.f;
};
13 changes: 10 additions & 3 deletions goop/sys/platform/vulkan/Renderer_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ bool Renderer_Vulkan::renderScene(uint32_t width, uint32_t height, uint32_t imag
{
VkDeviceSize offset = 0;
vkCmdBindVertexBuffers(cb, 0, 1, buffers->getVertexBuffer(currentFrame), &offset);
vkCmdBindVertexBuffers(cb, 1, 1, buffers->getInstanceBuffer(currentFrame), &offset);
vkCmdBindIndexBuffer(cb, buffers->getIndexBuffer(currentFrame), 0, VK_INDEX_TYPE_UINT32);
}

Expand All @@ -456,10 +457,16 @@ bool Renderer_Vulkan::renderScene(uint32_t width, uint32_t height, uint32_t imag
if (buffers->getIndexCount(currentFrame, 0) != 0 &&
buffers->getIndexBuffer(currentFrame) != nullptr)
{
for (size_t i = 0; i < buffers->getIndexCountSize(currentFrame); i++)
// for each different instance, render all instances of that mesh
size_t uniqueInstances = buffers->getNumUniqueInstances(currentFrame);
for (size_t i = 0; i < buffers->getNumUniqueInstances(currentFrame); i++)
{
vkCmdDrawIndexed(cb, buffers->getIndexCount(currentFrame, i), 1,
buffers->getIndexOffset(currentFrame, i), 0, 0);
int instanceCount = buffers->getInstanceCount(currentFrame, i);
int instanceOffset = buffers->getInstanceOffsets(currentFrame, i);
int indexCount = buffers->getIndexCount(currentFrame, i);
int indexOffset = buffers->getIndexOffset(currentFrame, i);
vkCmdDrawIndexed(cb, indexCount, instanceCount, indexOffset, 0,
instanceOffset);
}
}

Expand Down

0 comments on commit ba45e7f

Please sign in to comment.