diff --git a/.gitignore b/.gitignore index 6536e5a..d6862e0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,11 +6,6 @@ sample/*/textures/ vcc/include/vcc/export.h -# TODO(gardell): Generated by freeglut, should not be here. -config.h -freeglut.pc -freeglut.rc - *.spv cpp-frp/libcpp-frp.a @@ -19,6 +14,9 @@ test/frp-test test-coverage.info test-coverage/ +## vscode +.vscode + ## Android *.iml diff --git a/CMakeLists.txt b/CMakeLists.txt index c088209..e48e122 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,29 +15,32 @@ set(CMAKE_CXX_STANDARD 11) set(VULKAN_SDK_DIR "" CACHE PATH "Path to the Vulkan SDK") +set(VULKAN_CPP_LIBRARY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(VULKAN_CPP_LIBRARY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + # # SPIRV-Headers # -set(SPIRV-Headers_SOURCE_DIR ${CMAKE_BINARY_DIR}/spirv-headers-src) +set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/spirv-headers-src) # Download and unpack SPIRV-Headers at configure time configure_file(CMakeLists.txt.spirv-headers.in spirv-headers-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-headers-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spirv-headers-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-headers-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spirv-headers-download) # Add SPIRV-Headers directly to our build. -add_subdirectory(${CMAKE_BINARY_DIR}/spirv-headers-src - ${CMAKE_BINARY_DIR}/spirv-headers-build) +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/spirv-headers-src + ${CMAKE_CURRENT_BINARY_DIR}/spirv-headers-build) # # SPIRV-Tools # -set(SPIRV_TOOLS_SRC ${CMAKE_BINARY_DIR}/spirv-tools-src) +set(SPIRV_TOOLS_SRC ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-src) SET(SPIRV_SKIP_EXECUTABLES OFF CACHE BOOL "" FORCE) SET(SPIRV_SKIP_TESTS OFF CACHE BOOL "" FORCE) @@ -46,13 +49,13 @@ SET(SPIRV_SKIP_TESTS OFF CACHE BOOL "" FORCE) configure_file(CMakeLists.txt.spirv-tools.in spirv-tools-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-tools-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-tools-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-download) # Add SPIRV-Tools directly to our build. -add_subdirectory(${CMAKE_BINARY_DIR}/spirv-tools-src - ${CMAKE_BINARY_DIR}/spirv-tools-build) +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-src + ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-build) # # glm @@ -60,29 +63,29 @@ add_subdirectory(${CMAKE_BINARY_DIR}/spirv-tools-src add_definitions(-DGLM_ENABLE_EXPERIMENTAL) -set(GLM_SRC_DIR ${CMAKE_BINARY_DIR}/glm-src) +set(GLM_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/glm-src) # Download and unpack glm at configure time configure_file(CMakeLists.txt.glm.in glm-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glm-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/glm-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glm-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/glm-download) # # gli # -set(GLI_SRC_DIR ${CMAKE_BINARY_DIR}/gli-src) +set(GLI_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/gli-src) # Download and unpack gli at configure time configure_file(CMakeLists.txt.gli.in gli-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gli-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gli-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gli-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gli-download) if(NOT DEFINED ANDROID_NDK) @@ -94,9 +97,9 @@ if(NOT DEFINED ANDROID_NDK) configure_file(CMakeLists.txt.googletest.in googletest-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download) # Prevent GoogleTest from overriding our compiler/linker options # when building with Visual Studio @@ -105,8 +108,8 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Add googletest directly to our build. This adds # the following targets: gtest, gtest_main, gmock # and gmock_main -add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src - ${CMAKE_BINARY_DIR}/googletest-build) +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build) # # Glslang @@ -116,66 +119,66 @@ add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src configure_file(CMakeLists.txt.glslang.in glslang-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glslang-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/glslang-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glslang-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/glslang-download) # Add glslang directly to our build. -add_subdirectory(${CMAKE_BINARY_DIR}/glslang-src - ${CMAKE_BINARY_DIR}/glslang-build) +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/glslang-src + ${CMAKE_CURRENT_BINARY_DIR}/glslang-build) # # OpenVR # -set(OPENVR_SOURCE_DIR ${CMAKE_BINARY_DIR}/openvr) +set(OPENVR_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/openvr) # Download and unpack OpenVR at configure time configure_file(CMakeLists.txt.openvr.in openvr-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openvr-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/openvr-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openvr-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/openvr-download) # # zlib # set(SKIP_INSTALL_ALL true) -set(ZLIB_SRC_DIR ${CMAKE_BINARY_DIR}/zlib-src) +set(ZLIB_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/zlib-src) # Download and unpack zlib at configure time configure_file(CMakeLists.txt.zlib.in zlib-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/zlib-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/zlib-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/zlib-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/zlib-download) # Add zlib directly to our build. add_subdirectory(${ZLIB_SRC_DIR} - ${CMAKE_BINARY_DIR}/zlib-build) + ${CMAKE_CURRENT_BINARY_DIR}/zlib-build) set(ZLIB_LIBRARY zlib) -set(ZLIB_INCLUDE_DIR ${ZLIB_SRC_DIR} ${CMAKE_BINARY_DIR}/zlib-build) +set(ZLIB_INCLUDE_DIR ${ZLIB_SRC_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib-build) # # png # -set(PNG_SRC_DIR ${CMAKE_BINARY_DIR}/png-src) -set(PNG_BUILD_DIR ${CMAKE_BINARY_DIR}/png-build) +set(PNG_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/png-src) +set(PNG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/png-build) set(PNG_INCLUDE_DIR ${PNG_SRC_DIR} ${PNG_BUILD_DIR}) # Download and unpack png at configure time configure_file(CMakeLists.txt.png.in png-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/png-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/png-download) execute_process(COMMAND ${CMAKE_COMMAND} --build . - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/png-download) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/png-download) # Add png directly to our build. add_subdirectory(${PNG_SRC_DIR} ${PNG_BUILD_DIR}) diff --git a/CMakeLists.txt.freeglut.in b/CMakeLists.txt.freeglut.in deleted file mode 100644 index 0929188..0000000 --- a/CMakeLists.txt.freeglut.in +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright 2016 Google Inc. All Rights Reserved. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -cmake_minimum_required(VERSION 2.8.2) - -project(freeglut-download NONE) - -include(ExternalProject) -ExternalProject_Add(freeglut - GIT_REPOSITORY https://github.com/dcnieho/FreeGLUT.git - GIT_TAG git_master - SOURCE_DIR "${FREEGLUT_SRC_DIR}" - BINARY_DIR "${CMAKE_BINARY_DIR}/freeglut-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/CMakeLists.txt.glslang.in b/CMakeLists.txt.glslang.in index 29e1d9e..f8bcab0 100644 --- a/CMakeLists.txt.glslang.in +++ b/CMakeLists.txt.glslang.in @@ -18,8 +18,8 @@ include(ExternalProject) ExternalProject_Add(glslang GIT_REPOSITORY https://github.com/KhronosGroup/glslang.git GIT_TAG master - SOURCE_DIR "${CMAKE_BINARY_DIR}/glslang-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/glslang-build" + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/glslang-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/glslang-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/CMakeLists.txt.googletest.in b/CMakeLists.txt.googletest.in index 52378f1..a1585cd 100644 --- a/CMakeLists.txt.googletest.in +++ b/CMakeLists.txt.googletest.in @@ -18,8 +18,8 @@ include(ExternalProject) ExternalProject_Add(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG master - SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/CMakeLists.txt.spirv-headers.in b/CMakeLists.txt.spirv-headers.in index a81dda0..b3c3dd0 100644 --- a/CMakeLists.txt.spirv-headers.in +++ b/CMakeLists.txt.spirv-headers.in @@ -19,7 +19,7 @@ ExternalProject_Add(spirv-headers GIT_REPOSITORY https://github.com/KhronosGroup/SPIRV-Headers.git GIT_TAG master SOURCE_DIR "${SPIRV-Headers_SOURCE_DIR}" - BINARY_DIR "${CMAKE_BINARY_DIR}/spirv-headers-build" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/spirv-headers-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/CMakeLists.txt.spirv-tools.in b/CMakeLists.txt.spirv-tools.in index 94f075d..688c129 100644 --- a/CMakeLists.txt.spirv-tools.in +++ b/CMakeLists.txt.spirv-tools.in @@ -19,7 +19,7 @@ ExternalProject_Add(spirv-tools GIT_REPOSITORY https://github.com/KhronosGroup/SPIRV-Tools.git GIT_TAG master SOURCE_DIR "${SPIRV_TOOLS_SRC}" - BINARY_DIR "${CMAKE_BINARY_DIR}/spirv-tools-build" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/CMakeLists.txt.zlib.in b/CMakeLists.txt.zlib.in index 4b2da5c..9419bd7 100644 --- a/CMakeLists.txt.zlib.in +++ b/CMakeLists.txt.zlib.in @@ -19,7 +19,7 @@ ExternalProject_Add(zlib GIT_REPOSITORY https://github.com/madler/zlib.git GIT_TAG master SOURCE_DIR "${ZLIB_SRC_DIR}" - BINARY_DIR "${CMAKE_BINARY_DIR}/zlib-build" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/README.md b/README.md index 3bedf19..31cf757 100644 --- a/README.md +++ b/README.md @@ -82,14 +82,14 @@ The library is thread-safe as required by the Vulkan specification, `2.5 Threadi Notice that `Implicit Externally Synchronized Parameters` is not included. ### OpenVR Samples include an OpenVR example. This simple demo renders the models of the connected devices like trackers and controllers. It supports lazy loading and recompiles the command buffers when any new devices are added or removed. -##Install -###Linux/XCB +## Install +### Linux/XCB `cmake .` downloads all the dependencies needed. `cmake --build .` compiles the libraries and samples. -###Android +### Android Install `Android Studio` and the `NDK`. `SDK 25` is required. Import the root project directory. Initial building and synchronizing will take a very long time, as it will download the dependency projects needed. **Note:** Textures are copied to the `assets/` and `res/` folders of the respective projects. However, `*.spv` compiled shaders are not generated. These must be copied to the `assets/` folder. -###Visual Studio 2015 +### Visual Studio 2015 Only 2015 is supported. The C++11 support in previous versions is not sufficient. `cmake -DVULKAN_SDK_DIR:PATH= .` downloads all the dependencies and sets up the projects. Either use `cmake --build .` to compile or open the generated `.sln`. diff --git a/sample/cube/CMakeLists.txt b/sample/cube/CMakeLists.txt index 7f80d12..af1b918 100644 --- a/sample/cube/CMakeLists.txt +++ b/sample/cube/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories(../../types/include) include_directories(../../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(../../vcc-image/include) include_directories(${GLM_SRC_DIR}) if(NOT VULKAN_SDK_DIR STREQUAL "") diff --git a/sample/heightmap/CMakeLists.txt b/sample/heightmap/CMakeLists.txt index ea585d3..1503f59 100644 --- a/sample/heightmap/CMakeLists.txt +++ b/sample/heightmap/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories(../../types/include) include_directories(../../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(../../vcc-image/include) include_directories(${CPP_FRP_SRC_DIR}/cpp-frp/include) include_directories(${GLM_SRC_DIR}) diff --git a/sample/lighting/CMakeLists.txt b/sample/lighting/CMakeLists.txt index 797cb9b..6894407 100644 --- a/sample/lighting/CMakeLists.txt +++ b/sample/lighting/CMakeLists.txt @@ -14,7 +14,7 @@ include_directories(include) include_directories(../../types/include) include_directories(../../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(${GLM_SRC_DIR}) if(NOT VULKAN_SDK_DIR STREQUAL "") include_directories(${VULKAN_SDK_DIR}/include) diff --git a/sample/normal-mapping-and-cube-texture/CMakeLists.txt b/sample/normal-mapping-and-cube-texture/CMakeLists.txt index 591e89f..3f48d4e 100644 --- a/sample/normal-mapping-and-cube-texture/CMakeLists.txt +++ b/sample/normal-mapping-and-cube-texture/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories(../../types/include) include_directories(../../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(../../vcc-image/include) include_directories(${GLM_SRC_DIR}) if(NOT VULKAN_SDK_DIR STREQUAL "") diff --git a/sample/openvr/CMakeLists.txt b/sample/openvr/CMakeLists.txt index eab94cd..dd80e45 100644 --- a/sample/openvr/CMakeLists.txt +++ b/sample/openvr/CMakeLists.txt @@ -14,7 +14,7 @@ include_directories(include) include_directories(../../types/include) include_directories(../../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(../../vcc-image/include) include_directories(${GLM_SRC_DIR}) include_directories(${OPENVR_SOURCE_DIR}/headers) diff --git a/sample/teapot/CMakeLists.txt b/sample/teapot/CMakeLists.txt index d6a11ed..54cc570 100644 --- a/sample/teapot/CMakeLists.txt +++ b/sample/teapot/CMakeLists.txt @@ -14,7 +14,7 @@ include_directories(include) include_directories(../../types/include) include_directories(../../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(../../vcc-image/include) include_directories(${GLM_SRC_DIR}) if(NOT VULKAN_SDK_DIR STREQUAL "") diff --git a/vcc-image/CMakeLists.txt b/vcc-image/CMakeLists.txt index 394d2d2..cbbc3ae 100644 --- a/vcc-image/CMakeLists.txt +++ b/vcc-image/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories(include) include_directories(../types/include) include_directories(../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(${GLI_SRC_DIR}) include_directories(${GLI_SRC_DIR}/external) if(NOT PNG_INCLUDE_DIR STREQUAL "") diff --git a/vcc-test/CMakeLists.txt b/vcc-test/CMakeLists.txt index 8b7f776..00e3c51 100644 --- a/vcc-test/CMakeLists.txt +++ b/vcc-test/CMakeLists.txt @@ -12,7 +12,7 @@ # include_directories(../vcc/include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(../types/include) include_directories(${gtest_SOURCE_DIR}/include) include_directories(${GLM_SRC_DIR}) diff --git a/vcc/CMakeLists.txt b/vcc/CMakeLists.txt index fbf9896..991d2bc 100644 --- a/vcc/CMakeLists.txt +++ b/vcc/CMakeLists.txt @@ -12,7 +12,7 @@ # include(GenerateExportHeader) include_directories(include) -include_directories(${CMAKE_BINARY_DIR}/vcc/include) +include_directories(${VULKAN_CPP_LIBRARY_BINARY_DIR}/vcc/include) include_directories(../types/include) include_directories(${GLM_SRC_DIR}) if(NOT VULKAN_SDK_DIR STREQUAL "") @@ -116,5 +116,5 @@ generate_export_header(vcc target_link_libraries(vcc types ${VULKAN_LIBRARY}) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - target_link_libraries(vcc pthread xcb atomic) + target_link_libraries(vcc pthread xcb xcb-keysyms atomic) endif() diff --git a/vcc/include/vcc/window.h b/vcc/include/vcc/window.h index 9d81ca2..86e3f3d 100644 --- a/vcc/include/vcc/window.h +++ b/vcc/include/vcc/window.h @@ -32,7 +32,9 @@ #include #ifdef _WIN32 #include -#endif // WIN32 +#elif defined(VK_USE_PLATFORM_XCB_KHR) +#include +#endif namespace vcc { namespace window { @@ -162,7 +164,8 @@ struct window_type { , connection(std::forward(connection)) , window(std::forward(window)) , extent(extent) - , atom_wm_delete_window(nullptr, free) + , atom_wm_delete_window(nullptr, free) + , key_symbols(nullptr, xcb_key_symbols_free) #endif // VK_USE_PLATFORM_XCB_KHR , device(device), graphics_queue(graphics_queue) {} @@ -177,6 +180,8 @@ struct window_type { typedef std::unique_ptr atom_reply_t; atom_reply_t atom_wm_delete_window; VkExtent2D extent; + typedef std::unique_ptr key_symbols_t; + key_symbols_t key_symbols; #endif // __ANDROID__ type::supplier instance; surface::surface_type surface; diff --git a/vcc/src/window.cpp b/vcc/src/window.cpp index 46d3731..40a080c 100644 --- a/vcc/src/window.cpp +++ b/vcc/src/window.cpp @@ -426,6 +426,7 @@ window_type create( xcb_intern_atom_cookie_t cookie2(xcb_intern_atom(window.connection.get(), 0, 16, "WM_DELETE_WINDOW")); window.atom_wm_delete_window.reset(xcb_intern_atom_reply(window.connection.get(), cookie2, 0)); + window.key_symbols.reset(xcb_key_symbols_alloc(window.connection.get())); xcb_change_property(window.connection.get(), XCB_PROP_MODE_REPLACE, window.window, reply->atom, 4, 32, 1, &window.atom_wm_delete_window->atom); @@ -621,13 +622,13 @@ int run(window_type &window, const swapchain_create_callback_type &swapchain_cre } break; case XCB_KEY_PRESS: { auto kp = (xcb_key_press_event_t *) event.get(); - // TODO(gardell): Translate button - input_callbacks.key_down_callback(keycode_type(kp->detail)); + input_callbacks.key_down_callback(keycode_type(xcb_key_symbols_get_keysym( + window.key_symbols.get(), kp->detail, 0))); } break; case XCB_KEY_RELEASE: { auto kr = (xcb_key_release_event_t *) event.get(); - // TODO(gardell): Translate button - input_callbacks.key_up_callback(keycode_type(kr->detail)); + input_callbacks.key_up_callback(keycode_type(xcb_key_symbols_get_keysym( + window.key_symbols.get(), kr->detail, 0))); } break; } }