Skip to content

Commit

Permalink
02 with Bufferizable
Browse files Browse the repository at this point in the history
  • Loading branch information
elect86 committed May 6, 2018
1 parent b3a9209 commit 6780942
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"

compile 'com.github.kotlin-graphics:uno-sdk:fc67ccf36c7da5baffa41efab4c5911be41c9c77'
compile 'com.github.kotlin-graphics:assimp:0c7d00d227e8fd2fdb04bc6916dbee60df051026'
compile 'com.github.kotlin-graphics:assimp:c224cf47516bc91a848a4dea88bf82d5327074a0'
implementation 'com.github.kotlin-graphics:imgui:b721ceaf260a47fa3623ab8d780ecfbe3510ec21'

ext.spirvCrossVersion = "0.4.0"
Expand Down
15 changes: 3 additions & 12 deletions src/main/kotlin/vulkan/basics/02 Pipelines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,12 @@ private class Pipelines : VulkanExampleBase() {
val uniformBuffer = Buffer()

/** Same uniform buffer layout as shader */
object uboVS {
object uboVS : Bufferizable() {
var projection = Mat4()
var modelView = Mat4()
val lightPos = Vec4(0f, 2f, 1f, 0f)

fun pack() {
projection to buffer
modelView.to(buffer, Mat4.size)
lightPos.to(buffer, Mat4.size * 2)
}

val size = Mat4.size * 2 + Vec4.size
val buffer = bufferBig(size)
val address = memAddress(buffer)
override val fieldOrder = arrayOf("projection", "modelView", "lightPos")
}

var pipelineLayout: VkPipelineLayout = NULL
Expand Down Expand Up @@ -343,8 +335,7 @@ private class Pipelines : VulkanExampleBase() {
.rotateAssign(rotation.y.rad, 0f, 1f, 0f)
.rotateAssign(rotation.z.rad, 0f, 0f, 1f)

uboVS.pack()
memCopy(uboVS.address, uniformBuffer.mapped[0], uboVS.size.L)
uboVS to uniformBuffer.mapped[0]
}

fun draw() {
Expand Down

0 comments on commit 6780942

Please sign in to comment.