简体   繁体   English

Wayland,Xlib,XCB,MIR窗口系统的预处理器符号

[英]Preprocessor symbol for Wayland, Xlib, XCB, MIR window systems

On Vulkan docs we have the following regarding WSI Platform: 在Vulkan docs上,我们具有有关WSI平台的以下内容:

The Vulkan API does not define any type of platform object. Vulkan API没有定义任何类型的平台对象。 Platform-specific WSI extensions are defined, which contain platform-specific functions for using WSI. 定义了特定于平台的WSI扩展,其中包含使用WSI的特定于平台的功能。 Use of these extensions is guarded by preprocessor symbols. 这些扩展名的使用受到预处理器符号的保护。

• VK_USE_PLATFORM_ANDROID_KHR - Android •VK_USE_PLATFORM_ANDROID_KHR-安卓

• VK_USE_PLATFORM_MIR_KHR - Mir •VK_USE_PLATFORM_MIR_KHR-Mir

• VK_USE_PLATFORM_WAYLAND_KHR - Wayland •VK_USE_PLATFORM_WAYLAND_KHR-韦兰

• VK_USE_PLATFORM_WIN32_KHR - Microsoft Windows •VK_USE_PLATFORM_WIN32_KHR-Microsoft Windows

• VK_USE_PLATFORM_XCB_KHR - X Window System, using the XCB library •VK_USE_PLATFORM_XCB_KHR-使用XCB库的X Window系统

• VK_USE_PLATFORM_XLIB_KHR - X Window System, using the Xlib library •VK_USE_PLATFORM_XLIB_KHR-使用Xlib库的X Window系统

I understand that I should pick a platform or a Window System, and then define the correct symbol prior to compile. 我了解我应该选择一个平台或Window System,然后在编译之前定义正确的符号。 When compiling against Android or Windows, I can just write something like below: 在针对Android或Windows进行编译时,我可以编写如下内容:

#if defined(ANDROID) || defined (__ANDROID__)
  #define VK_USE_PLATFORM_ANDROID_KHR 1
#elif defined(_WIN32)
  #define VK_USE_PLATFORM_WIN32_KHR 1
#endif

So far, OK. 到目前为止,还可以。 Android and Windows has their own unique window system, which is good enough. Android和Windows都有自己独特的窗口系统,这已经足够了。 But Linux has several windowing systems - Xlib, XCB, Wayland and MIR, afaik. 但是Linux有几个窗口系统-Xlib,XCB,Wayland和MIR,afaik。

I'd like to know if there is a C/C++ preprocessor symbol which may help to know which Window System is the one used by that environment, so can write generic code able to deal with each API, without messing then. 我想知道是否有一个C / C ++ 预处理器符号 ,它可以帮助您了解该环境使用的是哪个Window System,因此可以编写能够处理每个API的通用代码,而不会造成混乱。

Xlib and XCB are two libraries that can both be used interchangeably to interface with an X11 windowing server on Linux. Xlib和XCB是两个库,它们可以互换使用,以与Linux上的X11窗口服务器接口。 If you need your application to be compatible with older Linux systems, build for Xlib; 如果您需要您的应用程序与较早的Linux系统兼容,请为Xlib编译; otherwise, use XCB. 否则,请使用XCB。

Wayland and Mir are both still highly experimental (as of May 2016), and can safely be ignored. Wayland和Mir仍处于试验阶段(截至2016年5月),可以放心忽略。

If you are the one interfacing with the windowing system then you already know what preprocessor symbol you need. 如果您是与窗口系统接口的人,那么您已经知道所需的预处理器符号。

If you are not then as the application code (using a wrapper around the native windowing) then you would ask the wrapper for the vkSurface, if that is not available then raise an issue with the wrapper's maintainers. 如果您不是当时的应用程序代码(在本机窗口周围使用包装器),那么您将要求包装器提供vkSurface,如果不可用,则引发包装器维护者的问题。

If you are a vulkan library then you should be able to handle all linux windowing options. 如果您是vulkan库,那么您应该能够处理所有linux窗口选项。 If you enable all preprocessor symbols and manually load the required function as needed depending on which function the application calls. 如果启用所有预处理器符号并根据应用程序调用的功能,根据需要手动加载所需的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM