xo-imgui: restore opengl + vulkan builds
This commit is contained in:
parent
d817c649aa
commit
d9aa1ddc81
15 changed files with 202 additions and 194 deletions
|
|
@ -1,67 +1,74 @@
|
|||
if (XO_ENABLE_EXAMPLES)
|
||||
# imgui dependency
|
||||
|
||||
find_path(IMGUI_INCLUDE_DIR
|
||||
NAMES imgui/imgui.h
|
||||
DOC "path to imgui header"
|
||||
)
|
||||
if (IMGUI_INCLUDE_DIR)
|
||||
message(STATUS "found imgui/imgui.h in IMGUI_INCLUDE_DIR=[${IMGUI_INCLUDE_DIR}]")
|
||||
else()
|
||||
message(FATAL_ERROR "unable to find imgui.h")
|
||||
if (XO_ENABLE_VULKAN)
|
||||
|
||||
find_path(
|
||||
IMGUI_INCLUDE_DIR
|
||||
NAMES imgui/imgui.h
|
||||
DOC "path to imgui header"
|
||||
HINTS ${PROJECT_SOURCE_DIR}/include
|
||||
)
|
||||
if (IMGUI_INCLUDE_DIR)
|
||||
message(STATUS "found imgui/imgui.h in IMGUI_INCLUDE_DIR=[${IMGUI_INCLUDE_DIR}]")
|
||||
else()
|
||||
message(FATAL_ERROR "unable to find imgui.h")
|
||||
endif()
|
||||
|
||||
# target executable
|
||||
|
||||
set(SELF_EXE imgui_ex3)
|
||||
add_executable(${SELF_EXE} imgui_ex3.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_demo.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_draw.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_widgets.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_tables.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_sdl2.cpp
|
||||
#${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_opengl3.cpp
|
||||
#${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_glfw.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_vulkan.cpp
|
||||
)
|
||||
xo_include_options2(${SELF_EXE})
|
||||
|
||||
# OpenGL dependency
|
||||
|
||||
# have to choose between
|
||||
# libGL.so
|
||||
# or
|
||||
# libOpenGL.so + libGLX.so # GLVND = OpenGL Vendor Neutral Dispatch (e.g. mesa|nvda)
|
||||
#
|
||||
# expect in .build/CMakeCache.txt:
|
||||
# OPENGL_opengl_LIBRARY:FILEPATH=/path/to/libOpenGL.so
|
||||
# OpenGL_DIR:PATH=OpenGL_DIR-NOTFOUND # no cmake config file
|
||||
|
||||
# set(OpenGL_GL_PREFERENCE GLVND) # or LEGACY
|
||||
# find_package(OpenGL REQUIRED) # find_package(OpenGL CONFIG REQUIRE) won't work
|
||||
# target_link_libraries(${SELF_EXE} PUBLIC OpenGL::GL)
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
target_link_libraries(${SELF_EXE} PUBLIC Vulkan::Vulkan)
|
||||
|
||||
# GLEW dependency
|
||||
xo_external_pkgconfig_dependency(${SELF_EXE} GLEW glew)
|
||||
|
||||
# GLFW dependency
|
||||
#find_package(glfw3 CONFIG REQUIRED)
|
||||
#target_link_libraries(${SELF_EXE} PUBLIC glfw) # want -lglfw
|
||||
|
||||
# SDL2 dependency
|
||||
xo_external_pkgconfig_dependency(${SELF_EXE} SDL2 sdl2)
|
||||
|
||||
# would prefer to use just IMGUI_INCLUDE_DIR,
|
||||
# but imgui/backends/ .h files don't quote the imgui/ stem
|
||||
#
|
||||
target_include_directories(${SELF_EXE} PUBLIC ${IMGUI_INCLUDE_DIR}/imgui)
|
||||
|
||||
xo_dependency(${SELF_EXE} xo_object)
|
||||
xo_dependency(${SELF_EXE} randomgen)
|
||||
xo_dependency(${SELF_EXE} xo_flatstring)
|
||||
xo_dependency(${SELF_EXE} xo_alloc)
|
||||
|
||||
install(TARGETS ${SELF_EXE} DESTINATION ${XO_EXAMPLE_INSTALL_DIR})
|
||||
endif()
|
||||
|
||||
# target executable
|
||||
|
||||
set(SELF_EXE imgui_ex3)
|
||||
add_executable(${SELF_EXE} imgui_ex3.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_demo.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_draw.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_widgets.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/imgui_tables.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_sdl2.cpp
|
||||
#${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_opengl3.cpp
|
||||
#${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_glfw.cpp
|
||||
${IMGUI_INCLUDE_DIR}/imgui/backends/imgui_impl_vulkan.cpp
|
||||
)
|
||||
xo_include_options2(${SELF_EXE})
|
||||
|
||||
# OpenGL dependency
|
||||
|
||||
# have to choose between
|
||||
# libGL.so
|
||||
# or
|
||||
# libOpenGL.so + libGLX.so # GLVND = OpenGL Vendor Neutral Dispatch (e.g. mesa|nvda)
|
||||
#
|
||||
# expect in .build/CMakeCache.txt:
|
||||
# OPENGL_opengl_LIBRARY:FILEPATH=/path/to/libOpenGL.so
|
||||
# OpenGL_DIR:PATH=OpenGL_DIR-NOTFOUND # no cmake config file
|
||||
|
||||
# set(OpenGL_GL_PREFERENCE GLVND) # or LEGACY
|
||||
# find_package(OpenGL REQUIRED) # find_package(OpenGL CONFIG REQUIRE) won't work
|
||||
# target_link_libraries(${SELF_EXE} PUBLIC OpenGL::GL)
|
||||
|
||||
find_package(Vulkan REQUIRED)
|
||||
target_link_libraries(${SELF_EXE} PUBLIC Vulkan::Vulkan)
|
||||
|
||||
# GLEW dependency
|
||||
xo_external_pkgconfig_dependency(${SELF_EXE} GLEW glew)
|
||||
|
||||
# GLFW dependency
|
||||
#find_package(glfw3 CONFIG REQUIRED)
|
||||
#target_link_libraries(${SELF_EXE} PUBLIC glfw) # want -lglfw
|
||||
|
||||
# SDL2 dependency
|
||||
xo_external_pkgconfig_dependency(${SELF_EXE} SDL2 sdl2)
|
||||
|
||||
# would prefer to use just IMGUI_INCLUDE_DIR,
|
||||
# but imgui/backends/ .h files don't quote the imgui/ stem
|
||||
#
|
||||
target_include_directories(${SELF_EXE} PUBLIC ${IMGUI_INCLUDE_DIR}/imgui)
|
||||
|
||||
xo_dependency(${SELF_EXE} xo_object)
|
||||
xo_dependency(${SELF_EXE} randomgen)
|
||||
xo_dependency(${SELF_EXE} xo_flatstring)
|
||||
xo_dependency(${SELF_EXE} xo_alloc)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -4365,17 +4365,23 @@ private:
|
|||
throw std::runtime_error("Failed to get SDL Vulkan extensions!");
|
||||
}
|
||||
|
||||
#ifdef __apple__
|
||||
// Add portability extension for MoltenVK (macOS)
|
||||
extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
||||
#endif
|
||||
|
||||
createInfo.enabledExtensionCount = extensions.size();
|
||||
createInfo.ppEnabledExtensionNames = extensions.data();
|
||||
createInfo.enabledLayerCount = 0;
|
||||
|
||||
#ifdef __apple__
|
||||
// CRITICAL: Enable portability enumeration flag for MoltenVK
|
||||
createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
||||
#endif
|
||||
|
||||
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
|
||||
int result = vkCreateInstance(&createInfo, nullptr, &instance);
|
||||
if (result != VK_SUCCESS) {
|
||||
printf("vkCreateInstance failed with error: %d\n", result);
|
||||
throw std::runtime_error("Failed to create instance!");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue