No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
justindriggers Merge pull request #2 from justindriggers/memoryAllocation
Implement memory allocation/mapping and Buffers
Latest commit cce8549 Sep 18, 2018

README.md

License

Vulkan Java API

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.

Disclaimer

This library is a work-in-progress, and the API is incomplete. Contributions and feedback are welcome and appreciated.

But why?

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.

Concepts

  • Vulkan APIs that begin with vkCreate are covered by Java Object instantiation.
    • The vkCreateSemaphore function (which requires a VkDevice) is invoked simply by constructing a new Semaphore(device).
  • Vulkan APIs that begin with vkDestroy are invoked by implementing the AutoCloseable interface.
    • The vkDestroySemaphore function is invoked by calling semaphore.close(), or using a try-with-resources block.
  • Vulkan APIs that act on a specific parameter are implemented as methods on the corresponding object.
    • The vkDeviceWaitIdle function (which requires a VkDevice) is invoked by calling device.waitIdle().

Getting Started

build.gradle

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")
   }
}

Example

Check out https://github.com/justindriggers/vulkan-java-api-example for a more comprehensive usage example.