87 lines
2.7 KiB
C++
87 lines
2.7 KiB
C++
#include "rse_graphics.hpp"
|
|
#include "window.hpp"
|
|
#include "vulkan_base.hpp"
|
|
|
|
#include "mesh_controller.hpp"
|
|
#include "vulkan_commons.hpp"
|
|
namespace rse::graphics
|
|
{
|
|
|
|
RseGraphics::RseGraphics()
|
|
{
|
|
vulkan_state = {
|
|
.graphicsQueue = VK_NULL_HANDLE,
|
|
.physicalDevice = VK_NULL_HANDLE,
|
|
.currentFrame = 0U,
|
|
.queueFamilyIndices = {0U}, /* TODO: Change when more families are needed */
|
|
.uniformBuffers = {},
|
|
.pCommandBuffers = {},
|
|
.descriptorSets = {},
|
|
.swapChainImageViews = {},
|
|
.swapchainExtent = {},
|
|
.renderPass = VK_NULL_HANDLE,
|
|
.descriptorSetLayout = VK_NULL_HANDLE,
|
|
.swapchainFramebuffers = {},
|
|
.graphicsPipeline = VK_NULL_HANDLE,
|
|
.pipelineLayout = VK_NULL_HANDLE,
|
|
.swapchain = VK_NULL_HANDLE,
|
|
};
|
|
}
|
|
|
|
|
|
uint8_t RseGraphics::graphics_run(void)
|
|
{
|
|
|
|
window::windowInit();
|
|
|
|
|
|
|
|
if (0 != vulkanbase::initVulkan())
|
|
return -1;
|
|
|
|
// 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}}};
|
|
const std::vector<rse::graphics::vulkanbase::Vertex> vertices2 = {{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 1.0f}},
|
|
|
|
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}},
|
|
{{0.5f, 0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}},
|
|
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 0.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
|
|
));
|
|
|
|
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, 1.0f, 0.0f),
|
|
glm::vec3(0.0f, 0.0f, glm::radians(0.0f)),
|
|
1.0f
|
|
));
|
|
|
|
window::windowLoop();
|
|
|
|
vulkanbase::deinitVulkan();
|
|
|
|
window::windowTerminate();
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
} // namespace rse::graphics
|