Skip to content

Commit af3d1d9

Browse files
authored
Update README.md
1 parent 2e34d01 commit af3d1d9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ 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 `val defaultKey = "0 - default"`
43+
44+
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!
45+
2546
Plus some other small utils like:
2647
- methods for allocating very easily many different type of buffers from a lot of different data type, such as different arrays and so on.
2748
- an cap class for a deep and complete resume about a machine opengl capabilities

0 commit comments

Comments
 (0)