Class GLFWVulkan
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Contains the function pointers loaded fromGLFW.getLibrary()
. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
glfwCreateWindowSurface
(VkInstance instance, long window, VkAllocationCallbacks allocator, long[] surface) Array version of:CreateWindowSurface
static int
glfwCreateWindowSurface
(VkInstance instance, long window, VkAllocationCallbacks allocator, LongBuffer surface) Creates a Vulkan surface for the specified window.static long
glfwGetInstanceProcAddress
(VkInstance instance, CharSequence procname) Returns the address of the specified Vulkan core or extension function for the specified instance.static long
glfwGetInstanceProcAddress
(VkInstance instance, ByteBuffer procname) Returns the address of the specified Vulkan core or extension function for the specified instance.static boolean
glfwGetPhysicalDevicePresentationSupport
(VkInstance instance, VkPhysicalDevice device, int queuefamily) Returns whether the specified queue family of the specified physical device supports presentation to the platform GLFW was built for.static PointerBuffer
Returns an array of names of Vulkan instance extensions required by GLFW for creating Vulkan surfaces for GLFW windows.static void
glfwInitVulkanLoader
(long loader) Sets the desired VulkanvkGetInstanceProcAddr
function.static boolean
Returns whether the Vulkan loader has been found.static int
nglfwCreateWindowSurface
(long instance, long window, long allocator, long surface) Unsafe version of:CreateWindowSurface
static long
nglfwGetInstanceProcAddress
(long instance, long procname) Unsafe version of:GetInstanceProcAddress
static long
nglfwGetRequiredInstanceExtensions
(long count) Unsafe version of:GetRequiredInstanceExtensions
static void
Overrides the Vulkan shared library that GLFW loads internally.static void
setPath
(FunctionProvider sharedLibrary) CallssetPath(String)
with the path of the specifiedSharedLibrary
.
-
Method Details
-
glfwInitVulkanLoader
public static void glfwInitVulkanLoader(long loader) Sets the desired VulkanvkGetInstanceProcAddr
function.This function sets the
vkGetInstanceProcAddr
function that GLFW will use for all Vulkan related entry point queries.This feature is mostly useful on macOS, if your copy of the Vulkan loader is in a location where GLFW cannot find it through dynamic loading, or if you are still using the static library version of the loader.
If set to
NULL
, GLFW will try to load the Vulkan loader dynamically by its standard name and get this function from there. This is the default behavior.The standard name of the loader is
vulkan-1.dll
on Windows,libvulkan.so.1
on Linux and other Unix-like systems andlibvulkan.1.dylib
on macOS. If your code is also loading it via these names then you probably don't need to use this function.The function address you set is never reset by GLFW, but it only takes effect during initialization. Once GLFW has been initialized, any updates will be ignored until the library is terminated and initialized again.
This function may be called before
Init
.This function must only be called from the main thread.
- Parameters:
loader
- the address of the function to use, orNULL
- Since:
- version 3.4
-
glfwVulkanSupported
public static boolean glfwVulkanSupported()Returns whether the Vulkan loader has been found. This check is performed byInit
.The availability of a Vulkan loader and even an ICD does not by itself guarantee that surface creation or even instance creation is possible. Call
GetRequiredInstanceExtensions
to check whether the extensions necessary for Vulkan surface creation are available andGetPhysicalDevicePresentationSupport
to check whether a queue family of a physical device supports image presentation.Possible errors include
NOT_INITIALIZED
.This function may be called from any thread.
-
nglfwGetRequiredInstanceExtensions
public static long nglfwGetRequiredInstanceExtensions(long count) Unsafe version of:GetRequiredInstanceExtensions
- Parameters:
count
- where to store the number of extensions in the returned array. This is set to zero if an error occurred.
-
glfwGetRequiredInstanceExtensions
Returns an array of names of Vulkan instance extensions required by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the list will always containVK_KHR_surface
, so if you don't require any additional extensions you can pass this list directly to theVkInstanceCreateInfo
struct.If Vulkan is not available on the machine, this function returns
NULL
and generates aAPI_UNAVAILABLE
error. CallVulkanSupported
to check whether Vulkan is available.If Vulkan is available but no set of extensions allowing window surface creation was found, this function returns
NULL
. You may still use Vulkan for off-screen rendering and compute work.Additional extensions may be required by future versions of GLFW. You should check if any extensions you wish to enable are already in the returned array, as it is an error to specify an extension more than once in the
VkInstanceCreateInfo
struct.The returned array is allocated and freed by GLFW. You should not free it yourself. It is guaranteed to be valid only until the library is terminated.
This function may be called from any thread.
Possible errors include
NOT_INITIALIZED
andAPI_UNAVAILABLE
.- Returns:
- an array of ASCII encoded extension names, or
NULL
if an error occurred - Since:
- version 3.2
-
nglfwGetInstanceProcAddress
public static long nglfwGetInstanceProcAddress(long instance, long procname) Unsafe version of:GetInstanceProcAddress
-
glfwGetInstanceProcAddress
Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set toNULL
it can return any function exported from the Vulkan loader, including at least the following functions:VK10.vkEnumerateInstanceExtensionProperties(java.nio.ByteBuffer, java.nio.IntBuffer, org.lwjgl.vulkan.VkExtensionProperties.Buffer)
VK10.vkEnumerateInstanceLayerProperties(java.nio.IntBuffer, org.lwjgl.vulkan.VkLayerProperties.Buffer)
VK10.vkCreateInstance(org.lwjgl.vulkan.VkInstanceCreateInfo, org.lwjgl.vulkan.VkAllocationCallbacks, org.lwjgl.PointerBuffer)
VK10.vkGetInstanceProcAddr(org.lwjgl.vulkan.VkInstance, java.nio.ByteBuffer)
If Vulkan is not available on the machine, this function returns
NULL
and generates aAPI_UNAVAILABLE
error. CallVulkanSupported
to check whether Vulkan is available.This function is equivalent to calling
VK10.vkGetInstanceProcAddr(org.lwjgl.vulkan.VkInstance, java.nio.ByteBuffer)
with a platform-specific query of the Vulkan loader as a fallback.Possible errors include
NOT_INITIALIZED
andAPI_UNAVAILABLE
.The returned function pointer is valid until the library is terminated.
This function may be called from any thread.
- Parameters:
instance
- the Vulkan instance to query, orNULL
to retrieve functions related to instance creationprocname
- the ASCII encoded name of the function- Returns:
- the address of the function, or
NULL
if an error occurred - Since:
- version 3.2
-
glfwGetInstanceProcAddress
Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set toNULL
it can return any function exported from the Vulkan loader, including at least the following functions:VK10.vkEnumerateInstanceExtensionProperties(java.nio.ByteBuffer, java.nio.IntBuffer, org.lwjgl.vulkan.VkExtensionProperties.Buffer)
VK10.vkEnumerateInstanceLayerProperties(java.nio.IntBuffer, org.lwjgl.vulkan.VkLayerProperties.Buffer)
VK10.vkCreateInstance(org.lwjgl.vulkan.VkInstanceCreateInfo, org.lwjgl.vulkan.VkAllocationCallbacks, org.lwjgl.PointerBuffer)
VK10.vkGetInstanceProcAddr(org.lwjgl.vulkan.VkInstance, java.nio.ByteBuffer)
If Vulkan is not available on the machine, this function returns
NULL
and generates aAPI_UNAVAILABLE
error. CallVulkanSupported
to check whether Vulkan is available.This function is equivalent to calling
VK10.vkGetInstanceProcAddr(org.lwjgl.vulkan.VkInstance, java.nio.ByteBuffer)
with a platform-specific query of the Vulkan loader as a fallback.Possible errors include
NOT_INITIALIZED
andAPI_UNAVAILABLE
.The returned function pointer is valid until the library is terminated.
This function may be called from any thread.
- Parameters:
instance
- the Vulkan instance to query, orNULL
to retrieve functions related to instance creationprocname
- the ASCII encoded name of the function- Returns:
- the address of the function, or
NULL
if an error occurred - Since:
- version 3.2
-
glfwGetPhysicalDevicePresentationSupport
public static boolean glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, int queuefamily) Returns whether the specified queue family of the specified physical device supports presentation to the platform GLFW was built for.If Vulkan or the required window surface creation instance extensions are not available on the machine, or if the specified instance was not created with the required extensions, this function returns
FALSE
and generates aAPI_UNAVAILABLE
error. CallVulkanSupported
to check whether Vulkan is available andGetRequiredInstanceExtensions
to check what instance extensions are required.Possible errors include
NOT_INITIALIZED
,API_UNAVAILABLE
andPLATFORM_ERROR
.macOS: This function currently always returns
TRUE
, as theVK_MVK_macos_surface
andVK_EXT_metal_surface
extensions do not provide avkGetPhysicalDevice*PresentationSupport
type function.This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.
-
nglfwCreateWindowSurface
public static int nglfwCreateWindowSurface(long instance, long window, long allocator, long surface) Unsafe version of:CreateWindowSurface
-
glfwCreateWindowSurface
public static int glfwCreateWindowSurface(VkInstance instance, long window, @Nullable VkAllocationCallbacks allocator, LongBuffer surface) Creates a Vulkan surface for the specified window.If the Vulkan loader was not found at initialization, this function returns
VK10.VK_ERROR_INITIALIZATION_FAILED
and generates aAPI_UNAVAILABLE
error. CallVulkanSupported
to check whether the Vulkan loader was found.If the required window surface creation instance extensions are not available or if the specified instance was not created with these extensions enabled, this function returns
VK10.VK_ERROR_EXTENSION_NOT_PRESENT
and generates aAPI_UNAVAILABLE
error. CallGetRequiredInstanceExtensions
to check what instance extensions are required.The window surface cannot be shared with another API so the window must have been created with the client api hint set to
NO_API
otherwise it generates aINVALID_VALUE
error and returnsKHRSurface.VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
.The window surface must be destroyed before the specified Vulkan instance. It is the responsibility of the caller to destroy the window surface. GLFW does not destroy it for you. Call
KHRSurface.vkDestroySurfaceKHR(org.lwjgl.vulkan.VkInstance, long, org.lwjgl.vulkan.VkAllocationCallbacks)
to destroy the surface.Possible errors include
NOT_INITIALIZED
,API_UNAVAILABLE
,PLATFORM_ERROR
andINVALID_VALUE
.If an error occurs before the creation call is made, GLFW returns the Vulkan error code most appropriate for the error. Appropriate use of
VulkanSupported
andglfwGetRequiredInstanceExtensions
should eliminate almost all occurrences of these errors.Notes:
- This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.
- macOS: GLFW prefers the
VK_EXT_metal_surface
extension, with theVK_MVK_macos_surface
extension as a fallback. The name of the selected extension, if any, is included in the array returned byglfwGetRequiredInstanceExtensions
. - macOS: This function creates and sets a
CAMetalLayer
instance for the window content view, which is required for MoltenVK to function. - x11: By default GLFW prefers the
VK_KHR_xcb_surface
extension, with theVK_KHR_xlib_surface
extension as a fallback. You can makeVK_KHR_xlib_surface
the preferred extension by setting theX11_XCB_VULKAN_SURFACE
init hint. The name of the selected extension, if any, is included in the array returned byglfwGetRequiredInstanceExtensions
.
- Parameters:
instance
- the Vulkan instance to create the surface inwindow
- the window to create the surface forallocator
- the allocator to use, orNULL
to use the default allocator.surface
- where to store the handle of the surface. This is set toVK10.VK_NULL_HANDLE
if an error occurred.- Returns:
VK10.VK_SUCCESS
if successful, or a Vulkan error code if an error occurred- Since:
- version 3.2
-
glfwCreateWindowSurface
public static int glfwCreateWindowSurface(VkInstance instance, long window, @Nullable VkAllocationCallbacks allocator, long[] surface) Array version of:CreateWindowSurface
-
setPath
CallssetPath(String)
with the path of the specifiedSharedLibrary
.Example usage:
GLFWVulkan.setPath(VK.getFunctionProvider());
- Parameters:
sharedLibrary
- aFunctionProvider
instance that will be cast toSharedLibrary
-
setPath
Overrides the Vulkan shared library that GLFW loads internally.This is useful when there's a mismatch between the shared libraries loaded by LWJGL and GLFW.
This method must be called before GLFW initializes Vulkan. The override is available only in the default GLFW build bundled with LWJGL. Using the override with a custom GLFW build will produce a warning in
DEBUG
mode (but not an error).- Parameters:
path
- the Vulkan shared library path, ornull
to remove the override.
-