Files
Cheap-Vulkan-Renderer/first_app.cpp
2026-02-20 11:40:12 +00:00

49 lines
1.4 KiB
C++

#include "first_app.hpp"
#include <stdexcept>
namespace cve {
FirstApp::FirstApp() {
createPipelineLayout();
createPipeline();
createCommandBuffers();
}
FirstApp::~FirstApp() {
vkDestroyPipelineLayout(cveDevice.device(), pipelineLayout, nullptr);
}
void FirstApp::run() {
while (!cveWindow.shouldClose()) {
glfwPollEvents();
}
}
void FirstApp::createPipelineLayout() {
VkPipelineLayoutCreateInfo pipelineLayoutInfo{};
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = 0;
pipelineLayoutInfo.pSetLayouts = nullptr;
pipelineLayoutInfo.pushConstantRangeCount = 0;
pipelineLayoutInfo.pPushConstantRanges = nullptr;
if (vkCreatePipelineLayout(cveDevice.device(), &pipelineLayoutInfo, nullptr, &pipelineLayout) !=
VK_SUCCESS) {
throw std::runtime_error("Failed to create pipeline layout");
}
}
void FirstApp::createPipeline() {
auto pipelineConfig = CvePipeline::defaultPipelineConfigInfo(cveSwapChain.width(), cveSwapChain.height());
pipelineConfig.renderPass = cveSwapChain.getRenderPass();
pipelineConfig.pipelineLayout = pipelineLayout;
cvePipeline = std::make_unique<CvePipeline>(
cveDevice,
"shaders/simple_shader.vert.spv",
"shaders/simple_shader.frag.spv",
pipelineConfig
);
}
void FirstApp::createCommandBuffers() {};
void FirstApp::drawFrame() {};
}