Skip to content
Snippets Groups Projects
Verified Commit 22d9496c authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Added drawing gui only without clearing

parent 6ac2fc2b
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
wobble_bobble
...@@ -15,7 +15,7 @@ add_executable(wobble_bobble ...@@ -15,7 +15,7 @@ add_executable(wobble_bobble
fix_project(wobble_bobble) fix_project(wobble_bobble)
# including headers of dependencies and the VkCV framework # including headers of dependencies and the VkCV framework
target_include_directories(wobble_bobble SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_camera_include} ${vkcv_shader_compiler_include}) target_include_directories(wobble_bobble SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_camera_include} ${vkcv_gui_include} ${vkcv_shader_compiler_include})
# linking with libraries from all dependencies and the VkCV framework # linking with libraries from all dependencies and the VkCV framework
target_link_libraries(wobble_bobble vkcv vkcv_camera vkcv_shader_compiler) target_link_libraries(wobble_bobble vkcv vkcv_camera vkcv_gui vkcv_shader_compiler)
#include <vkcv/Core.hpp>
#include <vkcv/camera/CameraManager.hpp>
#include <vkcv/gui/GUI.hpp>
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
const char* applicationName = "Wobble Bobble";
uint32_t windowWidth = 800;
uint32_t windowHeight = 600;
vkcv::Core core = vkcv::Core::create(
applicationName,
VK_MAKE_VERSION(0, 0, 1),
{vk::QueueFlagBits::eTransfer, vk::QueueFlagBits::eGraphics, vk::QueueFlagBits::eCompute},
{ VK_KHR_SWAPCHAIN_EXTENSION_NAME }
);
vkcv::WindowHandle windowHandle = core.createWindow(applicationName, windowWidth, windowHeight, true);
vkcv::Window& window = core.getWindow(windowHandle);
vkcv::camera::CameraManager cameraManager(window);
vkcv::gui::GUI gui (core, windowHandle);
cameraManager.addCamera(vkcv::camera::ControllerType::PILOT);
cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL);
auto swapchainExtent = core.getSwapchain(windowHandle).getExtent();
vkcv::ImageHandle depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
swapchainExtent.width,
swapchainExtent.height
).getHandle();
auto start = std::chrono::system_clock::now();
while (vkcv::Window::hasOpenWindow()) {
vkcv::Window::pollEvents();
if(window.getHeight() == 0 || window.getWidth() == 0)
continue;
uint32_t swapchainWidth, swapchainHeight;
if (!core.beginFrame(swapchainWidth, swapchainHeight,windowHandle)) {
continue;
}
if ((swapchainWidth != swapchainExtent.width) || ((swapchainHeight != swapchainExtent.height))) {
depthBuffer = core.createImage(
vk::Format::eD32Sfloat,
swapchainWidth,
swapchainHeight
).getHandle();
swapchainExtent.width = swapchainWidth;
swapchainExtent.height = swapchainHeight;
}
auto end = std::chrono::system_clock::now();
auto deltatime = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
start = end;
cameraManager.update(0.000001 * static_cast<double>(deltatime.count()));
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
core.prepareSwapchainImageForPresent(cmdStream);
core.submitCommandStream(cmdStream);
gui.beginGUI();
ImGui::Begin("Settings");
ImGui::End();
gui.endGUI();
core.endFrame(windowHandle);
}
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment