From 42b26597b4a21aed305270c548c08c405a11e298 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 13 Apr 2020 05:03:53 +0900 Subject: [PATCH] comment --- assets/tiling.frag | 2 +- src/net/torvald/UnsafePtr.kt | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/assets/tiling.frag b/assets/tiling.frag index f79d8a38c..b71bba952 100644 --- a/assets/tiling.frag +++ b/assets/tiling.frag @@ -17,7 +17,7 @@ uniform sampler2D u_texture; uniform vec2 screenDimension; -uniform vec2 tilesInAxes; // basically a screen dimension; vec2(tiles_in_horizontal, tiles_in_vertical) +uniform vec2 tilesInAxes; // size of the tilemap texture; vec2(tiles_in_horizontal, tiles_in_vertical) uniform sampler2D tilemap; // RGBA8888 diff --git a/src/net/torvald/UnsafePtr.kt b/src/net/torvald/UnsafePtr.kt index a12b65069..5820f48d4 100644 --- a/src/net/torvald/UnsafePtr.kt +++ b/src/net/torvald/UnsafePtr.kt @@ -104,6 +104,16 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) { // NOTE: get/set multibyte values are NOT BYTE-ALIGNED! + fun getDouble(index: Long): Double { + checkNullPtr(index) + return UnsafeHelper.unsafe.getDouble(ptr + index) + } + + fun getLong(index: Long): Long { + checkNullPtr(index) + return UnsafeHelper.unsafe.getLong(ptr + index) + } + fun getFloat(index: Long): Float { checkNullPtr(index) return UnsafeHelper.unsafe.getFloat(ptr + index) @@ -114,6 +124,28 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) { return UnsafeHelper.unsafe.getInt(ptr + index) } + fun getShort(index: Long): Short { + checkNullPtr(index) + return UnsafeHelper.unsafe.getShort(ptr + index) + } + + fun getChar(index: Long): Char { + checkNullPtr(index) + return UnsafeHelper.unsafe.getChar(ptr + index) + } + + + + fun setDouble(index: Long, value: Double) { + checkNullPtr(index) + UnsafeHelper.unsafe.putDouble(ptr + index, value) + } + + fun setLong(index: Long, value: Long) { + checkNullPtr(index) + UnsafeHelper.unsafe.putLong(ptr + index, value) + } + fun setFloat(index: Long, value: Float) { checkNullPtr(index) UnsafeHelper.unsafe.putFloat(ptr + index, value) @@ -124,6 +156,18 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) { UnsafeHelper.unsafe.putInt(ptr + index, value) } + fun setShort(index: Long, value: Short) { + checkNullPtr(index) + UnsafeHelper.unsafe.putShort(ptr + index, value) + } + + fun setChar(index: Long, value: Char) { + checkNullPtr(index) + UnsafeHelper.unsafe.putChar(ptr + index, value) + } + + + fun fillWith(byte: Byte) { UnsafeHelper.unsafe.setMemory(ptr, size, byte) }