61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
#include <Orange/Core/Result.h>
|
|
|
|
#include <Orange/Render/Window.h>
|
|
#include <Orange/Render/RenderContext.h>
|
|
#include <Orange/Render/Swapchain.h>
|
|
#include <vulkan/vulkan_core.h>
|
|
|
|
using namespace orange;
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
(void)argc; (void)argv;
|
|
|
|
auto r_window = Window::Create();
|
|
if (!r_window)
|
|
return 1;
|
|
|
|
auto r_renderContext = RenderContext::Create("Cube Test");
|
|
if (!r_renderContext)
|
|
return 1;
|
|
|
|
auto r_surface = r_window->CreateSurface(r_renderContext->Instance());
|
|
if (!r_surface)
|
|
return 1;
|
|
|
|
auto r_swapchain = Swapchain::Create(*r_renderContext, *r_surface);
|
|
if (!r_swapchain)
|
|
return 1;
|
|
|
|
while (r_window->Update())
|
|
{
|
|
r_renderContext->BeginCommandBuffer(r_swapchain->CommandBuffer());
|
|
{
|
|
const VkRenderingAttachmentInfoKHR attachmentInfo =
|
|
{
|
|
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR,
|
|
.imageView = r_swapchain->ImageView(),
|
|
.imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR,
|
|
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
|
.clearValue = { .color = { .float32 = { 1.0f, 0.5f, 0.0f, 1.0f } } },
|
|
};
|
|
|
|
const VkRenderingInfo renderInfo =
|
|
{
|
|
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
|
.renderArea = { {}, r_swapchain->Extent() },
|
|
.layerCount = 1,
|
|
.colorAttachmentCount = 1,
|
|
.pColorAttachments = &attachmentInfo,
|
|
};
|
|
vkCmdBeginRendering(r_swapchain->CommandBuffer(), &renderInfo);
|
|
vkCmdEndRendering(r_swapchain->CommandBuffer());
|
|
}
|
|
r_renderContext->EndCommandBuffer(r_swapchain->CommandBuffer());
|
|
r_swapchain->Present();
|
|
}
|
|
|
|
return 0;
|
|
}
|