GLFWVulkan
relies on preview features of the Java platform:
GLFWVulkan
refers to one or more preview APIs:MemorySegment
.
- Since:
- 0.1.0
- Author:
- squid233
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
glfwCreateWindowSurface
(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW window, MemorySegmentPREVIEW allocator, long[] surface) Creates a Vulkan surface for the specified window.static MemorySegmentPREVIEW
glfwGetInstanceProcAddress
(MemorySegmentPREVIEW instance, String procName) Returns the address of the specified Vulkan instance function.static boolean
glfwGetPhysicalDevicePresentationSupport
(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW device, int queueFamily) Returns whether the specified queue family can present images.static int
nglfwCreateWindowSurface
(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW window, MemorySegmentPREVIEW allocator, MemorySegmentPREVIEW surface) Creates a Vulkan surface for the specified window.static MemorySegmentPREVIEW
nglfwGetInstanceProcAddress
(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW procName) Returns the address of the specified Vulkan instance function.
-
Method Details
-
nglfwGetInstanceProcAddress
public static MemorySegmentPREVIEW nglfwGetInstanceProcAddress(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW procName) Returns the address of the specified Vulkan instance function.This function returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to
NULL
PREVIEW it can return any function exported from the Vulkan loader, including at least the following functions:vkEnumerateInstanceExtensionProperties
vkEnumerateInstanceLayerProperties
vkCreateInstance
vkGetInstanceProcAddr
If Vulkan is not available on the machine, this function returns
NULL
PREVIEW and generates aAPI_UNAVAILABLE
error. CallvulkanSupported
to check whether Vulkan is at least minimally available.This function is equivalent to calling
vkGetInstanceProcAddr
with a platform-specific query of the Vulkan loader as a fallback.- Parameters:
instance
- The Vulkan instance to query, orNULL
PREVIEW to retrieve functions related to instance creation.procName
- The ASCII encoded name of the function.- Returns:
- The address of the function, or
NULL
PREVIEW if an error occurred. - Errors:
- Possible errors include
NOT_INITIALIZED
andAPI_UNAVAILABLE
. - Thread safety:
- This function may be called from any thread.
- Pointer lifetime:
- The returned function pointer is valid until the library is terminated.
-
glfwGetInstanceProcAddress
public static MemorySegmentPREVIEW glfwGetInstanceProcAddress(MemorySegmentPREVIEW instance, String procName) Returns the address of the specified Vulkan instance function. -
glfwGetPhysicalDevicePresentationSupport
public static boolean glfwGetPhysicalDevicePresentationSupport(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW device, int queueFamily) Returns whether the specified queue family can present images.This function 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 at least minimally available andgetRequiredInstanceExtensions
PREVIEW to check what instance extensions are required.- Parameters:
instance
- The instance that the physical device belongs to.device
- The physical device that the queue family belongs to.queueFamily
- The index of the queue family to query.- Returns:
true
if the queue family supports presentation, orfalse
otherwise.- Errors:
- Possible errors include
NOT_INITIALIZED
,API_UNAVAILABLE
andPLATFORM_ERROR
. - Remarks:
- macOS: This function currently always returns
true
, as theVK_MVK_macos_surface
andVK_EXT_metal_surface
extensions do not provide avkGetPhysicalDevice*PresentationSupport
type function. - Thread safety:
- This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.
-
nglfwCreateWindowSurface
public static int nglfwCreateWindowSurface(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW window, MemorySegmentPREVIEW allocator, MemorySegmentPREVIEW surface) Creates a Vulkan surface for the specified window.This function creates a Vulkan surface for the specified window.
If the Vulkan loader or at least one minimally functional ICD were not found, this function returns
VK_ERROR_INITIALIZATION_FAILED
and generates aAPI_UNAVAILABLE
error. CallvulkanSupported
to check whether Vulkan is at least minimally available.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
VK_ERROR_EXTENSION_NOT_PRESENT
and generates aAPI_UNAVAILABLE
error. CallgetRequiredInstanceExtensions
PREVIEW 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 toNO_API
otherwise it generates aINVALID_VALUE
error and returnsVK_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
vkDestroySurfaceKHR
to destroy the surface.- Parameters:
instance
- The Vulkan instance to create the surface in.window
- The window to create the surface for.allocator
- The allocator to use, orNULL
PREVIEW to use the default allocator.surface
- Where to store the handle of the surface. This is set toVK_NULL_HANDLE
if an error occurred.- Returns:
VK_SUCCESS
if successful, or a Vulkan error code if an error occurred.- See Also:
- Errors:
- Possible errors include
NOT_INITIALIZED
,API_UNAVAILABLE
,PLATFORM_ERROR
andINVALID_VALUE
. - Remarks:
- 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
andgetRequiredInstanceExtensions
PREVIEW should eliminate almost all occurrences of these errors.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 bygetRequiredInstanceExtensions
PREVIEW.macOS: This function creates and sets a
CAMetalLayer
instance for the window content view, which is required for MoltenVK to function. - Thread safety:
- This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.
-
glfwCreateWindowSurface
public static int glfwCreateWindowSurface(MemorySegmentPREVIEW instance, MemorySegmentPREVIEW window, MemorySegmentPREVIEW allocator, long[] surface) Creates a Vulkan surface for the specified window.- Parameters:
instance
- The Vulkan instance to create the surface in.window
- The window to create the surface for.allocator
- The allocator to use, orNULL
PREVIEW to use the default allocator.surface
- Where to store the handle of the surface. This is set toVK_NULL_HANDLE
if an error occurred.- Returns:
VK_SUCCESS
if successful, or a Vulkan error code if an error occurred.- See Also:
-
GLFWVulkan
when preview features are enabled.