Skip to content

Commit

Permalink
update vulkan
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Feb 12, 2025
1 parent df90695 commit 181f660
Show file tree
Hide file tree
Showing 6 changed files with 684 additions and 689 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Current Version: RGFW 1.6-dev
- change RGFW_window_fullscreen to RGFW_window_setFullscreen
- make RGFW_window_setFullscreen use exclusive fullscreen
- add RGFW_window_isFullscreen
- add refreshRate to RGFW_monitor_scale

Release: RGFW 1.5 (Jan 14, 2024)
-----------------------------------------------
Expand Down Expand Up @@ -277,6 +278,7 @@ new examples:
- Add custom backend example
- Add gamepad example
- Add no standard library example
- add RGFW_VK_SURFACE and RGFW_window_createVKSurface directly to RGFW

Current Release: RGFW 1.06 (Aug 14, 2024)
-----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ else
endif


examples/vk10/vk10: examples/vk10/vk10.c RGFW.h
examples/vk10/vk10: examples/vk10/vk10.c examples/vk10/vkinit.h RGFW.h
ifneq ($(NO_VULKAN), 1)
glslangValidator -V examples/vk10/shaders/vert.vert -o examples/vk10/shaders/vert.h --vn vert_code
glslangValidator -V examples/vk10/shaders/frag.frag -o examples/vk10/shaders/frag.h --vn frag_code
Expand Down
51 changes: 49 additions & 2 deletions RGFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ typedef RGFW_ENUM(u8, RGFW_gamepadCodes) {
RGFWDEF RGFW_monitor* RGFW_getMonitors(void);
/*! get the primary monitor */
RGFWDEF RGFW_monitor RGFW_getPrimaryMonitor(void);
/*! scale monitor to area */
/*! scale monitor to area and refreshRate, if refreshRate == 0, it's ignored */
RGFWDEF RGFW_bool RGFW_monitor_scale(RGFW_monitor mon, RGFW_area area, u32 refreshRate);
#endif

Expand Down Expand Up @@ -1175,6 +1175,27 @@ typedef struct {
you can use this function to get a pointer the instance
*/
RGFWDEF RGFW_directXinfo* RGFW_getDirectXInfo(void);
#elif defined(RGFW_VULKAN)
#if defined(RGFW_X11)
#define VK_USE_PLATFORM_XLIB_KHR
#define RGFW_VK_SURFACE "VK_KHR_xlib_surface"
#elif defined(RGFW_WINDOWS)
#define VK_USE_PLATFORM_WIN32_KHR
#define OEMRESOURCE
#define RGFW_VK_SURFACE "VK_KHR_win32_surface"
#elif defined(RGFW_MACOS) && !defined(RGFW_MACOS_X11)
#define VK_USE_PLATFORM_MACOS_MVK
#define RGFW_VK_SURFACE "VK_MVK_macos_surface"
#elif defined(RGFW_WAYLAND)
#define VK_USE_PLATFORM_WAYLAND_KHR
#define RGFW_VK_SURFACE "VK_KHR_wayland_surface"
#else
#define RGFW_VK_SURFACE NULL
#endif

#include <vulkan/vulkan.h>

RGFWDEF VkResult RGFW_window_createVKSurface(RGFW_window* win, VkInstance instance, VkSurfaceKHR* surface);
#endif

/** @} */
Expand Down Expand Up @@ -2454,7 +2475,33 @@ void RGFW_window_swapInterval(RGFW_window* win, i32 swapInterval) {
/*
end of RGFW_EGL defines
*/
#endif /* RGFW_GL (OpenGL, EGL, OSMesa )*/
/* end of RGFW_GL (OpenGL, EGL, OSMesa )*/

/*
RGFW_VULKAN defines
*/
#elif defined(RGFW_VULKAN)

VkResult RGFW_window_createVKSurface(RGFW_window* win, VkInstance instance, VkSurfaceKHR* surface) {
assert(win != NULL); assert(instance);
assert(surface != NULL);

*surface = VK_NULL_HANDLE;

#ifdef RGFW_X11
VkXlibSurfaceCreateInfoKHR x11 = { VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, 0, 0, (Display*) win->src.display, (Window) win->src.window };
return vkCreateXlibSurfaceKHR(instance, &x11, NULL, surface);
#elif defined(RGFW_WINDOWS)
VkWin32SurfaceCreateInfoKHR win32 = { VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, 0, 0, GetModuleHandle(NULL), (HWND)win->src.window };

return vkCreateWin32SurfaceKHR(instance, &win32, NULL, surface);
#elif defined(RGFW_MACOS) && !defined(RGFW_MACOS_X11)
VkMacOSSurfaceCreateFlagsMVK macos = { VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK, 0, 0, vulkWin->display, (void *)win->src.window };

return vkCreateMacOSSurfaceMVK(instance, &macos, NULL, surface);
#endif
}
#endif /* end of RGFW_vulkan */

/*
This is where OS specific stuff starts
Expand Down
Loading

0 comments on commit 181f660

Please sign in to comment.