Skip to content
Snippets Groups Projects
Commit 7c7ec09c authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Initial demo version

parents
No related branches found
No related tags found
No related merge requests found
package de.kuschku.atlas.model
data class Section(
val y: Byte,
val blockLight: ByteArray,
val skyLight: ByteArray,
val blocks: IntArray,
val data: ByteArray
)
\ No newline at end of file
package de.kuschku.atlas.util
import org.lwjgl.system.MemoryStack
typealias GLFWwindow = Long
inline fun <reified T : Any> sizeof(): Int {
return when (T::class) {
Float::class, Float::class.javaObjectType, Float::class.javaPrimitiveType -> 4
Int::class, Int::class.javaObjectType, Int::class.javaPrimitiveType -> 4
Long::class, Long::class.javaObjectType, Long::class.javaPrimitiveType -> 8
Short::class, Short::class.javaObjectType, Short::class.javaPrimitiveType -> 2
Byte::class, Byte::class.javaObjectType, Byte::class.javaPrimitiveType -> 1
else -> throw IllegalArgumentException("Unsupported type: ${T::class}")
}
}
inline fun memoryStack(block: MemoryStack.() -> Unit) {
val stack = MemoryStack.stackPush()
var closed = false
try {
return block(stack)
} catch (e: Exception) {
closed = true
try {
stack?.close()
} catch (closeException: Exception) {
}
throw e
} finally {
if (!closed) {
stack?.close()
}
}
}
\ No newline at end of file
package de.kuschku.atlas.util
import kotlin.experimental.and
fun convertNibbleArray(array: ByteArray): ByteArray {
val result = ByteArray(array.size * 2)
for ((i, value) in array.withIndex()) {
val loNibble = value and 0x0F
val hiNibble = ((value.toInt() and 0xFF) shr 4 and 0x0F).toByte()
result[i * 2] = loNibble
result[i * 2 + 1] = hiNibble
}
return result
}
fun convertBlocks(blocks: ByteArray, add: ByteArray?): IntArray {
val result = IntArray(blocks.size)
if (add != null) {
for ((i, value) in add.withIndex()) {
val loNibble: Int = (value and 0x0F).toInt()
val hiNibble: Int = ((value.toInt() and 0xFF) shr 4 and 0x0F)
result[i * 2] = ((loNibble shl 8) + blocks[i * 2])
result[i * 2 + 1] = hiNibble shl 8 + blocks[i * 2 + 1]
}
} else {
for ((i, value) in blocks.withIndex()) {
result[i] = value.toInt() and 0xFF
}
}
return result
}
\ No newline at end of file
#version 330 core
/*
in float blockLightLevel;
in float skyLightLevel;
*/
out vec4 FragColor;
void main()
{
FragColor = vec4(0.5, 0.2, 0.1, 1.0);
}
\ No newline at end of file
#version 330 core
layout (location = 0) in vec3 aPos;
/*
layout (location = 1) in float aBlockLight;
layout (location = 2) in float aSkyLight;
out float blockLightLevel;
out float skyLightLevel;
*/
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
/*
blockLightLevel = aBlockLight;
skyLightLevel = aSkyLight;
*/
gl_Position = projection * view * model * vec4(aPos, 1.0);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment