From f5311eb0350ec0aaaf6c60e7ab7132073eb07d61 Mon Sep 17 00:00:00 2001 From: Daniel Gergely Date: Fri, 29 Dec 2023 13:14:51 +0100 Subject: [PATCH] Add drawElements --- .idea/kgl.iml | 20 ++++++++++++++ .idea/modules.xml | 27 +++++++++++++++++++ .../com/danielgergely/kgl/KglAndroid.kt | 2 ++ .../kotlin/com.danielgergely.kgl/KglIos.kt | 4 +++ .../kotlin/com/danielgergely/kgl/KglJogl.kt | 1 + .../kotlin/com/danielgergely/kgl/KglLwjgl.kt | 4 +++ .../kotlin/com/danielgergely/kgl/DebugKgl.kt | 7 +++++ .../kotlin/com/danielgergely/kgl/Kgl.kt | 1 + .../danielgergely/kgl/{Kgl.kt => KglJs.kt} | 2 ++ 9 files changed, 68 insertions(+) create mode 100644 .idea/kgl.iml create mode 100644 .idea/modules.xml rename kgl/src/jsMain/kotlin/com/danielgergely/kgl/{Kgl.kt => KglJs.kt} (99%) diff --git a/.idea/kgl.iml b/.idea/kgl.iml new file mode 100644 index 0000000..6bf4211 --- /dev/null +++ b/.idea/kgl.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8a5c7d9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kgl-android/src/main/kotlin/com/danielgergely/kgl/KglAndroid.kt b/kgl-android/src/main/kotlin/com/danielgergely/kgl/KglAndroid.kt index 6795f56..0b6d1ad 100644 --- a/kgl-android/src/main/kotlin/com/danielgergely/kgl/KglAndroid.kt +++ b/kgl-android/src/main/kotlin/com/danielgergely/kgl/KglAndroid.kt @@ -203,6 +203,8 @@ object KglAndroid : Kgl { override fun drawArrays(mode: Int, first: Int, count: Int) = GL.glDrawArrays(mode, first, count) + override fun drawElements(mode: Int, count: Int, type: Int) = GL.glDrawElements(mode, count, type, 0) + override fun getError(): Int = GL.glGetError() override fun finish() = GL.glFinish() diff --git a/kgl-ios/src/nativeMain/kotlin/com.danielgergely.kgl/KglIos.kt b/kgl-ios/src/nativeMain/kotlin/com.danielgergely.kgl/KglIos.kt index 6b86c8f..ad4caf3 100644 --- a/kgl-ios/src/nativeMain/kotlin/com.danielgergely.kgl/KglIos.kt +++ b/kgl-ios/src/nativeMain/kotlin/com.danielgergely.kgl/KglIos.kt @@ -361,6 +361,10 @@ object KglIos : Kgl { glDrawArrays(mode.toUInt(), first, count) } + override fun drawElements(mode: Int, count: Int, type: Int) { + glDrawElements(mode.toUInt(), count, type.toUInt(), null) + } + override fun getError(): Int { return glGetError().toInt() } diff --git a/kgl-jogl/src/main/kotlin/com/danielgergely/kgl/KglJogl.kt b/kgl-jogl/src/main/kotlin/com/danielgergely/kgl/KglJogl.kt index 8b654de..dec24e6 100644 --- a/kgl-jogl/src/main/kotlin/com/danielgergely/kgl/KglJogl.kt +++ b/kgl-jogl/src/main/kotlin/com/danielgergely/kgl/KglJogl.kt @@ -260,6 +260,7 @@ class KglJogl(private val gl: GL) : Kgl { gl.glDeleteVertexArrays(1, intArrayOf(vertexArrayObject), 0) override fun drawArrays(mode: Int, first: Int, count: Int) = gl.glDrawArrays(mode, first, count) + override fun drawElements(mode: Int, count: Int, type: Int) = gl.glDrawElements(mode, count, type, 0) override fun getError(): Int = gl.glGetError() override fun finish() = gl.glFinish() diff --git a/kgl-lwjgl/src/main/kotlin/com/danielgergely/kgl/KglLwjgl.kt b/kgl-lwjgl/src/main/kotlin/com/danielgergely/kgl/KglLwjgl.kt index bde6eba..7136468 100644 --- a/kgl-lwjgl/src/main/kotlin/com/danielgergely/kgl/KglLwjgl.kt +++ b/kgl-lwjgl/src/main/kotlin/com/danielgergely/kgl/KglLwjgl.kt @@ -119,6 +119,10 @@ object KglLwjgl : Kgl { GL.glDrawArrays(mode, first, count) } + override fun drawElements(mode: Int, count: Int, type: Int) { + GL.glDrawElements(mode, count, type, 0) + } + override fun getError(): Int { return GL.glGetError() } diff --git a/kgl/src/commonMain/kotlin/com/danielgergely/kgl/DebugKgl.kt b/kgl/src/commonMain/kotlin/com/danielgergely/kgl/DebugKgl.kt index acb96dc..042f2a7 100644 --- a/kgl/src/commonMain/kotlin/com/danielgergely/kgl/DebugKgl.kt +++ b/kgl/src/commonMain/kotlin/com/danielgergely/kgl/DebugKgl.kt @@ -464,6 +464,13 @@ public class DebugKgl( return ret } + override fun drawElements(mode: Int, count: Int, type: Int) { + runBefore("drawElements") + val ret = kgl.drawElements(mode, count, type) + runAfter("drawElements") + return ret + } + override fun getError(): Int { runBefore("getError") val ret = kgl.getError() diff --git a/kgl/src/commonMain/kotlin/com/danielgergely/kgl/Kgl.kt b/kgl/src/commonMain/kotlin/com/danielgergely/kgl/Kgl.kt index 56f71c7..10357a0 100644 --- a/kgl/src/commonMain/kotlin/com/danielgergely/kgl/Kgl.kt +++ b/kgl/src/commonMain/kotlin/com/danielgergely/kgl/Kgl.kt @@ -95,6 +95,7 @@ public interface Kgl { public fun deleteVertexArray(vertexArrayObject: VertexArrayObject) public fun drawArrays(mode: Int, first: Int, count: Int) + public fun drawElements(mode: Int, count: Int, type: Int) public fun getError(): Int public fun finish() diff --git a/kgl/src/jsMain/kotlin/com/danielgergely/kgl/Kgl.kt b/kgl/src/jsMain/kotlin/com/danielgergely/kgl/KglJs.kt similarity index 99% rename from kgl/src/jsMain/kotlin/com/danielgergely/kgl/Kgl.kt rename to kgl/src/jsMain/kotlin/com/danielgergely/kgl/KglJs.kt index e8e590d..ef3633f 100644 --- a/kgl/src/jsMain/kotlin/com/danielgergely/kgl/Kgl.kt +++ b/kgl/src/jsMain/kotlin/com/danielgergely/kgl/KglJs.kt @@ -190,6 +190,8 @@ public class KglJs(private val gl: WebGLRenderingContext) : Kgl { public override fun drawArrays(mode: Int, first: Int, count: Int): Unit = gl.drawArrays(mode, first, count) + public override fun drawElements(mode: Int, count: Int, type: Int): Unit = gl.drawElements(mode, count, type, 0) + public override fun getError(): Int = gl.getError() public override fun finish(): Unit = gl.finish()