编写完顶点渲染程序,先保存一下
This commit is contained in:
+12
-9
@@ -178,8 +178,6 @@ void Application::createLogicalDevice() {
|
||||
throw std::runtime_error("failed to create logical device!");
|
||||
}
|
||||
|
||||
v_device = std::make_unique<vkb::core::DeviceC>(v_gpu, device, surface);
|
||||
|
||||
vkGetDeviceQueue(device, indices.graphicsFamily.value(), 0, &graphicsQueue);
|
||||
vkGetDeviceQueue(device, indices.presentFamily.value(), 0, &presentQueue);
|
||||
}
|
||||
@@ -480,11 +478,7 @@ void Application::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t im
|
||||
|
||||
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
// 绑定图形管线
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
|
||||
|
||||
// 绘制三角形
|
||||
vkCmdDraw(commandBuffer, 3, 1, 0, 0);
|
||||
render(commandBuffer);
|
||||
|
||||
// 结束渲染流程
|
||||
vkCmdEndRenderPass(commandBuffer);
|
||||
@@ -494,6 +488,15 @@ void Application::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t im
|
||||
}
|
||||
}
|
||||
|
||||
void Application::render(VkCommandBuffer commandBuffer)
|
||||
{
|
||||
// 绑定图形管线
|
||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
|
||||
|
||||
// 绘制三角形
|
||||
vkCmdDraw(commandBuffer, 3, 1, 0, 0);
|
||||
}
|
||||
|
||||
void Application::drawFrame()
|
||||
{
|
||||
// 1. 等待前一帧完成
|
||||
@@ -651,10 +654,10 @@ uint32_t Application::findMemoryType(VkPhysicalDevice physicalDevice, uint32_t t
|
||||
|
||||
Texture Application::loadTexture(std::string path)
|
||||
{
|
||||
const char* filename = getPath(path).c_str();
|
||||
std::vector<char> data = readFile(path);
|
||||
std::vector<unsigned char> image;
|
||||
unsigned w, h;
|
||||
unsigned error = lodepng::decode(image, w, h, filename, LCT_RGBA, 8);
|
||||
unsigned error = lodepng::decode(image, w, h, data.data(), LCT_RGBA, 8);
|
||||
Texture tex;
|
||||
processWithVulkan(image.data(), w, h, w * 4, image.size(), tex, true);
|
||||
return tex;
|
||||
|
||||
Reference in New Issue
Block a user