commonMain.korlibs.kgl.KmlBufferExt.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of korgw Show documentation
Show all versions of korgw Show documentation
Portable UI with accelerated graphics support for Kotlin
package korlibs.kgl
import korlibs.memory.*
fun Buffer.toAsciiString(): String {
var out = ""
for (n in 0 until size) {
val b = getInt8(n)
if (b == 0.toByte()) break
out += b.toInt().toChar()
}
return out
}
fun Buffer.putAsciiString(str: String): Buffer {
var n = 0
for (c in str) {
if (size >= n) setInt8(n++, c.code)
}
if (size >= n) setInt8(n++, 0)
return this
}
fun IntArray.toTempBuffer(callback: (Buffer) -> T): T {
return BufferTemp(this.size) { buffer: Buffer ->
val ints = buffer.i32
for (n in this.indices) ints[n] = this[n]
callback(buffer)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy