Skip to content

Commit c74defd

Browse files
committed
v0.7.4
fixed kool dependencies commented out vk stuff for the moment bump up: - kotlin 1.2.70 - gradle 4.10.2 - gln
1 parent 154a92b commit c74defd

File tree

11 files changed

+80
-88
lines changed

11 files changed

+80
-88
lines changed

build.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ group = 'com.github.kotlin-graphics'
1212

1313
buildscript {
1414

15-
ext.kotlinVersion = '1.2.60'
15+
ext.kotlinVersion = '1.2.70'
1616

1717
repositories {
1818
mavenCentral()
@@ -23,7 +23,7 @@ buildscript {
2323
dependencies {
2424
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
2525
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
26-
classpath "org.junit.platform:junit-platform-gradle-plugin:1.1.0"
26+
classpath "org.junit.platform:junit-platform-gradle-plugin:1.2.0"
2727
}
2828
}
2929

@@ -36,12 +36,11 @@ dependencies {
3636
implementation "$kotlin-reflect:$kotlinVersion"
3737

3838
ext.kx = "com.github.kotlin-graphics"
39-
implementation "$kx:gln:820ec8bca2"
40-
implementation "$kx:vkk:86fe39a"
41-
implementation "$kx:appBuffer:39d8216"
39+
implementation "$kx:gln:1e35c8c7a5f0f1e61a77f0a2cb803111da5ef4df"
40+
// implementation "$kx:vkk:86fe39a"
41+
// implementation "$kx:appBuffer:39d8216"
4242

43-
testImplementation 'io.kotlintest:kotlintest:2.0.7'
44-
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.0.6'
43+
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.1.10'
4544

4645
// ext.jogl = "2.3.2"
4746
// compile "org.jogamp.gluegen:gluegen-rt:$jogl"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

src/main/kotlin/uno/buffer/buffer.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package uno.buffer
22

33

4-
import glm_.BYTES
5-
import glm_.buffer.*
4+
import kool.*
65
import org.lwjgl.PointerBuffer
76
import org.lwjgl.system.MemoryUtil
87
import uno.kotlin.Quadruple

src/main/kotlin/uno/buffer/of.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package uno.buffer
22

33
import glm_.BYTES
4-
import glm_.buffer.bufferBig
5-
import glm_.buffer.floatBufferBig
6-
import glm_.buffer.intBufferBig
4+
import kool.bufferBig
5+
import kool.floatBufferBig
6+
import kool.intBufferBig
77
import glm_.i
88
import glm_.set
99
import glm_.vec2.Vec2

src/main/kotlin/uno/caps/caps.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package uno.caps
22

3-
import glm_.buffer.cap
4-
import glm_.buffer.intBufferBig
3+
import kool.cap
4+
import kool.intBufferBig
55
import glm_.vec2.Vec2
66
import gln.checkError
77
import gln.glGetVec2

src/main/kotlin/uno/glfw/GlfwWindow.kt

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package uno.glfw
22

3-
import ab.appBuffer
3+
import glm_.BYTES
44
import glm_.bool
55
import glm_.f
66
import glm_.i
@@ -11,6 +11,7 @@ import glm_.vec4.Vec4i
1111
import gln.debug.GlDebugSeverity
1212
import gln.debug.GlDebugSource
1313
import gln.debug.GlDebugType
14+
import kool.stak
1415
import org.lwjgl.glfw.*
1516
import org.lwjgl.glfw.GLFW.*
1617
import org.lwjgl.opengl.GL
@@ -20,7 +21,6 @@ import org.lwjgl.system.Callback
2021
import org.lwjgl.system.MemoryStack
2122
import org.lwjgl.system.MemoryUtil.*
2223
import org.lwjgl.vulkan.VkInstance
23-
import uno.kotlin.first
2424
import uno.kotlin.getOrfirst
2525
import java.nio.ByteBuffer
2626
import java.nio.FloatBuffer
@@ -129,18 +129,18 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
129129
fun setSizeLimit(width: IntRange, height: IntRange) = glfwSetWindowSizeLimits(handle, width.start, height.start, width.endInclusive, height.endInclusive)
130130

131131
var pos = Vec2i()
132-
get() {
133-
val x = appBuffer.int
134-
val y = appBuffer.int
132+
get() = stak {
133+
val x = it.nmalloc(Int.BYTES * 2)
134+
val y = x + Int.BYTES
135135
nglfwGetWindowPos(handle, x, y)
136136
return field(memGetInt(x), memGetInt(y))
137137
}
138138
set(value) = glfwSetWindowPos(handle, value.x, value.y)
139139

140140
var size = Vec2i()
141-
get() {
142-
val x = appBuffer.int
143-
val y = appBuffer.int
141+
get() = stak {
142+
val x = it.nmalloc(Int.BYTES * 2)
143+
val y = x + Int.BYTES
144144
nglfwGetWindowSize(handle, x, y)
145145
return field(memGetInt(x), memGetInt(y))
146146
}
@@ -157,27 +157,27 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
157157
set(value) = glfwSetWindowAspectRatio(handle, value.x, value.y)
158158

159159
val framebufferSize = Vec2i()
160-
get() {
161-
val x = appBuffer.int
162-
val y = appBuffer.int
160+
get() = stak {
161+
val x = it.nmalloc(Int.BYTES * 2)
162+
val y = x + Int.BYTES
163163
nglfwGetFramebufferSize(handle, x, y)
164164
return field(memGetInt(x), memGetInt(y))
165165
}
166166

167167
val frameSize = Vec4i()
168-
get() {
169-
val x = appBuffer.int
170-
val y = appBuffer.int
171-
val z = appBuffer.int
172-
val w = appBuffer.int
168+
get() = stak {
169+
val x = it.nmalloc(Int.BYTES * 4)
170+
val y = x + Int.BYTES
171+
val z = y + Int.BYTES
172+
val w = z + Int.BYTES
173173
nglfwGetWindowFrameSize(handle, x, y, z, w)
174174
return field(memGetInt(x), memGetInt(y), memGetInt(z), memGetInt(w))
175175
}
176176

177177
val contentScale = Vec2()
178-
get() {
179-
val x = appBuffer.float
180-
val y = appBuffer.float
178+
get() = stak {
179+
val x = it.nmalloc(Float.BYTES * 2)
180+
val y = x + Float.BYTES
181181
nglfwGetWindowContentScale(handle, x, y)
182182
return field(memGetFloat(x), memGetFloat(y))
183183
}
@@ -247,9 +247,9 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
247247
}
248248

249249
var cursorPos = Vec2d()
250-
get() {
251-
val x = appBuffer.double
252-
val y = appBuffer.double
250+
get() = stak {
251+
val x = it.nmalloc(Double.BYTES * 2)
252+
val y = x + Double.BYTES
253253
nglfwGetCursorPos(handle, x, y)
254254
return field(memGetDouble(x), memGetDouble(y))
255255
}
@@ -354,7 +354,7 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
354354
// Event handlers are called by the GLFW callback mechanism and should not be called directly
355355
//
356356

357-
open fun onWindowResized(newSize: Vec2i) = appBuffer.reset()
357+
open fun onWindowResized(newSize: Vec2i) {}
358358
open fun onWindowClosed() {}
359359

360360
// Keyboard handling
@@ -413,8 +413,8 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
413413
val joystick3Buttons: ByteBuffer?
414414
get() = getJoystickButtons(GLFW_JOYSTICK_3)
415415

416-
fun getJoystickButtons(joystickId: Int): ByteBuffer? {
417-
val count = appBuffer.int
416+
fun getJoystickButtons(joystickId: Int): ByteBuffer? = stak {
417+
val count = it.nmalloc(Int.BYTES)
418418
val result = nglfwGetJoystickButtons(joystickId, count)
419419
return memByteBufferSafe(result, memGetInt(count))
420420
}
@@ -426,8 +426,8 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
426426
val joystick3Axes: FloatBuffer?
427427
get() = getJoystickAxes(GLFW_JOYSTICK_3)
428428

429-
fun getJoystickAxes(joystickId: Int): FloatBuffer? {
430-
val count = appBuffer.int
429+
fun getJoystickAxes(joystickId: Int): FloatBuffer? = stak {
430+
val count = it.nmalloc(Int.BYTES)
431431
val result = nglfwGetJoystickAxes(joystickId, count)
432432
return memFloatBufferSafe(result, memGetInt(count))
433433
}
@@ -445,16 +445,15 @@ open class GlfwWindow(var handle: GlfwWindowHandle) {
445445
inline fun loop(condition: () -> Boolean, block: (MemoryStack) -> Unit) {
446446
while (condition()) {
447447
glfwPollEvents()
448-
val stack = MemoryStack.stackGet()
449-
block(stack.push())
450-
if (autoSwap)
451-
glfwSwapBuffers(handle)
452-
stack.pop()
453-
appBuffer.reset() // TODO delete
448+
stak {
449+
block(it)
450+
if (autoSwap)
451+
glfwSwapBuffers(handle)
452+
}
454453
}
455454
}
456455

457-
infix fun createSurface(instance: VkInstance) = glfw.createWindowSurface(handle, instance)
456+
// infix fun createSurface(instance: VkInstance) = glfw.createWindowSurface(handle, instance)
458457

459458
fun swapBuffers() = glfwSwapBuffers(handle)
460459
inline fun present() = swapBuffers()

src/main/kotlin/uno/glfw/direct fields.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@ package uno.glfw
22

33
import glm_.vec2.Vec2i
44
import org.lwjgl.glfw.GLFWVidMode
5-
import vkk.adr
65

76

87
inline val GLFWVidMode.width: Int
9-
get() = GLFWVidMode.nwidth(adr)
8+
get() = GLFWVidMode.nwidth(address()) // TODO adr
109
inline val GLFWVidMode.height: Int
11-
get() = GLFWVidMode.nheight(adr)
10+
get() = GLFWVidMode.nheight(address())
1211
inline val GLFWVidMode.size: Vec2i
1312
get() = Vec2i(width, height)
1413
inline val GLFWVidMode.redBits: Int
15-
get() = GLFWVidMode.nredBits(adr)
14+
get() = GLFWVidMode.nredBits(address())
1615
inline val GLFWVidMode.greenBits: Int
17-
get() = GLFWVidMode.ngreenBits(adr)
16+
get() = GLFWVidMode.ngreenBits(address())
1817
inline val GLFWVidMode.blueBits: Int
19-
get() = GLFWVidMode.nblueBits(adr)
18+
get() = GLFWVidMode.nblueBits(address())
2019
inline val GLFWVidMode.refreshRate: Int
21-
get() = GLFWVidMode.nrefreshRate(adr)
20+
get() = GLFWVidMode.nrefreshRate(address())
2221

2322

2423
typealias HWND = Long

src/main/kotlin/uno/glfw/glfw.kt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package uno.glfw
22

3-
import ab.appBuffer
4-
import glm_.buffer.adr
3+
import kool.adr
54
import glm_.i
65
import glm_.vec2.Vec2i
6+
import kool.stak
77
import org.lwjgl.glfw.GLFW.*
88
import org.lwjgl.glfw.GLFWErrorCallback
99
import org.lwjgl.glfw.GLFWVidMode
@@ -15,9 +15,9 @@ import org.lwjgl.system.Platform
1515
import org.lwjgl.vulkan.VkInstance
1616
import uno.glfw.windowHint.Profile
1717
import uno.kotlin.parseInt
18-
import vkk.VK_CHECK_RESULT
19-
import vkk.VkSurfaceKHR
20-
import vkk.adr
18+
//import vkk.VK_CHECK_RESULT
19+
//import vkk.VkSurfaceKHR
20+
//import vkk.adr
2121
import java.util.function.BiPredicate
2222

2323
/**
@@ -85,7 +85,7 @@ object glfw {
8585
set(value) {
8686
if (value != null) {
8787
field = value
88-
nglfwSetErrorCallback(nErrorCallback.adr)
88+
nglfwSetErrorCallback(nErrorCallback.address()) // TODO adr
8989
} else
9090
nglfwSetErrorCallback(NULL)
9191
}
@@ -113,23 +113,23 @@ object glfw {
113113

114114
fun pollEvents() = glfwPollEvents()
115115

116-
val requiredInstanceExtensions: ArrayList<String>
117-
get() {
118-
val pCount = appBuffer.intBuffer
119-
val ppNames = GLFWVulkan.nglfwGetRequiredInstanceExtensions(pCount.adr)
120-
val count = pCount[0]
121-
val pNames = MemoryUtil.memPointerBufferSafe(ppNames, count) ?: return arrayListOf()
122-
val res = ArrayList<String>(count)
123-
for (i in 0 until count)
124-
res += MemoryUtil.memASCII(pNames[i])
125-
return res
126-
}
127-
128-
fun createWindowSurface(windowHandle: Long, instance: VkInstance): VkSurfaceKHR {
129-
val pSurface = appBuffer.long
130-
VK_CHECK_RESULT(GLFWVulkan.nglfwCreateWindowSurface(instance.adr, windowHandle, NULL, pSurface))
131-
return memGetLong(pSurface)
132-
}
116+
// val requiredInstanceExtensions: ArrayList<String>
117+
// get() {
118+
// val pCount = appBuffer.intBuffer
119+
// val ppNames = GLFWVulkan.nglfwGetRequiredInstanceExtensions(pCount.adr)
120+
// val count = pCount[0]
121+
// val pNames = MemoryUtil.memPointerBufferSafe(ppNames, count) ?: return arrayListOf()
122+
// val res = ArrayList<String>(count)
123+
// for (i in 0 until count)
124+
// res += MemoryUtil.memASCII(pNames[i])
125+
// return res
126+
// }
127+
//
128+
// fun createWindowSurface(windowHandle: Long, instance: VkInstance): VkSurfaceKHR {
129+
// val pSurface = appBuffer.long
130+
// VK_CHECK_RESULT(GLFWVulkan.nglfwCreateWindowSurface(instance.adr, windowHandle, NULL, pSurface))
131+
// return memGetLong(pSurface)
132+
// }
133133

134134
enum class Error(val i: Int) {
135135
none(GLFW_NO_ERROR),
@@ -149,8 +149,8 @@ object glfw {
149149
}
150150

151151
val error: Error
152-
get() {
153-
val pointer = appBuffer.pointerBuffer
152+
get() = stak {
153+
val pointer = it.mallocPointer(1)
154154
val code = glfwGetError(pointer)
155155
errorDescription = when {
156156
code != GLFW_NO_ERROR -> memUTF8(pointer[0])

src/main/kotlin/uno/kotlin/buffers/DualPivotQuicksort.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package uno.kotlin.buffers
22

33
import glm_.b
4-
import glm_.buffer.intBufferBig
54
import glm_.set
6-
import uno.buffer.intBufferBig
5+
import kool.intBufferBig
76
import java.nio.ByteBuffer
87
import java.nio.IntBuffer
98

src/main/kotlin/uno/kotlin/buffers/TimSort.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ package uno.kotlin.buffers
22

33
import glm_.BYTES
44
import glm_.L
5-
import glm_.b
6-
import glm_.buffer.intBufferBig
7-
import glm_.detail.Random.int
85
import glm_.set
6+
import kool.intBufferBig
97
import org.lwjgl.system.MemoryUtil
10-
import uno.buffer.intBufferBig
118
import java.nio.IntBuffer
129

1310
/** A stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when running on partially

0 commit comments

Comments
 (0)