Top Description Inners Constructors Methods
org.lwjgl.glfw

public Class GLFWVulkan

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.*, org.lwjgl.system.*, org.lwjgl.vulkan.*

Native bindings to the GLFW library's Vulkan functions.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
GLFWVulkan.Functions

Contains the function pointers loaded from GLFW.getLibrary().

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

VK10#VK_SUCCESS if successful, or a Vulkan error code if an error occurred
glfwCreateWindowSurface
(VkInstance
the Vulkan instance to create the surface in
instance
,
long
the window to create the surface for
window
,
VkAllocationCallbacks
the allocator to use, or NULL to use the default allocator.
allocator
,
LongBuffer
where to store the handle of the surface. This is set to VK10#VK_NULL_HANDLE if an error occurred.
surface
)

Creates a Vulkan surface for the specified window.

public static int
glfwCreateWindowSurface(VkInstance instance, long window, VkAllocationCallbacks allocator, long[] surface)

Array version of: CreateWindowSurface

public static long

Returns:

the address of the function, or NULL if an error occurred
glfwGetInstanceProcAddress
(VkInstance
the Vulkan instance to query, or NULL to retrieve functions related to instance creation
instance
,
ByteBuffer
the ASCII encoded name of the function
procname
)

Returns the address of the specified Vulkan core or extension function for the specified instance.

public static long

Returns:

the address of the function, or NULL if an error occurred
glfwGetInstanceProcAddress
(VkInstance
the Vulkan instance to query, or NULL to retrieve functions related to instance creation
instance
,
CharSequence
the ASCII encoded name of the function
procname
)

Returns the address of the specified Vulkan core or extension function for the specified instance.

public static boolean

Returns:

TRUE if the queue family supports presentation, or FALSE otherwise
glfwGetPhysicalDevicePresentationSupport
(VkInstance
the instance that the physical device belongs to
instance
,
VkPhysicalDevice
the physical device that the queue family belongs to
device
,
int
the index of the queue family to query
queuefamily
)

Returns whether the specified queue family of the specified physical device supports presentation to the platform GLFW was built for.

public static PointerBuffer

Returns:

an array of ASCII encoded extension names, or NULL if an error occurred
glfwGetRequiredInstanceExtensions
()

Returns an array of names of Vulkan instance extensions required by GLFW for creating Vulkan surfaces for GLFW windows.

public static void
glfwInitVulkanLoader(long
the address of the function to use, or NULL
loader
)

Sets the desired Vulkan vkGetInstanceProcAddr function.

public static boolean

Returns:

TRUE if Vulkan is available, or FALSE otherwise
glfwVulkanSupported
()

Returns whether the Vulkan loader has been found.

public static int
nglfwCreateWindowSurface(long instance, long window, long allocator, long surface)

Unsafe version of: CreateWindowSurface

public static long
nglfwGetInstanceProcAddress(long instance, long procname)

Unsafe version of: GetInstanceProcAddress

public static long
nglfwGetRequiredInstanceExtensions(long
where to store the number of extensions in the returned array. This is set to zero if an error occurred.
count
)

Unsafe version of: GetRequiredInstanceExtensions

public static void
setPath(FunctionProvider
a FunctionProvider instance that will be cast to SharedLibrary
sharedLibrary
)

Calls setPath(String) with the path of the specified SharedLibrary.

public static void
setPath(String
the Vulkan shared library path, or null to remove the override.
path
)

Overrides the Vulkan shared library that GLFW loads internally.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

GLFWVulkanback to summary
protected GLFWVulkan()

Method Detail

glfwCreateWindowSurfaceback to summary
public static int glfwCreateWindowSurface(VkInstance instance, long window, 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 a API_UNAVAILABLE error. Call VulkanSupported 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 a API_UNAVAILABLE error. Call GetRequiredInstanceExtensions 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 a INVALID_VALUE error and returns KHRSurface#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 to destroy the surface.

Possible errors include NOT_INITIALIZED, API_UNAVAILABLE, PLATFORM_ERROR and INVALID_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 and glfwGetRequiredInstanceExtensions 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 the VK_MVK_macos_surface extension as a fallback. The name of the selected extension, if any, is included in the array returned by glfwGetRequiredInstanceExtensions.
  • 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 the VK_KHR_xlib_surface extension as a fallback. You can make VK_KHR_xlib_surface the preferred extension by setting the X11_XCB_VULKAN_SURFACE init hint. The name of the selected extension, if any, is included in the array returned by glfwGetRequiredInstanceExtensions.
Parameters
instance:VkInstance

the Vulkan instance to create the surface in

window:long

the window to create the surface for

allocator:VkAllocationCallbacks

the allocator to use, or NULL to use the default allocator.

surface:LongBuffer

where to store the handle of the surface. This is set to VK10#VK_NULL_HANDLE if an error occurred.

Returns:int

VK10#VK_SUCCESS if successful, or a Vulkan error code if an error occurred

Annotations
@NativeType:VkResult
Since
version 3.2
glfwCreateWindowSurfaceback to summary
public static int glfwCreateWindowSurface(VkInstance instance, long window, VkAllocationCallbacks allocator, long[] surface)

Array version of: CreateWindowSurface

Annotations
@NativeType:VkResult
glfwGetInstanceProcAddressback to summary
public static long glfwGetInstanceProcAddress(VkInstance instance, ByteBuffer procname)

Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to NULL it can return any function exported from the Vulkan loader, including at least the following functions:

If Vulkan is not available on the machine, this function returns NULL and generates a API_UNAVAILABLE error. Call VulkanSupported to check whether Vulkan is available.

This function is equivalent to calling VK10#vkGetInstanceProcAddr with a platform-specific query of the Vulkan loader as a fallback.

Possible errors include NOT_INITIALIZED and API_UNAVAILABLE.

The returned function pointer is valid until the library is terminated.

This function may be called from any thread.

Parameters
instance:VkInstance

the Vulkan instance to query, or NULL to retrieve functions related to instance creation

procname:ByteBuffer

the ASCII encoded name of the function

Returns:long

the address of the function, or NULL if an error occurred

Annotations
@NativeType:GLFWvkproc
Since
version 3.2
glfwGetInstanceProcAddressback to summary
public static long glfwGetInstanceProcAddress(VkInstance instance, CharSequence procname)

Returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to NULL it can return any function exported from the Vulkan loader, including at least the following functions:

If Vulkan is not available on the machine, this function returns NULL and generates a API_UNAVAILABLE error. Call VulkanSupported to check whether Vulkan is available.

This function is equivalent to calling VK10#vkGetInstanceProcAddr with a platform-specific query of the Vulkan loader as a fallback.

Possible errors include NOT_INITIALIZED and API_UNAVAILABLE.

The returned function pointer is valid until the library is terminated.

This function may be called from any thread.

Parameters
instance:VkInstance

the Vulkan instance to query, or NULL to retrieve functions related to instance creation

procname:CharSequence

the ASCII encoded name of the function

Returns:long

the address of the function, or NULL if an error occurred

Annotations
@NativeType:GLFWvkproc
Since
version 3.2
glfwGetPhysicalDevicePresentationSupportback to summary
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 a API_UNAVAILABLE error. Call VulkanSupported to check whether Vulkan is available and GetRequiredInstanceExtensions to check what instance extensions are required.

Possible errors include NOT_INITIALIZED, API_UNAVAILABLE and PLATFORM_ERROR.

macOS: This function currently always returns TRUE, as the VK_MVK_macos_surface and VK_EXT_metal_surface extensions do not provide a vkGetPhysicalDevice*PresentationSupport type function.

This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.

Parameters
instance:VkInstance

the instance that the physical device belongs to

device:VkPhysicalDevice

the physical device that the queue family belongs to

queuefamily:int

the index of the queue family to query

Returns:boolean

TRUE if the queue family supports presentation, or FALSE otherwise

Annotations
@NativeType:int
Since
version 3.2
glfwGetRequiredInstanceExtensionsback to summary
public static PointerBuffer 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 contain VK_KHR_surface, so if you don't require any additional extensions you can pass this list directly to the VkInstanceCreateInfo struct.

If Vulkan is not available on the machine, this function returns NULL and generates a API_UNAVAILABLE error. Call VulkanSupported 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 and API_UNAVAILABLE.

Returns:PointerBuffer

an array of ASCII encoded extension names, or NULL if an error occurred

Annotations
@Nullable
@NativeType:char const **
Since
version 3.2
glfwInitVulkanLoaderback to summary
public static void glfwInitVulkanLoader(long loader)

Sets the desired Vulkan vkGetInstanceProcAddr 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 and libvulkan.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:long

the address of the function to use, or NULL

Since
version 3.4
glfwVulkanSupportedback to summary
public static boolean glfwVulkanSupported()

Returns whether the Vulkan loader has been found. This check is performed by Init.

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 and GetPhysicalDevicePresentationSupport 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.

Returns:boolean

TRUE if Vulkan is available, or FALSE otherwise

Annotations
@NativeType:int
Since
version 3.2
nglfwCreateWindowSurfaceback to summary
public static int nglfwCreateWindowSurface(long instance, long window, long allocator, long surface)

Unsafe version of: CreateWindowSurface

nglfwGetInstanceProcAddressback to summary
public static long nglfwGetInstanceProcAddress(long instance, long procname)

Unsafe version of: GetInstanceProcAddress

nglfwGetRequiredInstanceExtensionsback to summary
public static long nglfwGetRequiredInstanceExtensions(long count)

Unsafe version of: GetRequiredInstanceExtensions

Parameters
count:long

where to store the number of extensions in the returned array. This is set to zero if an error occurred.

setPathback to summary
public static void setPath(FunctionProvider sharedLibrary)

Calls setPath(String) with the path of the specified SharedLibrary.

Example usage: GLFWVulkan.setPath(VK.getFunctionProvider());

Parameters
sharedLibrary:FunctionProvider

a FunctionProvider instance that will be cast to SharedLibrary

setPathback to summary
public static void setPath(String path)

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:String

the Vulkan shared library path, or null to remove the override.

org.lwjgl.glfw back to summary

public final Class GLFWVulkan.Functions

extends Object
Class Inheritance

Contains the function pointers loaded from GLFW.getLibrary().

Field Summary

Modifier and TypeField and Description
public static final long
CreateWindowSurface

Function address.

public static final long
GetInstanceProcAddress

Function address.

public static final long
public static final long
public static final long
InitVulkanLoader

Function address.

public static final long
VulkanSupported

Function address.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CreateWindowSurfaceback to summary
public static final long CreateWindowSurface

Function address.

GetInstanceProcAddressback to summary
public static final long GetInstanceProcAddress

Function address.

GetPhysicalDevicePresentationSupportback to summary
public static final long GetPhysicalDevicePresentationSupport

Function address.

GetRequiredInstanceExtensionsback to summary
public static final long GetRequiredInstanceExtensions

Function address.

InitVulkanLoaderback to summary
public static final long InitVulkanLoader

Function address.

VulkanSupportedback to summary
public static final long VulkanSupported

Function address.

Constructor Detail

Functionsback to summary
private Functions()