Skip to content

Commit

Permalink
Reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
gergelydaniel committed Dec 17, 2022
1 parent ba061cc commit 340417a
Show file tree
Hide file tree
Showing 15 changed files with 425 additions and 1,297 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ gradle-app.setting
local.properties
.idea/misc.xml
.idea/jarRepositories.xml
.idea/kotlinc.xml
2 changes: 0 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.gradle.kotlin.dsl.`kotlin-dsl`

plugins {
`kotlin-dsl`
}
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/src/main/kotlin/ProjectVersion.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.gradle.api.Project

val currentVersion: String by lazy {
versionInfo().versionName
}
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/Publishing.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.kotlin.dsl.repositories
import java.net.URI

data class PublishingSetup(
Expand Down
2 changes: 1 addition & 1 deletion kgl-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.danielgergely.kgl_android" />
<manifest package="com.danielgergely.kgl_android"/>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.danielgergely.kgl

import kotlinx.cinterop.cstr
import kotlinx.cinterop.*
import platform.gles3.*
import platform.glescommon.GLboolean
Expand Down
5 changes: 5 additions & 0 deletions kgl-lwjgl/src/main/kotlin/com/danielgergely/kgl/KglLwjgl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ object KglLwjgl : Kgl {
type,
javaBuffer
)

is ShortBuffer -> GL.glTexImage2D(
target,
level,
Expand All @@ -220,6 +221,7 @@ object KglLwjgl : Kgl {
type,
javaBuffer
)

is IntBuffer -> GL.glTexImage2D(
target,
level,
Expand All @@ -231,6 +233,7 @@ object KglLwjgl : Kgl {
type,
javaBuffer
)

is FloatBuffer -> GL.glTexImage2D(
target,
level,
Expand All @@ -242,6 +245,7 @@ object KglLwjgl : Kgl {
type,
javaBuffer
)

is DoubleBuffer -> GL.glTexImage2D(
target,
level,
Expand All @@ -253,6 +257,7 @@ object KglLwjgl : Kgl {
type,
javaBuffer
)

else -> throw IllegalArgumentException("unknown buffer type ${javaBuffer.javaClass}")
}
}
Expand Down
690 changes: 345 additions & 345 deletions kgl/src/commonMain/kotlin/com/danielgergely/kgl/Constants.kt

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions kgl/src/commonMain/kotlin/com/danielgergely/kgl/DebugKgl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class DebugKgl(
private val kgl: Kgl,
private val runBefore: (String) -> Unit,
private val runAfter: (String) -> Unit,
): Kgl {
) : Kgl {

override fun createShader(type: Int): Shader? {
runBefore("createShader")
Expand Down Expand Up @@ -188,7 +188,14 @@ public class DebugKgl(
return ret
}

override fun vertexAttribPointer(location: Int, size: Int, type: Int, normalized: Boolean, stride: Int, offset: Int) {
override fun vertexAttribPointer(
location: Int,
size: Int,
type: Int,
normalized: Boolean,
stride: Int,
offset: Int
) {
runBefore("vertexAttribPointer")
val ret = kgl.vertexAttribPointer(location, size, type, normalized, stride, offset)
runAfter("vertexAttribPointer")
Expand Down Expand Up @@ -485,7 +492,12 @@ public class DebugKgl(
return ret
}

override fun framebufferRenderbuffer(target: Int, attachment: Int, renderbuffertarget: Int, renderbuffer: Renderbuffer) {
override fun framebufferRenderbuffer(
target: Int,
attachment: Int,
renderbuffertarget: Int,
renderbuffer: Renderbuffer
) {
runBefore("framebufferRenderbuffer")
val ret = kgl.framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer)
runAfter("framebufferRenderbuffer")
Expand Down
27 changes: 22 additions & 5 deletions kgl/src/commonMain/kotlin/com/danielgergely/kgl/Kgl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public interface Kgl {

public fun getShaderParameter(shader: Shader, pname: Int): Int

public fun getProgramInfoLog(program: Program) : String?
public fun getShaderInfoLog(shaderId: Shader) : String?
public fun getProgramInfoLog(program: Program): String?
public fun getShaderInfoLog(shaderId: Shader): String?

public fun createProgram(): Program?
public fun attachShader(programId: Program, shaderId: Shader)
Expand Down Expand Up @@ -63,10 +63,21 @@ public interface Kgl {
public fun clear(mask: Int)

public fun createTexture(): Texture
public fun createTextures(n: Int) : Array<Texture>
public fun createTextures(n: Int): Array<Texture>
public fun deleteTexture(texture: Texture)
public fun texImage2D(target: Int, level: Int, internalFormat: Int, border: Int, resource: TextureResource)
public fun texImage2D(target: Int, level: Int, internalFormat: Int, width: Int, height: Int, border: Int, format: Int, type: Int, buffer: Buffer)
public fun texImage2D(
target: Int,
level: Int,
internalFormat: Int,
width: Int,
height: Int,
border: Int,
format: Int,
type: Int,
buffer: Buffer
)

public fun activeTexture(texture: Int)
public fun bindTexture(target: Int, texture: Texture?)
public fun generateMipmap(target: Int)
Expand All @@ -91,7 +102,13 @@ public interface Kgl {
public fun bindRenderbuffer(target: Int, renderbuffer: Renderbuffer?)
public fun createRenderbuffer(): Renderbuffer
public fun deleteRenderbuffer(renderbuffer: Renderbuffer)
public fun framebufferRenderbuffer(target: Int, attachment: Int, renderbuffertarget: Int, renderbuffer: Renderbuffer)
public fun framebufferRenderbuffer(
target: Int,
attachment: Int,
renderbuffertarget: Int,
renderbuffer: Renderbuffer
)

public fun isRenderbuffer(renderbuffer: Renderbuffer): Boolean
public fun renderbufferStorage(target: Int, internalformat: Int, width: Int, height: Int)

Expand Down
16 changes: 14 additions & 2 deletions kgl/src/jsMain/kotlin/com/danielgergely/kgl/Kgl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class KglJs(private val gl: WebGLRenderingContext) : Kgl {
public override fun linkProgram(programId: Program): Unit = gl.linkProgram(programId.unsafeCast<WebGLProgram>())
public override fun useProgram(programId: Program): Unit = gl.useProgram(programId.unsafeCast<WebGLProgram>())

public override fun detachShader(programId: Program, shaderId: Shader): Unit = gl.detachShader(programId.unsafeCast<WebGLProgram>(), shaderId.unsafeCast<WebGLShader>())
public override fun detachShader(programId: Program, shaderId: Shader): Unit =
gl.detachShader(programId.unsafeCast<WebGLProgram>(), shaderId.unsafeCast<WebGLShader>())

public override fun deleteProgram(programId: Program): Unit = gl.deleteProgram(programId.unsafeCast<WebGLProgram>())

public override fun getUniformLocation(programId: Program, name: String): UniformLocation? =
Expand Down Expand Up @@ -147,7 +149,17 @@ public class KglJs(private val gl: WebGLRenderingContext) : Kgl {
type: Int,
buffer: Buffer
) {
gl.texImage2D(target, level, internalFormat, width, height, border, format, type, buffer.getJsBufferWithOffset())
gl.texImage2D(
target,
level,
internalFormat,
width,
height,
border,
format,
type,
buffer.getJsBufferWithOffset()
)
}


Expand Down
2 changes: 2 additions & 0 deletions kgl/src/jvmMain/kotlin/com/danielgergely/kgl/Buffer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public actual class ByteBuffer(buffer: ByteBuffer) : Buffer(buffer) {
put(buffer)
position(0)
})

public actual constructor(size: Int) : this(alloc(size))

private companion object {
Expand Down Expand Up @@ -121,6 +122,7 @@ public actual class IntBuffer(private val buffer: IntBuffer) : Buffer(buffer) {
put(buffer)
position(0)
})

public actual constructor(size: Int) : this(alloc(size))

private companion object {
Expand Down
4 changes: 1 addition & 3 deletions kgl/src/jvmMain/kotlin/com/danielgergely/kgl/Types.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.danielgergely.kgl

import java.io.InputStream

public actual typealias Shader = Int

public actual typealias Program = Int
Expand All @@ -19,7 +17,7 @@ public actual class TextureResource(
public val type: Int,
public val data: Buffer,
) {
public actual fun dispose() { }
public actual fun dispose() {}
}

public actual typealias VertexArrayObject = Int
Expand Down
4 changes: 3 additions & 1 deletion kgl/src/nativeMain/kotlin/com/danielgergely/kgl/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public actual class TextureResource(
public val type: Int,
public val data: Buffer,
) {
public actual fun dispose() { data.dispose() }
public actual fun dispose() {
data.dispose()
}
}

public actual typealias VertexArrayObject = Int
Expand Down
Loading

0 comments on commit 340417a

Please sign in to comment.