Skip to content

Commit

Permalink
Add direct Wayland WSI (no decorations though)
Browse files Browse the repository at this point in the history
  • Loading branch information
krOoze committed Jan 31, 2019
1 parent 9a82e90 commit 36ef3b1
Show file tree
Hide file tree
Showing 9 changed files with 2,439 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ Requirements
**Build Environment[GLFW]**: GLFW 3.2+ (already included as a git submodule), requires `xorg-dev` package on Linux
**Build environment[Xlib]**: Requires `xorg-dev` package
**Build environment[XCB]**: Requires `libxcb1-dev`, `libxcb-util-dev`, `libxcb-keysyms1-dev`, and `x11proto-dev` packages
**Build environment[Wayland]**: Requires `libwayland-dev` and `libxkbcommon-dev` packages
**Target Environment**: installed (latest) Vulkan capable drivers (to see anything)
**Target Environment**: GLFW(recommended), XCB or Xlib based windowing system
**Target Environment**: GLFW(recommended), XCB, Xlib, or Wayland based windowing system

On Unix-like environment refer to [SDK docs](https://vulkan.lunarg.com/doc/sdk/latest/linux/getting_started.html) on how to set `VULKAN_SDK` variable.

Expand Down
2 changes: 2 additions & 0 deletions src/ErrorHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct VulkanResultException{
#define RESULT_HANDLER( errorCode, source ) if( errorCode ) throw VulkanResultException( __FILE__, __LINE__, __func__, source, errorCode )
#define RESULT_HANDLER_EX( cond, errorCode, source ) if( cond ) throw VulkanResultException( __FILE__, __LINE__, __func__, source, errorCode )

#define RUNTIME_ASSERT( cond, source ) if( !(cond) ) throw source " failed";

// just use cout for logging now
std::ostream& logger = std::cout;

Expand Down
10 changes: 6 additions & 4 deletions src/HelloTriangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,12 @@ int helloTriangle() try{
TODO( "This may be triggered from many sources (e.g. WM_SIZE event, and VK_ERROR_OUT_OF_DATE_KHR too). Should prevent duplicate swapchain recreation." )

VkSurfaceCapabilitiesKHR capabilities = getSurfaceCapabilities( physicalDevice, surface );
VkExtent2D surfaceSize = {
capabilities.currentExtent.width == UINT32_MAX ? ::initialWindowWidth : capabilities.currentExtent.width,
capabilities.currentExtent.height == UINT32_MAX ? ::initialWindowHeight : capabilities.currentExtent.height,
};

if( capabilities.currentExtent.width == UINT32_MAX && capabilities.currentExtent.height == UINT32_MAX ){
capabilities.currentExtent.width = getWindowWidth( window );
capabilities.currentExtent.height = getWindowHeight( window );
}
VkExtent2D surfaceSize = { capabilities.currentExtent.width, capabilities.currentExtent.height };

const bool swapchainCreatable = {
surfaceSize.width >= capabilities.minImageExtent.width
Expand Down
1 change: 1 addition & 0 deletions src/VulkanEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#define USE_PLATFORM_GLFW
//#define VK_USE_PLATFORM_XCB_KHR
//#define VK_USE_PLATFORM_XLIB_KHR
//#define VK_USE_PLATFORM_WAYLAND_KHR
#endif
#else
//#error "Unsupported OS platform." // caught in main.cpp instead
Expand Down
1 change: 1 addition & 0 deletions src/WSI/Glfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void toggleFullscreen( GLFWwindow* window ){
}
}

TODO( "Fullscreen window seem to become unresponsive in Wayland session Ubuntu" )
void keyCallback( GLFWwindow* window, int key, int /*scancode*/, int action, int mods ) noexcept{
if( key == GLFW_KEY_ESCAPE && action == GLFW_PRESS ) glfwSetWindowShouldClose( window, GLFW_TRUE );

Expand Down
Loading

0 comments on commit 36ef3b1

Please sign in to comment.