Skip to content

Commit 9f47c0a

Browse files
committed
Switching to ezvcpkg build
1 parent 2e248db commit 9f47c0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+244
-48717
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ cmake_policy(VERSION 3.6)
33
include("cmake/defaults.cmake")
44
set(NAME VulkanCppExamples)
55

6+
include("cmake/ezvcpkg.cmake")
7+
8+
ezvcpkg_fetch(
9+
PACKAGES assimp basisu imgui glad glfw3 gli glm vulkan
10+
UPDATE_TOOLCHAIN
11+
)
612

713
project(${NAME})
814

base/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ file(GLOB_RECURSE COMMON_SOURCE *.c *.cpp *.h *.hpp)
2525
add_library(${TARGET_NAME} STATIC ${COMMON_SOURCE})
2626
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "common")
2727
add_dependencies(${TARGET_NAME} shaders)
28-
target_link_libraries(${TARGET_NAME} imgui)
2928

29+
target_basisu()
3030
target_glfw3()
3131
target_glm()
3232
target_gli()
@@ -37,5 +37,5 @@ target_glad()
3737

3838
if (ANDROID)
3939
add_dependencies(${TARGET_NAME} app-glue)
40-
target_link_libraries(${TARGET_NAME} app-glue android log m)
40+
target_link_libraries(${TARGET_NAME} PRIVATE app-glue android log m)
4141
endif()

base/gl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ static void debugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum s
9595

9696
void gl::setupDebugLogging() {
9797
glDebugMessageCallback(debugMessageCallback, NULL);
98-
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
98+
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
9999
}
100100
#endif

base/ui.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,11 @@ void UIOverlay::update() {
381381
context.trash<vks::Buffer>(vertexBuffer);
382382
vertexBuffer = vks::Buffer();
383383
}
384-
vertexBuffer = context.createBuffer(vk::BufferUsageFlagBits::eVertexBuffer, vk::MemoryPropertyFlagBits::eHostVisible, vertexBufferSize);
385-
vertexBuffer.map();
386-
updateCmdBuffers = true;
384+
if (vertexCount) {
385+
vertexBuffer = context.createBuffer(vk::BufferUsageFlagBits::eVertexBuffer, vk::MemoryPropertyFlagBits::eHostVisible, vertexBufferSize);
386+
vertexBuffer.map();
387+
updateCmdBuffers = true;
388+
}
387389
}
388390

389391
// Index buffer
@@ -394,9 +396,11 @@ void UIOverlay::update() {
394396
indexBuffer.unmap();
395397
indexBuffer.destroy();
396398
}
397-
indexBuffer = context.createBuffer(vk::BufferUsageFlagBits::eIndexBuffer, vk::MemoryPropertyFlagBits::eHostVisible, indexBufferSize);
398-
indexBuffer.map();
399-
updateCmdBuffers = true;
399+
if (indexCount) {
400+
indexBuffer = context.createBuffer(vk::BufferUsageFlagBits::eIndexBuffer, vk::MemoryPropertyFlagBits::eHostVisible, indexBufferSize);
401+
indexBuffer.map();
402+
updateCmdBuffers = true;
403+
}
400404
}
401405

402406
// Upload data
@@ -412,8 +416,12 @@ void UIOverlay::update() {
412416
}
413417

414418
// Flush to make writes visible to GPU
415-
vertexBuffer.flush();
416-
indexBuffer.flush();
419+
if (vertexBuffer) {
420+
vertexBuffer.flush();
421+
}
422+
if (indexBuffer) {
423+
indexBuffer.flush();
424+
}
417425

418426
if (updateCmdBuffers) {
419427
updateCommandBuffers();

base/vulkanExampleBase.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,24 @@ ExampleBase::~ExampleBase() {
6767
}
6868

6969
void ExampleBase::run() {
70+
try {
7071
// Android initialization is handled in APP_CMD_INIT_WINDOW event
7172
#if !defined(__ANDROID__)
72-
glfwInit();
73-
setupWindow();
74-
initVulkan();
75-
setupSwapchain();
76-
prepare();
73+
glfwInit();
74+
setupWindow();
75+
initVulkan();
76+
setupSwapchain();
77+
prepare();
7778
#endif
7879

79-
renderLoop();
80+
renderLoop();
8081

81-
// Once we exit the render loop, wait for everything to become idle before proceeding to the descructor.
82-
context.queue.waitIdle();
83-
context.device.waitIdle();
82+
// Once we exit the render loop, wait for everything to become idle before proceeding to the descructor.
83+
context.queue.waitIdle();
84+
context.device.waitIdle();
85+
} catch(const std::system_error& err) {
86+
std::cerr << err.what() << std::endl;
87+
}
8488
}
8589

8690
void ExampleBase::getEnabledFeatures() {
@@ -258,6 +262,8 @@ void ExampleBase::setupUi() {
258262
overlayCreateInfo.depthformat = depthFormat;
259263
overlayCreateInfo.size = size;
260264

265+
ImGui::SetCurrentContext(ImGui::CreateContext());
266+
261267
// Virtual function call for example to customize overlay creation
262268
OnSetupUIOverlay(overlayCreateInfo);
263269
ui.create(overlayCreateInfo);
@@ -350,7 +356,7 @@ void ExampleBase::prepareFrame() {
350356
}
351357

352358
void ExampleBase::submitFrame() {
353-
bool submitOverlay = settings.overlay && ui.visible;
359+
bool submitOverlay = settings.overlay && ui.visible && (ui.cmdBuffers.size() > currentBuffer);
354360
if (submitOverlay) {
355361
vk::SubmitInfo submitInfo;
356362
// Wait for color attachment output to finish before rendering the text overlay

cmake/externals/LibOVR/CMakeLists.txt

Lines changed: 0 additions & 100 deletions
This file was deleted.

cmake/externals/LibOVR/LibOVRCMakeLists.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

cmake/externals/assimp/CMakeLists.txt

Lines changed: 0 additions & 53 deletions
This file was deleted.

cmake/externals/glew/CMakeLists.txt

Lines changed: 0 additions & 37 deletions
This file was deleted.

cmake/externals/glfw3/CMakeLists.txt

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)