Skip to content

Commit 1a8d0a8

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 6236a09 + 7411acd commit 1a8d0a8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,29 @@ A kind of a [gln](https://github.com/kotlin-graphics/glm) for glfw. So, code mor
2222
glClear(GL_COLOR_BUFFER_BIT)
2323
}
2424

25+
One cool feature is that it supports multiple listeners of the same type, like `CharCallback`:
26+
27+
var charCallback: CharCallbackT? = null
28+
get() = charCallbacks.getOrfirst(defaultKey)
29+
set(value) {
30+
charCallbacks[defaultKey] = value
31+
field = value
32+
}
33+
val charCallbacks = sortedMapOf<String, CharCallbackT>()
34+
val nCharCallback = GLFWCharCallbackI { _, codePoint -> charCallbacks.values.forEach { it(codePoint) } }
35+
36+
`nCharCallback` where `n` stays for native is the only and real callback
37+
38+
`charCallback` is just a comfortable interface to automatically set/get a single callback
39+
40+
`charCallbacks` is the `SortedMap` containing all the current callbacks
41+
42+
I've been chosen that so they can be easier ordered, the default callback has always this key:
43+
44+
`val defaultKey = "0 - default"`
45+
46+
I actually asked for this multi-callback in the native glfw, but in the meanwhile we can already use it. And this is also faster because it's all on the jvm!
47+
2548
Plus some other small utils like:
2649
- methods for allocating very easily many different type of buffers from a lot of different data type, such as different arrays and so on.
2750
- an cap class for a deep and complete resume about a machine opengl capabilities

0 commit comments

Comments
 (0)