mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
minor fixes
This commit is contained in:
@@ -263,7 +263,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
Gdx.gl20.glViewport(0, 0, width, height);
|
Gdx.gl20.glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final float UPDATE_RATE = 1f / 64f; // TODO set it like 1/100, because apparent framerate is limited by update rate
|
public static final float UPDATE_RATE = 1f / 64f; // apparent framerate will be limited by update rate
|
||||||
|
|
||||||
private static float loadTimer = 0f;
|
private static float loadTimer = 0f;
|
||||||
private static final float showupTime = 100f / 1000f;
|
private static final float showupTime = 100f / 1000f;
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ object CommonResourcePool {
|
|||||||
try {
|
try {
|
||||||
if (u is Disposable)
|
if (u is Disposable)
|
||||||
u.dispose()
|
u.dispose()
|
||||||
if (u is Texture)
|
else if (u is Texture)
|
||||||
u.dispose()
|
u.dispose()
|
||||||
if (u is TextureRegion)
|
else if (u is TextureRegion)
|
||||||
u.texture.dispose()
|
u.texture.dispose()
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,8 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
// using unsafe pointer gets you 100 fps, whereas using directbytebuffer gets you 90
|
// using unsafe pointer gets you 100 fps, whereas using directbytebuffer gets you 90
|
||||||
internal val ptr: UnsafePtr = UnsafeHelper.allocate(width * height * BYTES_PER_BLOCK)
|
internal val ptr: UnsafePtr = UnsafeHelper.allocate(width * height * BYTES_PER_BLOCK)
|
||||||
|
|
||||||
//private val directByteBuffer: ByteBuffer
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
ptr.fillWith(0)
|
ptr.fillWith(0)
|
||||||
|
|
||||||
//directByteBuffer = ByteBuffer.allocateDirect(width * height * BYTES_PER_BLOCK)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +36,7 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
*/
|
*/
|
||||||
constructor(width: Int, height: Int, data: ByteArray) : this(width, height) {
|
constructor(width: Int, height: Int, data: ByteArray) : this(width, height) {
|
||||||
TODO()
|
TODO()
|
||||||
//data.forEachIndexed { index, byte -> unsafe.putByte(layerPtr + index, byte) }
|
data.forEachIndexed { index, byte -> UnsafeHelper.unsafe.putByte(ptr.ptr + index, byte) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,13 +58,11 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
val y = iteratorCount / width
|
val y = iteratorCount / width
|
||||||
val x = iteratorCount % width
|
val x = iteratorCount % width
|
||||||
// advance counter
|
// advance counter
|
||||||
iteratorCount += 2
|
iteratorCount += 1
|
||||||
|
|
||||||
val offset = 2L * (y * width + x)
|
val offset = BYTES_PER_BLOCK * (y * width + x)
|
||||||
val lsb = ptr[offset]
|
val lsb = ptr[offset]
|
||||||
//val lsb = directByteBuffer[offset]
|
|
||||||
val msb = ptr[offset + 1]
|
val msb = ptr[offset + 1]
|
||||||
//val msb = directByteBuffer[offset + 1]
|
|
||||||
|
|
||||||
|
|
||||||
return lsb.toUint() + msb.toUint().shl(8)
|
return lsb.toUint() + msb.toUint().shl(8)
|
||||||
@@ -94,7 +88,6 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
iteratorCount += 1
|
iteratorCount += 1
|
||||||
|
|
||||||
return ptr[iteratorCount]
|
return ptr[iteratorCount]
|
||||||
//return directByteBuffer[iteratorCount]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,8 +96,6 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
val offset = BYTES_PER_BLOCK * (y * width + x)
|
val offset = BYTES_PER_BLOCK * (y * width + x)
|
||||||
val lsb = ptr[offset]
|
val lsb = ptr[offset]
|
||||||
val msb = ptr[offset + 1]
|
val msb = ptr[offset + 1]
|
||||||
//val lsb = directByteBuffer[offset]
|
|
||||||
//val msb = directByteBuffer[offset + 1]
|
|
||||||
|
|
||||||
return lsb.toUint() + msb.toUint().shl(8)
|
return lsb.toUint() + msb.toUint().shl(8)
|
||||||
}
|
}
|
||||||
@@ -118,8 +109,6 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
|
|
||||||
ptr[offset] = lsb
|
ptr[offset] = lsb
|
||||||
ptr[offset + 1] = msb
|
ptr[offset + 1] = msb
|
||||||
//directByteBuffer.put(offset, lsb)
|
|
||||||
//directByteBuffer.put(offset + 1, msb)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,7 +128,6 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
|||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
ptr.destroy()
|
ptr.destroy()
|
||||||
//directByteBuffer.clear()
|
|
||||||
printdbg(this, "BlockLayer with ptr ($ptr) successfully freed")
|
printdbg(this, "BlockLayer with ptr ($ptr) successfully freed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user