Skip to content

Commit d21843c

Browse files
committed
0.7.18
1 parent 90d776d commit d21843c

File tree

19 files changed

+113
-77
lines changed

19 files changed

+113
-77
lines changed

awt/awt.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import magik.createGithubPublication
22
import magik.github
3-
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
43
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
5-
import org.lwjgl.lwjgl
64
import org.lwjgl.Lwjgl.Module.*
5+
import org.lwjgl.lwjgl
76

87
plugins {
98
kotlin("jvm")
@@ -17,6 +16,7 @@ version = rootProject.version
1716

1817
dependencies {
1918
implementation(projects.core)
19+
implementation(projects.gl)
2020

2121
api("kotlin.graphics:gln:0.5.32")
2222

@@ -41,7 +41,7 @@ publishing {
4141
suppressAllPomMetadataWarnings()
4242
}
4343
}
44-
repositories { github { domain = "kotlin-graphics/mary" } }
44+
repositories.github { domain = "kotlin-graphics/mary" }
4545
}
4646

4747
java.withSourcesJar()

awt/src/main/kotlin/uno/awt/LwjglCanvas.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.lwjgl.opengl.GLUtil
66
import org.lwjgl.system.Callback
77
import org.lwjgl.system.jawt.JAWTDrawingSurface
88
import org.lwjgl.system.jawt.JAWTFunctions
9-
import uno.glfw.GlWindow
9+
import uno.gl.GlWindow
1010
import uno.glfw.GlfwWindow
1111
import uno.glfw.VSync
1212
import uno.glfw.glfw

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ plugins {
1212
dependencies {
1313
api(projects.core)
1414
api(projects.awt)
15+
api(projects.gl)
1516
// vk
1617
}
1718

1819
kotlin.jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) }
1920

20-
2121
tasks {
2222
withType<KotlinCompile<*>>().all { kotlinOptions { freeCompilerArgs += listOf("-opt-in=kotlin.RequiresOptIn") } }
2323
test { useJUnitPlatform() }
@@ -30,5 +30,5 @@ publishing {
3030
suppressAllPomMetadataWarnings()
3131
}
3232
}
33-
repositories { github { domain = "kotlin-graphics/mary" } }
33+
repositories.github { domain = "kotlin-graphics/mary" }
3434
}

core/core.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import magik.createGithubPublication
22
import magik.github
3-
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
43
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
5-
import org.lwjgl.Lwjgl.Module.*
4+
import org.lwjgl.Lwjgl.Module.glfw
5+
import org.lwjgl.Lwjgl.Module.jemalloc
66
import org.lwjgl.lwjgl
77

88
plugins {
@@ -19,8 +19,8 @@ version = rootProject.version
1919
dependencies {
2020
implementation(kotlin("reflect"))
2121

22-
api("kotlin.graphics:gln:0.5.32")
23-
lwjgl { implementation(glfw, jemalloc, opengl) }
22+
api("kotlin.graphics:glm:0.9.9.1-11")
23+
lwjgl { implementation(glfw, jemalloc) }
2424

2525
testImplementation("io.kotest:kotest-runner-junit5:5.5.5")
2626
testImplementation("io.kotest:kotest-assertions-core:5.5.5")
@@ -29,7 +29,7 @@ dependencies {
2929
kotlin.jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) }
3030

3131
tasks {
32-
withType<KotlinCompilationTask<*>>().configureEach { compilerOptions { freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") } }
32+
withType<KotlinCompilationTask<*>>().configureEach { compilerOptions.freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") }
3333
test { useJUnitPlatform() }
3434
}
3535

@@ -41,7 +41,7 @@ publishing {
4141
suppressAllPomMetadataWarnings()
4242
}
4343
}
44-
repositories { github { domain = "kotlin-graphics/mary" } }
44+
repositories.github { domain = "kotlin-graphics/mary" }
4545
}
4646

4747
java.withSourcesJar()

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import glm_.vec4.Vec4
99
import glm_.vec4.Vec4b
1010
import glm_.vec4.Vec4i
1111
import glm_.vec4.Vec4ub
12-
import gln.glf.Vertex
13-
import gln.glf.glf
12+
//import gln.glf.Vertex
13+
//import gln.glf.glf
1414
import kool.*
1515
import java.nio.ByteBuffer
1616
import java.nio.FloatBuffer
@@ -35,22 +35,22 @@ fun bufferOf(vertices: Collection<*>): ByteBuffer {
3535
for (i in vertices.indices)
3636
(vertices.elementAt(i) as Vec4).to(res, i * Vec4.size)
3737
}
38-
is Vertex.pos2_tc2 -> {
39-
res = Buffer(glf.pos2_tc2.stride * vertices.size)
40-
for (i in vertices.indices) {
41-
val v = vertices.elementAt(i) as Vertex.pos2_tc2
42-
v.p.to(res, i * glf.pos2_tc2.stride)
43-
v.t.to(res, i * glf.pos2_tc2.stride + Vec2.size)
44-
}
45-
}
46-
is Vertex.pos3_col4ub -> {
47-
res = Buffer(glf.pos3_col4ub.stride * vertices.size)
48-
for (i in vertices.indices) {
49-
val v = vertices.elementAt(i) as Vertex.pos3_col4ub
50-
v.p.to(res, i * glf.pos2_tc2.stride)
51-
v.c.to(res, i * glf.pos2_tc2.stride + Vec3.size)
52-
}
53-
}
38+
// is Vertex.pos2_tc2 -> {
39+
// res = Buffer(glf.pos2_tc2.stride * vertices.size)
40+
// for (i in vertices.indices) {
41+
// val v = vertices.elementAt(i) as Vertex.pos2_tc2
42+
// v.p.to(res, i * glf.pos2_tc2.stride)
43+
// v.t.to(res, i * glf.pos2_tc2.stride + Vec2.size)
44+
// }
45+
// }
46+
// is Vertex.pos3_col4ub -> {
47+
// res = Buffer(glf.pos3_col4ub.stride * vertices.size)
48+
// for (i in vertices.indices) {
49+
// val v = vertices.elementAt(i) as Vertex.pos3_col4ub
50+
// v.p.to(res, i * glf.pos2_tc2.stride)
51+
// v.c.to(res, i * glf.pos2_tc2.stride + Vec3.size)
52+
// }
53+
// }
5454
else -> throw Error()
5555
}
5656
return res
@@ -63,9 +63,9 @@ fun bufferOf(vararg elements: Any): ByteBuffer {
6363
is Vec2 -> Vec2.size
6464
is Vec3 -> Vec3.size
6565
is Vec4 -> Vec4.size
66-
is Vertex.pos2_tc2 -> Vec2.size * 2
67-
is Vertex.pos3_col4ub -> Vec3.size + Vec4ub.size
68-
is Vertex.pos3_nor3_col4 -> Vec3.size * 2 + Vec4.size
66+
// is Vertex.pos2_tc2 -> Vec2.size * 2
67+
// is Vertex.pos3_col4ub -> Vec3.size + Vec4ub.size
68+
// is Vertex.pos3_nor3_col4 -> Vec3.size * 2 + Vec4.size
6969
else -> throw Exception("Invalid")
7070
}
7171
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import glm_.vec2.Vec2
66
import glm_.vec2.Vec2d
77
import glm_.vec2.Vec2i
88
import glm_.vec4.Vec4i
9-
import gln.L
109
import kool.*
1110
import org.lwjgl.glfw.*
1211
import org.lwjgl.glfw.GLFW.*
@@ -89,7 +88,7 @@ open class GlfwWindow(var handle: Long) {
8988
}
9089

9190
// --- [ glfwSetWindowIcon ] ---
92-
fun setIcon(images: GLFWImage.Buffer?) = nglfwSetWindowIcon(handle, images?.rem ?: 0, images?.adr?.L ?: MemoryUtil.NULL)
91+
fun setIcon(images: GLFWImage.Buffer?) = nglfwSetWindowIcon(handle, images?.rem ?: 0, images?.adr?.toLong() ?: MemoryUtil.NULL)
9392

9493
// --- [ glfwGetWindowPos ] ---
9594
// --- [ glfwSetWindowPos ] ---
@@ -266,7 +265,7 @@ open class GlfwWindow(var handle: Long) {
266265

267266
var userPointer: Ptr<*>
268267
get() = glfwGetWindowUserPointer(handle).toPtr<Nothing>()
269-
set(value) = glfwSetWindowUserPointer(handle, value.adr.L)
268+
set(value) = glfwSetWindowUserPointer(handle, value.adr.toLong())
270269

271270
// --- [ glfwSetWindowPosCallback ] ---
272271
var posCB: WindowPosCB?

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
package uno.glfw
44

55
import glm_.bool
6-
import gln.L
7-
import gln.writeAscii
86
import kool.Ptr
97
import kool.get
108
import kool.stack
@@ -28,7 +26,7 @@ value class Joystick(val id: Int) {
2826
val axes: FloatArray?
2927
get() = stack { s ->
3028
val pCount = s.ptrInt()
31-
val pAxes = GLFW.nglfwGetJoystickAxes(id, pCount.adr.L).toPtr<Float>()
29+
val pAxes = GLFW.nglfwGetJoystickAxes(id, pCount.adr.toLong()).toPtr<Float>()
3230
if (pAxes.isValid)
3331
FloatArray(pCount[0]) { pAxes[it] }
3432
else null
@@ -39,7 +37,7 @@ value class Joystick(val id: Int) {
3937
val buttons: BooleanArray?
4038
get() = stack { s ->
4139
val pCount = s.ptrInt()
42-
val pButtons = GLFW.nglfwGetJoystickButtons(id, pCount.adr.L).toPtr<Int>()
40+
val pButtons = GLFW.nglfwGetJoystickButtons(id, pCount.adr.toLong()).toPtr<Int>()
4341
if (pButtons.isValid)
4442
BooleanArray(pCount[0]) { pButtons[0] == GLFW.GLFW_PRESS }
4543
else null
@@ -66,7 +64,7 @@ value class Joystick(val id: Int) {
6664
val hats: Array<Hat>?
6765
get() = stack { s ->
6866
val pCount = s.ptrInt()
69-
val pHats = GLFW.nglfwGetJoystickHats(id, pCount.adr.L).toPtr<UByte>()
67+
val pHats = GLFW.nglfwGetJoystickHats(id, pCount.adr.toLong()).toPtr<UByte>()
7068
if (pHats.isValid)
7169
Array(pCount[0]) { Hat of pHats[it].toInt() }
7270
else null
@@ -84,7 +82,7 @@ value class Joystick(val id: Int) {
8482
// --- [ glfwGetJoystickUserPointer ] ---
8583
var userPointer: Ptr<*>
8684
get() = GLFW.glfwGetJoystickUserPointer(id).toPtr<Nothing>()
87-
set(value) = GLFW.glfwSetJoystickUserPointer(id, value.adr.L)
85+
set(value) = GLFW.glfwSetJoystickUserPointer(id, value.adr.toLong())
8886

8987
// --- [ glfwJoystickIsGamepad ] ---
9088
val isGamepad: Boolean
@@ -117,9 +115,7 @@ value class Joystick(val id: Int) {
117115
}
118116

119117
companion object {
120-
val _1: Joystick get() = Joystick(GLFW.GLFW_JOYSTICK_1)
121-
val _2: Joystick get() = Joystick(GLFW.GLFW_JOYSTICK_2)
122-
val _3: Joystick get() = Joystick(GLFW.GLFW_JOYSTICK_3)
118+
val joysticks: Array<Joystick> = Array(16) { Joystick(GLFW.GLFW_JOYSTICK_1 + it) }
123119
}
124120
}
125121

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

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

33
import glm_.bool
4-
import gln.L
5-
import gln.misc.glDebugCallback
6-
import gln.writeAscii
74
import kool.*
85
import org.lwjgl.glfw.*
96
import org.lwjgl.glfw.GLFW.*
@@ -67,7 +64,6 @@ object glfw {
6764
fun terminate() {
6865
glfwTerminate()
6966
errorCB = null // ~ free the current cb
70-
glDebugCallback?.free()
7167
}
7268

7369
// --- [ glfwInitHint ] ---
@@ -114,7 +110,7 @@ object glfw {
114110
val error: Error
115111
get() = stack {
116112
val ppDescription = it.ptrLong()
117-
val code = nglfwGetError(ppDescription.adr.L)
113+
val code = nglfwGetError(ppDescription.adr.toLong())
118114
errorDescription = when {
119115
code != GLFW_NO_ERROR -> memUTF8(ppDescription[0])
120116
else -> ""
@@ -167,7 +163,7 @@ object glfw {
167163
val monitors: GlfwMonitors
168164
get() = stack { s ->
169165
val pCount = s.ptrInt()
170-
val pMonitors = nglfwGetMonitors(pCount.adr.L)
166+
val pMonitors = nglfwGetMonitors(pCount.adr.toLong())
171167
GlfwMonitors(LongArray(pCount[0]) { memGetAddress(pMonitors + it shl 3) })
172168
}
173169

@@ -342,7 +338,7 @@ object glfw {
342338
// -> Joystick
343339

344340
// --- [ glfwUpdateGamepadMappings ] ---
345-
fun updateGamepadMappings(string: String): Boolean = stack.writeAscii(string) { nglfwUpdateGamepadMappings(it.adr.L) }.bool
341+
infix fun updateGamepadMappings(string: String): Boolean = stack.writeAsciiToAdr(string) { nglfwUpdateGamepadMappings(it.toLong()) }.bool
346342

347343
// --- [ glfwGetGamepadName ] ---
348344
// --- [ glfwGetGamepadState ] ---

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package uno.glfw
55
import glm_.vec2.Vec2
66
import glm_.vec2.Vec2d
77
import glm_.vec2.Vec2i
8-
import gln.L
98
import kool.*
109
import org.lwjgl.glfw.GLFW
1110
import org.lwjgl.glfw.GLFW.glfwDestroyCursor
@@ -28,7 +27,7 @@ class GlfwVidMode(val size: Vec2i, val redBits: Int, val greenBits: Int, val blu
2827
}
2928
}
3029

31-
operator fun Ptr<GlfwVidMode>.get(index: Int) = GlfwVidMode((adr.L + index * GlfwVidMode.Size).toPtr())
30+
operator fun Ptr<GlfwVidMode>.get(index: Int) = GlfwVidMode((adr.toLong() + index * GlfwVidMode.Size).toPtr())
3231

3332
class GlfwGammaRamp(val red: IntArray, val green: IntArray, val blue: IntArray) {
3433

@@ -42,9 +41,9 @@ class GlfwGammaRamp(val red: IntArray, val green: IntArray, val blue: IntArray)
4241
b[i] = blue[i].toUShort()
4342
}
4443
val ptr = stack.nmalloc(GLFWGammaRamp.ALIGNOF, GLFWGammaRamp.SIZEOF)
45-
memPutAddress(ptr + GLFWGammaRamp.RED, r.adr.L)
46-
memPutAddress(ptr + GLFWGammaRamp.GREEN, g.adr.L)
47-
memPutAddress(ptr + GLFWGammaRamp.BLUE, b.adr.L)
44+
memPutAddress(ptr + GLFWGammaRamp.RED, r.adr.toLong())
45+
memPutAddress(ptr + GLFWGammaRamp.GREEN, g.adr.toLong())
46+
memPutAddress(ptr + GLFWGammaRamp.BLUE, b.adr.toLong())
4847
memPutInt(ptr + GLFWGammaRamp.SIZE, red.size)
4948
return ptr.toPtr()
5049
}
@@ -62,7 +61,7 @@ fun GlfwGammaRamp(ptr: Ptr<GlfwGammaRamp>): GlfwGammaRamp {
6261
value class GlfwCursor(val handle: Long) {
6362
// --- [ glfwCreateCursor ] ---
6463
constructor(image: GlfwImage, hot: Int) : this(image, hot, hot)
65-
constructor(image: GlfwImage, xHot: Int, yHot: Int) : this(stack { GLFW.nglfwCreateCursor(image.toStack(it).adr.L, xHot, yHot) })
64+
constructor(image: GlfwImage, xHot: Int, yHot: Int) : this(stack { GLFW.nglfwCreateCursor(image.toStack(it).adr.toLong(), xHot, yHot) })
6665

6766
// --- [ glfwDestroyCursor ] ---
6867
fun destroy() = glfwDestroyCursor(handle)
@@ -115,7 +114,7 @@ class GlfwImage(val width: Int, val height: Int, val pixels: UByteArray) {
115114
val pPixels = stack.ptrUByte(pixels.size)
116115
for (i in pixels.indices)
117116
pPixels[i] = pixels[i]
118-
memPutAddress(ptr + GLFWImage.PIXELS, pPixels.adr.L)
117+
memPutAddress(ptr + GLFWImage.PIXELS, pPixels.adr.toLong())
119118
return ptr.toPtr()
120119
}
121120
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package uno.glfw
33
import glm_.vec2.Vec2
44
import glm_.vec2.Vec2i
55
import glm_.vec4.Vec4i
6-
import gln.L
76
import kool.Ptr
87
import kool.get
98
import kool.stack
@@ -69,14 +68,14 @@ value class GlfwMonitor(val handle: Long) {
6968
// --- [ glfwSetMonitorUserPointer ] ---
7069
var userPointer: Ptr<*>
7170
get() = glfwGetMonitorUserPointer(handle).toPtr<Nothing>()
72-
set(value) = glfwSetMonitorUserPointer(handle, value.adr.L)
71+
set(value) = glfwSetMonitorUserPointer(handle, value.adr.toLong())
7372

7473

7574
// --- [ glfwGetVideoModes ] ---
7675
val videoModes: Array<GlfwVidMode>
7776
get() = stack { s ->
7877
val pCount = s.ptrInt()
79-
val pModes = nglfwGetVideoModes(handle, pCount.adr.L).toPtr<GlfwVidMode>()
78+
val pModes = nglfwGetVideoModes(handle, pCount.adr.toLong()).toPtr<GlfwVidMode>()
8079
val count = pCount[0]
8180
Array(count) { pModes[it] }
8281
}
@@ -93,7 +92,7 @@ value class GlfwMonitor(val handle: Long) {
9392
// --- [ glfwGetGammaRamp ] ---
9493
var gammaRamp: GlfwGammaRamp
9594
get() = GlfwGammaRamp(nglfwGetGammaRamp(handle).toPtr())
96-
set(value) = stack { nglfwSetGammaRamp(handle, value.toStack(it).adr.L) }
95+
set(value) = stack { nglfwSetGammaRamp(handle, value.toStack(it).adr.toLong()) }
9796

9897
companion object {
9998
val NULL = GlfwMonitor(MemoryUtil.NULL)

0 commit comments

Comments
 (0)