Add basic functionality to draw instances
Allows creation of instances of meshes and drawing all of them with single draw call. Instances can have their own transformation data (location, rotation and scale).
This commit is contained in:
1 parent
6a09350902
commit
c4734e99c2
8 files changed
+343
-37
No files matched your search
@@ -2,6 +2,8 @@
|
||||
#include "window.hpp"
|
||||
#include "vulkan_base.hpp"
|
||||
|
||||
#include "mesh_controller.hpp"
|
||||
#include "vulkan_commons.hpp"
|
||||
namespace rse::graphics
|
||||
{
|
||||
|
||||
@@ -26,11 +28,34 @@ RseGraphics::RseGraphics()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
uint8_t RseGraphics::graphics_run(void)
|
||||
{
|
||||
|
||||
window::windowInit();
|
||||
|
||||
// FIXME: Temporary array of vertices, for testing purposes
|
||||
const std::vector<rse::graphics::vulkanbase::Vertex> vertices = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 1.0f}},
|
||||
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 1.0f}},
|
||||
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}},
|
||||
{{-0.5f, 0.5f, 0.0f}, {1.0f, 0.0f, 1.0f}}};
|
||||
|
||||
// FIXME: Temporary array of vertices, for testing purposes
|
||||
std::vector<uint16_t> indices = {0, 1, 2, 2, 3, 0};
|
||||
|
||||
uint16_t mesh_id = rse::graphics::mesh::create_mesh(vertices, indices);
|
||||
rse::graphics::mesh::create_mesh_instance(mesh_id, rse::graphics::mesh::InstanceData(
|
||||
glm::vec3(0.0f, 0.0f, 0.0f),
|
||||
glm::vec3(0.0f, 0.0f, glm::radians(45.0f)),
|
||||
1.0f
|
||||
));
|
||||
|
||||
rse::graphics::mesh::create_mesh_instance(mesh_id, rse::graphics::mesh::InstanceData(
|
||||
glm::vec3(-1.0f, 0.0f, 0.0f),
|
||||
glm::vec3(0.0f, 0.0f, 0.0f),
|
||||
1.0f
|
||||
));
|
||||
|
||||
if (0 != vulkanbase::initVulkan(vulkan_state))
|
||||
return -1;
|
||||
|
||||
|
||||
Reference in new issue
Block a user