aboutsummaryrefslogtreecommitdiff
path: root/sokol_app.h
diff options
context:
space:
mode:
Diffstat (limited to 'sokol_app.h')
-rw-r--r--sokol_app.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/sokol_app.h b/sokol_app.h
index 99f25d11..5082d23c 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -23,6 +23,7 @@
#define SOKOL_D3D11
#define SOKOL_METAL
#define SOKOL_WGPU
+ #define SOKOL_VULKAN
#define SOKOL_NOAPI
Optionally provide the following defines with your own implementations:
@@ -79,11 +80,17 @@
- with SOKOL_GLCORE: GL
- with SOKOL_GLES3: GLESv2
- with SOKOL_WGPU: a WebGPU implementation library (tested with webgpu_dawn)
+ - with SOKOL_VULKAN: vulkan
- with EGL: EGL
- on Android: GLESv3, EGL, log, android
- on Windows:
- with MSVC or Clang: library dependencies are defined via `#pragma comment`
- with SOKOL_WGPU: a WebGPU implementation library (tested with webgpu_dawn)
+ - with SOKOL_VULKAN:
+ - install the Vulkan SDK
+ - set a header search path to $VULKAN_SDK/Include
+ - set a library search path to $VULKAN_SDK/Lib
+ - link with vulkan-1.lib
- with MINGW/MSYS2 gcc:
- compile with '-mwin32' so that _WIN32 is defined
- link with the following libs: -lkernel32 -luser32 -lshell32
@@ -93,6 +100,11 @@
On Linux, you also need to use the -pthread compiler and linker option, otherwise weird
things will happen, see here for details: https://github.com/floooh/sokol/issues/376
+ For Linux+Vulkan install the following packages (or equivalents):
+ - libvulkan-dev
+ - vulkan-validationlayers
+ - vulkan-tools
+
On macOS and iOS, the implementation must be compiled as Objective-C.
On Emscripten:
@@ -2307,8 +2319,12 @@ inline void sapp_run(const sapp_desc& desc) { return sapp_run(&desc); }
#elif defined(_WIN32)
// Windows (D3D11 or GL)
#define _SAPP_WIN32 (1)
- #if !defined(SOKOL_D3D11) && !defined(SOKOL_GLCORE) && !defined(SOKOL_WGPU) && !defined(SOKOL_NOAPI)
- #error("sokol_app.h: unknown 3D API selected for Win32, must be SOKOL_D3D11, SOKOL_GLCORE, SOKOL_WGPU or SOKOL_NOAPI")
+ #if !defined(SOKOL_D3D11) && !defined(SOKOL_GLCORE) && !defined(SOKOL_WGPU) && !defined(SOKOL_VULKAN) && !defined(SOKOL_NOAPI)
+ #error("sokol_app.h: unknown 3D API selected for Win32, must be SOKOL_D3D11, SOKOL_GLCORE, SOKOL_WGPU, SOKOL_VULKAN or SOKOL_NOAPI")
+ #endif
+ #if defined(SOKOL_VULKAN)
+ #define VK_USE_PLATFORM_WIN32_KHR
+ #include <vulkan/vulkan.h>
#endif
#elif defined(__ANDROID__)
// Android
@@ -4291,6 +4307,8 @@ _SOKOL_PRIVATE void _sapp_vk_create_instance(void) {
ext_names[ext_count++] = VK_KHR_SURFACE_EXTENSION_NAME;
#if defined(VK_USE_PLATFORM_XLIB_KHR)
ext_names[ext_count++] = VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
+ #elif defined(VK_USE_PLATFORM_WIN32_KHR)
+ ext_names[ext_count++] = VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
#endif
SOKOL_ASSERT(ext_count <= 32);
@@ -4517,6 +4535,12 @@ _SOKOL_PRIVATE void _sapp_vk_create_surface(void) {
xlib_info.dpy = _sapp.x11.display;
xlib_info.window = _sapp.x11.window;
res = vkCreateXlibSurfaceKHR(_sapp.vk.instance, &xlib_info, 0, &_sapp.vk.surface);
+ #elif defined(_SAPP_WIN32)
+ _SAPP_STRUCT(VkWin32SurfaceCreateInfoKHR, win32_info);
+ win32_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
+ win32_info.hinstance = GetModuleHandleW(NULL);
+ win32_info.hwnd = _sapp.win32.hwnd;
+ res = vkCreateWin32SurfaceKHR(_sapp.vk.instance, &win32_info, 0, &_sapp.vk.surface);
#else
#error "sokol_app.h: unsupported Vulkan platform"
#endif
@@ -9076,6 +9100,8 @@ _SOKOL_PRIVATE void _sapp_win32_timing_measure(void) {
_SOKOL_PRIVATE void _sapp_win32_frame(bool from_winproc) {
#if defined(SOKOL_WGPU)
_sapp_wgpu_frame();
+ #elif defined(SOKOL_VULKAN)
+ _sapp_vk_frame();
#else
_sapp_frame();
#endif
@@ -9693,6 +9719,8 @@ _SOKOL_PRIVATE void _sapp_win32_run(const sapp_desc* desc) {
_sapp_wgl_create_context();
#elif defined(SOKOL_WGPU)
_sapp_wgpu_init();
+ #elif defined(SOKOL_VULKAN)
+ _sapp_vk_init();
#endif
_sapp.valid = true;
@@ -9741,6 +9769,8 @@ _SOKOL_PRIVATE void _sapp_win32_run(const sapp_desc* desc) {
_sapp_wgl_shutdown();
#elif defined(SOKOL_WGPU)
_sapp_wgpu_discard();
+ #elif defined(SOKOL_VULKAN)
+ _sapp_vk_discard();
#endif
_sapp_win32_destroy_window();
_sapp_win32_destroy_icons();