From c8a6d81a0c14e12e57b0c90264263bd32416e332 Mon Sep 17 00:00:00 2001 From: Giuseppe Barbieri Date: Tue, 4 Apr 2023 11:55:57 +0200 Subject: [PATCH] 0.8.3.0-19 --- .github/workflows/build.yml | 54 ++++++++++++++++-------- build.gradle.kts | 29 +++++-------- gradle/wrapper/gradle-wrapper.properties | 4 +- settings.gradle.kts | 2 +- src/main/kotlin/gli_/Cache.kt | 2 +- src/main/kotlin/gli_/Image.kt | 6 +-- src/main/kotlin/gli_/Storage.kt | 6 +-- src/main/kotlin/gli_/Texture.kt | 2 +- src/main/kotlin/gli_/gl.kt | 1 + src/main/kotlin/gli_/gli.kt | 4 +- src/main/kotlin/gli_/loadDds.kt | 1 + src/main/kotlin/gli_/loadImage.kt | 35 +++++++-------- src/main/kotlin/gli_/misc.kt | 12 +----- src/test/java/gli_/test.java | 2 +- src/test/kotlin/gli_/coreTexture.kt | 8 ++-- 15 files changed, 86 insertions(+), 82 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca6b9be..f3c5ef0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,49 +3,66 @@ name: build on: [ push ] jobs: + linux: name: 'Linux' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 - - name: Set up JDK 1.11 - uses: actions/setup-java@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 with: - java-version: 11 + distribution: temurin + java-version: 8 - name: Grant execute permission for gradlew run: chmod +x gradlew # - name: Build with Gradle # run: ./gradlew build -x dokkaHtml -x dokkaHtmlJar - uses: burrunan/gradle-cache-action@v1 - name: Build scenery + name: Build with: - arguments: build #-x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar + arguments: assemble #-x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar # - name: Cleanup Gradle Cache # # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. # # Restoring these files from a GitHub Actions cache might cause problems for future builds. # run: | # rm -f ~/.gradle/caches/modules-2/modules-2.lock # rm -f ~/.gradle/caches/modules-2/gc.properties +# - name: Show Working directory content +# run: ls +# - uses: actions/checkout@master +# with: +# repository: kotlin-graphics/mary +# path: ./mary + - name: Show ../.. directory content + run: ls ../.. +# - name: move mary up +# run: mv ./mary ../.. +# - name: Show Working directory content +# run: ls +# - name: Show ../.. directory content +# run: ls ../.. windows: name: 'Windows' runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 - - name: Set up JDK 1.11 - uses: actions/setup-java@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 with: - java-version: 11 + distribution: temurin + java-version: 8 # - name: Build with Gradle # run: .\gradlew.bat build -x dokkaHtml -x dokkaHtmlJar - uses: burrunan/gradle-cache-action@v1 - name: Build scenery + name: Build with: - arguments: build #-x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar + arguments: assemble #-x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar # - name: Cleanup Gradle Cache # # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. # # Restoring these files from a GitHub Actions cache might cause problems for future builds. @@ -58,20 +75,21 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 - - name: Set up JDK 1.11 - uses: actions/setup-java@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 with: - java-version: 11 + distribution: temurin + java-version: 8 - name: Grant execute permission for gradlew run: chmod +x gradlew # - name: Build with Gradle # run: ./gradlew build -x dokkaHtml -x dokkaHtmlJar - uses: burrunan/gradle-cache-action@v1 - name: Build scenery + name: Build with: - arguments: build #-x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar + arguments: assemble #-x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar # - name: Cleanup Gradle Cache # # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. # # Restoring these files from a GitHub Actions cache might cause problems for future builds. diff --git a/build.gradle.kts b/build.gradle.kts index aea0e4c..ead434c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,12 +2,12 @@ import magik.createGithubPublication import magik.github import org.jetbrains.kotlin.gradle.dsl.KotlinCompile import org.lwjgl.lwjgl -import org.lwjgl.lwjgl.Module.* +import org.lwjgl.Lwjgl.Module.* plugins { kotlin("jvm") version embeddedKotlinVersion - id("org.lwjgl.plugin") version "0.0.29" - id("elect86.magik") version "0.3.1" + id("org.lwjgl.plugin") version "0.0.34" + id("elect86.magik") version "0.3.2" `maven-publish` } @@ -18,9 +18,7 @@ repositories { dependencies { - implementation("kotlin.graphics:glm:0.9.9.1-5") - implementation("kotlin.graphics:unsigned:3.3.31") - implementation("kotlin.graphics:kool:0.9.68") + api("kotlin.graphics:glm:0.9.9.1-6") // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-core listOf(/*"-batik",*/ "-bmp", "-core", "-icns", "-iff", "-jpeg", "-metadata", "-pcx", "-pdf", "-pict", "-pnm", @@ -32,14 +30,11 @@ dependencies { lwjgl { implementation(jemalloc, opengl) } - testImplementation("io.kotest:kotest-runner-junit5:5.4.1") - testImplementation("io.kotest:kotest-assertions-core:5.4.1") + testImplementation("io.kotest:kotest-runner-junit5:5.5.5") + testImplementation("io.kotest:kotest-assertions-core:5.5.5") } -kotlin.jvmToolchain { - this as JavaToolchainSpec - languageVersion.set(JavaLanguageVersion.of(8)) -} +kotlin.jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) } tasks { withType>().all { @@ -47,7 +42,7 @@ tasks { freeCompilerArgs += listOf("-opt-in=kotlin.RequiresOptIn") } } - withType().configureEach { useJUnitPlatform() } + test { useJUnitPlatform() } } publishing { @@ -57,11 +52,7 @@ publishing { suppressAllPomMetadataWarnings() } } - repositories { - github { - domain = "kotlin-graphics/mary" - } - } + repositories { github { domain = "kotlin-graphics/mary" } } } -java { withSourcesJar() } \ No newline at end of file +java.withSourcesJar() \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index de4e167..9c804a4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionSha256Sum=ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7 diff --git a/settings.gradle.kts b/settings.gradle.kts index 58040fb..a7bde13 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,5 +9,5 @@ pluginManagement { gradle.rootProject { group = "kotlin.graphics" - version = "0.8.3.0-18" + version = "0.8.3.0-19" } \ No newline at end of file diff --git a/src/main/kotlin/gli_/Cache.kt b/src/main/kotlin/gli_/Cache.kt index a68d3b7..f5ebbe5 100644 --- a/src/main/kotlin/gli_/Cache.kt +++ b/src/main/kotlin/gli_/Cache.kt @@ -38,7 +38,7 @@ class Cache { val index = indexCache(layer, face, level) val offset = storage.baseOffset(baseLayer + layer, baseFace + face, baseLevel + level) - baseAddresses[index] = storage.data().adr + offset + baseAddresses[index] = storage.data().adr.toLong() + offset } for (level in 0 until levels) { diff --git a/src/main/kotlin/gli_/Image.kt b/src/main/kotlin/gli_/Image.kt index f19c343..6e3af6e 100644 --- a/src/main/kotlin/gli_/Image.kt +++ b/src/main/kotlin/gli_/Image.kt @@ -39,7 +39,7 @@ class Image { storage = Storage(format, extent, 1, 1, 1) this.format = format baseLevel = 0 - data = MemoryUtil.memByteBuffer(storage!!.data().adr, storage!!.data().remaining()) + data = memByteBuffer(storage!!.data().adr.toLong(), storage!!.data().remaining()) size = computeSize(0) } @@ -51,7 +51,7 @@ class Image { storage = Storage(image.storage!!) this.format = format baseLevel = image.baseLevel - data = MemoryUtil.memByteBuffer(image.data!!.adr, image.data!!.remaining()) + data = memByteBuffer(image.data!!.adr.toLong(), image.data!!.remaining()) size = image.size assert(format.blockSize == image.format.blockSize) } @@ -71,7 +71,7 @@ class Image { fun computeData(baseLayer: Int, baseFace: Int, baseLevel: Int): ByteBuffer { val baseOffset = storage!!.baseOffset(baseLayer, baseFace, baseLevel) - return memByteBuffer(storage!!.data().adr + baseOffset, storage!!.data().remaining() - baseOffset) + return memByteBuffer(storage!!.data().adr.toLong() + baseOffset, storage!!.data().remaining() - baseOffset) } fun computeSize(level: Int): Int { diff --git a/src/main/kotlin/gli_/Storage.kt b/src/main/kotlin/gli_/Storage.kt index 1619a33..ad93161 100644 --- a/src/main/kotlin/gli_/Storage.kt +++ b/src/main/kotlin/gli_/Storage.kt @@ -43,7 +43,7 @@ class Storage { blockCount = Vec3i(storage.blockCount) blockExtent = Vec3i(storage.blockExtent) extent = Vec3i(storage.extent) - data = MemoryUtil.memByteBuffer(storage.data!!.adr, storage.data!!.remaining()) + data = MemoryUtil.memByteBuffer(storage.data!!.adr.toLong(), storage.data!!.remaining()) } constructor(format: Format, extent: Vec3i, layers: Int, faces: Int, levels: Int) { @@ -120,8 +120,8 @@ class Storage { val baseOffsetSrc = storageSrc.baseOffset(layerSrc, faceSrc, levelSrc) val baseOffsetDst = baseOffset(layerDst, faceDst, levelDst) - val imageSrc = storageSrc.data!!.adr + baseOffsetSrc - val imageDst = data!!.adr + baseOffsetDst + val imageSrc = storageSrc.data!!.adr.toLong() + baseOffsetSrc + val imageDst = data!!.adr.toLong() + baseOffsetDst for (blockIndexZ in 0 until blockCount.z) for (blockIndexY in 0 until blockCount.y) { diff --git a/src/main/kotlin/gli_/Texture.kt b/src/main/kotlin/gli_/Texture.kt index 8aa1456..d64f4b6 100644 --- a/src/main/kotlin/gli_/Texture.kt +++ b/src/main/kotlin/gli_/Texture.kt @@ -262,7 +262,7 @@ open class Texture { blockData: T ) { val baseOffset = storage!!.baseOffset(layer, face, level) - val baseAddress = storage!!.data().adr + baseOffset + val baseAddress = storage!!.data().adr.toLong() + baseOffset val blockOffset = texelOffset / storage!!.blockExtent val blockExtent = texelExtent / storage!!.blockExtent + blockOffset diff --git a/src/main/kotlin/gli_/gl.kt b/src/main/kotlin/gli_/gl.kt index e67a4cd..abbd791 100644 --- a/src/main/kotlin/gli_/gl.kt +++ b/src/main/kotlin/gli_/gl.kt @@ -5,6 +5,7 @@ import gli_.detail.FORMAT_PROPERTY_BGRA_TYPE_BIT import gli_.gl.ExternalFormat.* import gli_.gl.InternalFormat.* import gli_.gl.TypeFormat.* +import glm_.has import java.nio.ByteBuffer import java.nio.IntBuffer import gli_.gl.ExternalFormat.NONE as NONE_ diff --git a/src/main/kotlin/gli_/gli.kt b/src/main/kotlin/gli_/gli.kt index 1f013ce..2451bb7 100644 --- a/src/main/kotlin/gli_/gli.kt +++ b/src/main/kotlin/gli_/gli.kt @@ -1,6 +1,7 @@ package gli_ import glm_.L +import kool.Address import org.lwjgl.system.MemoryUtil @@ -59,11 +60,12 @@ class Java { } fun memCopy(src: Long, dst: Long, bytes: Int) = MemoryUtil.memCopy(src, dst, bytes.L) +fun memCopy(src: Address, dst: Address, bytes: Int) = memCopy(src.toLong(), dst.toLong(), bytes) const val GLI_VERSION_MAJOR = 0 const val GLI_VERSION_MINOR = 8 const val GLI_VERSION_PATCH = 3 const val GLI_VERSION_REVISION = 0 -const val GLI_VERSION_BUILD = 18 +const val GLI_VERSION_BUILD = 19 const val GLI_VERSION = GLI_VERSION_MAJOR * 1_000 + GLI_VERSION_MINOR * 100 + GLI_VERSION_PATCH * 10 + GLI_VERSION_REVISION + GLI_VERSION_BUILD / 10f diff --git a/src/main/kotlin/gli_/loadDds.kt b/src/main/kotlin/gli_/loadDds.kt index 405c8f5..bb36e31 100644 --- a/src/main/kotlin/gli_/loadDds.kt +++ b/src/main/kotlin/gli_/loadDds.kt @@ -5,6 +5,7 @@ import gli_.dx.has import gli_.dx.or import glm_.b import glm_.glm +import glm_.has import glm_.i import glm_.vec3.Vec3i import kool.* diff --git a/src/main/kotlin/gli_/loadImage.kt b/src/main/kotlin/gli_/loadImage.kt index e7764d8..3a175a3 100644 --- a/src/main/kotlin/gli_/loadImage.kt +++ b/src/main/kotlin/gli_/loadImage.kt @@ -1,5 +1,6 @@ package gli_ +import glm_.b import glm_.or import glm_.vec3.Vec3i import kool.* @@ -37,9 +38,9 @@ interface loadImage { val dst = data() var i = 0 (image.raster.dataBuffer as DataBufferInt).data.forEach { - dst[i++] = it ushr 16 - dst[i++] = it ushr 8 - dst[i++] = it + dst[i++] = (it ushr 16).b + dst[i++] = (it ushr 8).b + dst[i++] = it.b } } TYPE_INT_ARGB -> Texture(Target._2D, Format.RGBA8_UNORM_PACK8, extent, 1, 1, 1).apply { @@ -47,10 +48,10 @@ interface loadImage { val dst = data() var i = 0 (image.raster.dataBuffer as DataBufferInt).data.forEach { - dst[i++] = it ushr 16 - dst[i++] = it ushr 8 - dst[i++] = it - dst[i++] = it ushr 24 + dst[i++] = (it ushr 16).b + dst[i++] = (it ushr 8).b + dst[i++] = it.b + dst[i++] = (it ushr 24).b } } TYPE_INT_ARGB_PRE -> Texture(Target._2D, Format.RGBA8_UNORM_PACK8, extent, 1, 1, 1).apply { @@ -59,10 +60,10 @@ interface loadImage { var i = 0 (image.raster.dataBuffer as DataBufferInt).data.forEach { val a = it ushr 24 - dst[i++] = (it ushr 16) / a - dst[i++] = (it ushr 8) / a - dst[i++] = it / a - dst[i++] = a + dst[i++] = ((it ushr 16) / a).b + dst[i++] = ((it ushr 8) / a).b + dst[i++] = (it / a).b + dst[i++] = a.b } } TYPE_INT_BGR -> Texture(Target._2D, Format.RGB8_UNORM_PACK8, extent, 1, 1, 1).apply { @@ -70,9 +71,9 @@ interface loadImage { val dst = data() var i = 0 (image.raster.dataBuffer as DataBufferInt).data.forEach { - dst[i++] = it - dst[i++] = it ushr 8 - dst[i++] = it ushr 16 + dst[i++] = it.b + dst[i++] = (it ushr 8).b + dst[i++] = (it ushr 16).b } } TYPE_3BYTE_BGR -> Texture(Target._2D, Format.RGB8_UNORM_PACK8, extent, 1, 1, 1).apply { @@ -102,9 +103,9 @@ interface loadImage { val src = (image.raster.dataBuffer as DataBufferByte).data for (i in src.indices step 4) { val a = src[i] - dst[i] = src[i + 3] / a - dst[i + 1] = src[i + 2] / a - dst[i + 2] = src[i + 1] / a + dst[i] = (src[i + 3] / a).b + dst[i + 1] = (src[i + 2] / a).b + dst[i + 2] = (src[i + 1] / a).b dst[i + 3] = a } } diff --git a/src/main/kotlin/gli_/misc.kt b/src/main/kotlin/gli_/misc.kt index c1f4abf..4507f02 100644 --- a/src/main/kotlin/gli_/misc.kt +++ b/src/main/kotlin/gli_/misc.kt @@ -1,20 +1,11 @@ package gli_ import glm_.vec2.Vec2i -import kool.lib.toByteArray -import kool.pos -import org.lwjgl.BufferUtils import java.awt.image.BufferedImage -import java.io.File -import java.net.URI import java.nio.ByteBuffer import java.nio.file.Path import java.nio.file.Paths import java.util.* -import javax.imageio.ImageIO - -infix fun Int.has(b: Int) = (this and b) != 0 -infix fun Int.hasnt(b: Int) = (this and b) == 0 fun pathOf(filename: String, vararg more: String): Path = Paths.get(filename, *more) //fun URI.toPath(): Path = Paths.get(this) @@ -34,8 +25,7 @@ fun ByteBuffer.flipY(width: Int, height: Int) { } } -operator fun Array.get(index: Format): dx.Format = - get(index.i - Format.FIRST.i) +operator fun Array.get(index: Format): dx.Format = get(index.i - Format.FIRST.i) fun BufferedImage.flipY() { var scanline1: Any? = null diff --git a/src/test/java/gli_/test.java b/src/test/java/gli_/test.java index 12c300e..142d1d8 100644 --- a/src/test/java/gli_/test.java +++ b/src/test/java/gli_/test.java @@ -7,7 +7,7 @@ import java.nio.IntBuffer; import static gli_.Java.gli; -import static kool.Fake_constructorsKt.IntBuffer; +import static kool.BuildersKt.IntBuffer; import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL13.glCompressedTexSubImage2D; import static org.lwjgl.opengl.GL42.glTexStorage2D; diff --git a/src/test/kotlin/gli_/coreTexture.kt b/src/test/kotlin/gli_/coreTexture.kt index 09be161..9e4e73c 100644 --- a/src/test/kotlin/gli_/coreTexture.kt +++ b/src/test/kotlin/gli_/coreTexture.kt @@ -374,7 +374,7 @@ class coreTexture : StringSpec() { for (layerIndex in 0 until it.layers()) for (levelIndex in 0 until it.levels()) { val baseAddress = it.data(layerIndex, 0, levelIndex).adr - error += if (baseAddress != NULL) 0 else 1 + error += if (baseAddress != 0uL) 0 else 1 } } } @@ -433,7 +433,7 @@ class coreTexture : StringSpec() { error += if (extent.x != 0) 0 else 1 error += if (extent.y != 0) 0 else 1 error += if (size != 0) 0 else 1 - error += if (baseAddress != NULL) 0 else 1 + error += if (baseAddress != 0uL) 0 else 1 } } } @@ -459,7 +459,7 @@ class coreTexture : StringSpec() { for (layerIndex in 0 until it.layers()) for (levelIndex in 0 until it.levels()) { val baseAddress = it.data(layerIndex, 0, levelIndex).adr - error += if (baseAddress != NULL) 0 else 1 + error += if (baseAddress != 0uL) 0 else 1 } } } @@ -518,7 +518,7 @@ class coreTexture : StringSpec() { error += if (extent.x != 0) 0 else 1 error += if (extent.y != 0) 0 else 1 error += if (size != 0) 0 else 1 - error += if (baseAddress != NULL) 0 else 1 + error += if (baseAddress != 0uL) 0 else 1 } } }