Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Slim OpenglAG a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Apr 18, 2022
1 parent b1b91de commit abf97d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
12 changes: 9 additions & 3 deletions korgw/src/commonMain/kotlin/com/soywiz/korag/AG.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1185,9 +1185,15 @@ abstract class AG : AGFeatures, Extra by Extra.Mixin() {
return old
}

open fun readColor(bitmap: Bitmap32): Unit = TODO()
open fun readDepth(width: Int, height: Int, out: FloatArray): Unit = TODO()
open fun readStencil(bitmap: Bitmap8): Unit = TODO()
open fun readColor(bitmap: Bitmap32): Unit {
commandsSync { it.readPixels(0, 0, bitmap.width, bitmap.height, bitmap.data.ints, ReadKind.COLOR) }
}
open fun readDepth(width: Int, height: Int, out: FloatArray): Unit {
commandsSync { it.readPixels(0, 0, width, height, out, ReadKind.DEPTH) }
}
open fun readStencil(bitmap: Bitmap8): Unit {
commandsSync { it.readPixels(0, 0, bitmap.width, bitmap.height, bitmap.data, ReadKind.STENCIL) }
}
fun readDepth(out: FloatArray2): Unit = readDepth(out.width, out.height, out.data)
open fun readColorTexture(texture: Texture, width: Int = backWidth, height: Int = backHeight): Unit = TODO()
fun readColor() = Bitmap32(backWidth, backHeight).apply { readColor(this) }
Expand Down
12 changes: 0 additions & 12 deletions korgw/src/commonMain/kotlin/com/soywiz/korag/gl/OpenglAG.kt
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,6 @@ abstract class AGOpengl : AG() {
override fun toString(): String = "AGOpengl.GlTexture($tex)"
}

override fun readColor(bitmap: Bitmap32) {
commandsSync { it.readPixels(0, 0, bitmap.width, bitmap.height, bitmap.data.ints, ReadKind.COLOR) }
}

override fun readDepth(width: Int, height: Int, out: FloatArray) {
commandsSync { it.readPixels(0, 0, width, height, out, ReadKind.DEPTH) }
}

override fun readStencil(bitmap: Bitmap8) {
commandsSync { it.readPixels(0, 0, bitmap.width, bitmap.height, bitmap.data, ReadKind.STENCIL) }
}

override fun readColorTexture(texture: Texture, width: Int, height: Int) {
texture.bind()
gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, width, height, 0)
Expand Down

0 comments on commit abf97d4

Please sign in to comment.