The Vulkan Java API is an object-oriented Java library, backed by the Lightweight Java Game Library Vulkan API. The Java API aims to encapsulate the complexities of struct construction and memory management into classes that are more easily understood by those uncomfortable with such concepts.
This library is a work-in-progress, and the API is incomplete. Contributions and feedback are welcome and appreciated.
The original goal behind writing this library was, first and foremost, to familiarize myself with the Vulkan API.
However, this library does have a lot of potential for the future:
- Apple recently deprecated OpenGL, pushing developers to use Metal instead.
- KhronosGroup released MoltenVK, providing a Vulkan-to-Metal compatibility layer for Apple systems.
- It is unlikely that libGDX (the most prominent Java-based game library at the time of this writing) will support Vulkan any time soon.
- Vulkan APIs that begin with
vkCreate
are covered by Java Object instantiation.- The
vkCreateSemaphore
function (which requires aVkDevice
) is invoked simply by constructing anew Semaphore(device)
.
- The
- Vulkan APIs that begin with
vkDestroy
are invoked by implementing theAutoCloseable
interface.- The
vkDestroySemaphore
function is invoked by callingsemaphore.close()
, or using atry-with-resources
block.
- The
- Vulkan APIs that act on a specific parameter are implemented as methods on the corresponding object.
- The
vkDeviceWaitIdle
function (which requires aVkDevice
) is invoked by callingdevice.waitIdle()
.
- The
import org.gradle.internal.os.OperatingSystem
project.ext.lwjglVersion = "3.2.0"
project.ext.hasVulkanNatives = false
switch (OperatingSystem.current()) {
case OperatingSystem.WINDOWS:
project.ext.lwjglNatives = "natives-windows"
break
case OperatingSystem.LINUX:
project.ext.lwjglNatives = "natives-linux"
break
case OperatingSystem.MAC_OS:
project.ext.lwjglNatives = "natives-macos"
project.ext.hasVulkanNatives = true
break
}
repositories {
mavenCentral()
maven {
url = 'https://dl.bintray.com/justindriggers/vulkan-java-api'
}
}
dependencies {
implementation('com.justindriggers:vulkan-java-api:0.+')
implementation("org.lwjgl:lwjgl:$lwjglVersion:$lwjglNatives")
implementation("org.lwjgl:lwjgl-glfw:$lwjglVersion:$lwjglNatives")
if (project.ext.hasVulkanNatives) {
implementation("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$lwjglNatives")
}
}
Check out https://github.com/justindriggers/vulkan-java-api-example for a more comprehensive usage example.