{"id":33108117,"url":"https://github.com/kotlin-graphics/vkk","last_synced_at":"2026-01-12T06:38:01.692Z","repository":{"id":65425973,"uuid":"132931904","full_name":"kotlin-graphics/vkk","owner":"kotlin-graphics","description":"VK², Kotlin Wrapper for Vulkan: code expressiveness and safety meet graphic power","archived":false,"fork":false,"pushed_at":"2022-12-02T10:08:57.000Z","size":2237,"stargazers_count":125,"open_issues_count":2,"forks_count":7,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-06-21T06:38:24.329Z","etag":null,"topics":["lwjgl","vulkan","vulkan-library","vulkan-sdk","vulkan-utils"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kotlin-graphics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-10T17:16:08.000Z","updated_at":"2024-06-13T15:26:02.000Z","dependencies_parsed_at":"2023-01-23T10:55:24.085Z","dependency_job_id":null,"html_url":"https://github.com/kotlin-graphics/vkk","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/kotlin-graphics/vkk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kotlin-graphics%2Fvkk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kotlin-graphics%2Fvkk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kotlin-graphics%2Fvkk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kotlin-graphics%2Fvkk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kotlin-graphics","download_url":"https://codeload.github.com/kotlin-graphics/vkk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kotlin-graphics%2Fvkk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285299189,"owners_count":27148079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lwjgl","vulkan","vulkan-library","vulkan-sdk","vulkan-utils"],"created_at":"2025-11-15T00:00:35.754Z","updated_at":"2025-11-19T18:01:05.601Z","avatar_url":"https://github.com/kotlin-graphics.png","language":"Kotlin","funding_links":[],"categories":["Bindings"],"sub_categories":[],"readme":"# VK², Kotlin Wrapper for Vulkan\n\n[![Build Status](https://github.com/kotlin-graphics/vkk/workflows/build/badge.svg)](https://github.com/kotlin-graphics/vkk/actions?workflow=build)\n[![license](https://img.shields.io/badge/License-Apache%202.0-orange.svg)](https://github.com/kotlin-graphics/vkk/blob/master/LICENSE) \n[![Release](https://jitpack.io/v/kotlin-graphics/vkk.svg)](https://jitpack.io/#kotlin-graphics/vkk) \n![Size](https://github-size-badge.herokuapp.com/kotlin-graphics/vkk.svg)\n[![Github All Releases](https://img.shields.io/github/downloads/kotlin-graphics/vkk/total.svg)]()\n\nThe goal of the VK² is to provide a library for the Vulkan C API to improve the developers Vulkan experience without introducing \nany considerable CPU runtime cost. It adds features like type safety for enums and bitfields, collection support, exceptions and simple enumerations.\n\nStrongly inspired by [Vulkan hpp](https://github.com/KhronosGroup/Vulkan-Hpp), it's shaped on the Sasha examples [port](https://github.com/java-opengl-labs/Vulkan). It's the Vulkan counterpart of the OpenGL [gln](https://github.com/kotlin-graphics/gln/).\n\nSee it in action [here](https://github.com/jvm-graphics-labs/Vulkan)!\n\n### How to retrieve it:\n\nYou can find all the instructions by [mary](https://github.com/kotlin-graphics/mary)\n\n## Usage\n\n### vk `object`\n\nTo avoid name collisions with the lwjgl Vulkan bindings, the VK² wrapper resides mostly under the `object vk`. The following rules apply to the new naming\n\n* All functions, extension functions, and structs have the Vk prefix removed. In addition to this the first letter of functions is lower case.\n  * `VkCreateImage` can be accessed as `vk.createImage`\n  * `VkImageTiling` can be accessed as `vk.ImageTiling`\n  * `VkImageCreateInfo` can be accessed as `vk.ImageCreateInfo`\n* Enums are mapped to scoped enums to provide compile time type safety. The names have been changed to have the Enum Base in CamelCase with the VK_ prefix and the enum name in Capital letters (corresponding to the original counterpart). Enums starting with a number requires ~to be surrounded by backticks~ the underscore prefix `_`, this because Idea handles backticks this very poorly.\n\nSome examples:\n  - `VK_COLOR_SPACE_SRGB_NONLINEAR_KHR` is now `VkColorSpace.SRGB_NONLINEAR_KHR`\n  - `VK_IMAGETYPE_2D` is now ``VkImageType._2D ``\n\n* Flag bits are handled like scoped enums with the addition that the `_BIT` suffix has also been removed.\n\n### Extension functions\n\nThis is one case where Kotlin really shines: VK² declares a class for all handles to ensure full type safety and to add support for member functions on handles. A member function has been added to a handle class for each function which accepts the corresponding handle as first parameter. Instead of `vkBindBufferMemory(device, ...)` one can write `device.bindBufferMemory(...)`.\n\n### Mask Flags\n\nAll flags masks have been `typealias`ed accordingly. For example a field of type `VkBufferUsageFlags` means that it represents a mask from the `VkBufferUsage.` enum.\nThe postfix `Flag` has been eliminated from the enum name for conciseness matter. However, it has been kept for some special cases, such as `VkQueueFlag`, to avoid clashes with existing other structures, in this case the `VkQueue` class for example.\n\n### CreateInfo structs and appBuffer\n\nWhen constructing a handle in Vulkan one usually has to create some `CreateInfo` struct which describes the new handle. Moreover, allocation has to be handled manually and everywhere C code uses pointers, we have to use buffers on the JVM. \nThis can result in quite lengthy code as can be seen in the following Vulkan example:\n\n```kotlin\nval info = VkImageCreateInfo.calloc()\n    .sType(VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO)\n    .pNext(null)\n    .flags(...some flags...)\n    .imageType(VK_IMAGE_TYPE_2D)\n    .format(VK_FORMAT_R8G8B8A8_UNORM)\n    .extent().apply {\n        .width(size.x)\n        .height(size.y)\n        .depth(1)\n    }\n    .mipLevels(1)\n    .arrayLayers(1)\n    .samples(VK_SAMPLE_COUNT_1_BIT)\n    .tiling(VK_IMAGE_TILING_OPTIMAL)\n    .usage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)\n    .sharingMode(VK_SHARING_MODE_EXCLUSIVE)\n    .pQueueFamilyIndices(null)\n    .initialLayout(VK_IMAGE_LAYOUT_UNDEFINED)\nval pImage = MemoryUtil.memAllocLong(1)\nvkCreateImage(device, info, allocator, pImage)\nimage = pImage.get(0)\ninfo.free()\nmemFree(pImage)\n```\n\nOne typical issue Vulkan developers encounter when filling out a CreateInfo struct field by field is that `sType` is incorrect.\n\nVK² provides constructors for all CreateInfo objects (and others) where `sType` is automatically filled with the correct value and `pNext` set to a `nullptr` by default. All other field are also initialized to zero. There are exceptions though.\n\nMoreover, all the allocations takes place in the thread local memory, using the lwjgl `MemoryStack` class.\n\nVK² provides also special method accepting glm classes, like `extent` accepting a `(Vec3i)` or `(Vec2i, Int)`.\nHere's how the same code looks with a constructor:\n\n```kotlin\nval info = vk.ImageCreateInfo {\n    flags = ...some flags...\n    imageType = VkImageType.`2D`\n    format = VkFormat.R8G8B8A8_UNORM\n    extent(size, 1)\n    mipLevels = 1\n    arrayLayers = 1\n    samples = VkSampleCount.`1_BIT`\n    tiling = VkImageTiling.OPTIMAL\n    usage = VkImageUsage.COLOR_ATTACHMENT_BIT.i\n    sharingMode = VkSharingMode.EXCLUSIVE\n}\nimage = device createImage info\n```\n\nErrors will be checked automatically in debug mode, but you can set `DEBUG` explicitely as you wish.\nIn case `VULKAN_NO_EXCEPTIONS` is `true`, errors will be reported in the `System.err` stream, otherwise the exception to the corresponding error will be thrown.\n\nTODO","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin-graphics%2Fvkk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkotlin-graphics%2Fvkk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin-graphics%2Fvkk/lists"}