diff --git a/build.gradle b/build.gradle index f72dec7..0117e26 100644 --- a/build.gradle +++ b/build.gradle @@ -4,8 +4,8 @@ plugins { id 'maven' id 'java' id 'java-library' - id "org.jetbrains.kotlin.jvm" version "1.3.50" - id "com.github.johnrengelman.shadow" version '5.1.0' + id "org.jetbrains.kotlin.jvm" version "1.3.61" + id "com.github.johnrengelman.shadow" version '5.2.0' } // jitpack @@ -14,11 +14,11 @@ group = 'com.github.kotlin-graphics' ext { moduleName = 'com.github.kotlin_graphics.gli' kotlin = 'org.jetbrains.kotlin:kotlin' - kotlin_version = '1.3.50' - kotlintest_version = '3.4.0' - glm_version = 'a484ec1181813912c5a69d3a6706a994ca138eff' - unsigned_version = 'c81c2e39fb9e10403650c1b371b8573fc745bfb4' - kool_version = '0ef9ad97d0c709de3cda4d7f05e74bff883b00a6' + kotlin_version = '1.3.61' + kotlintest_version = '3.4.2' + glm_version = '1b4ac18dd1a3c23440d3f33596688aac60bc0141' + unsigned_version = '18131d0fe0b7465a145a4502d31452c5ae0e59a1' + kool_version = 'fcf04b2c03b8949d9d9a8b0a580082e927903510' lwjgl_version = "3.2.3" lwjgl_natives = current() == WINDOWS ? "windows" : current() == LINUX ? "linux" : "macos" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 433b2f1..eabaa30 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip diff --git a/src/main/kotlin/gli_/Texture.kt b/src/main/kotlin/gli_/Texture.kt index 5122205..756e97d 100644 --- a/src/main/kotlin/gli_/Texture.kt +++ b/src/main/kotlin/gli_/Texture.kt @@ -47,10 +47,10 @@ open class Texture { val formatSwizzle = format.formatInfo.swizzles return with(field) { Swizzles( - if (r.isChannel()) formatSwizzle[r.i] else r, - if (g.isChannel()) formatSwizzle[g.i] else g, - if (b.isChannel()) formatSwizzle[b.i] else b, - if (a.isChannel()) formatSwizzle[a.i] else a) + if (r.isChannel) formatSwizzle[r.i] else r, + if (g.isChannel) formatSwizzle[g.i] else g, + if (b.isChannel) formatSwizzle[b.i] else b, + if (a.isChannel) formatSwizzle[a.i] else a) } } private set diff --git a/src/main/kotlin/gli_/detail.kt b/src/main/kotlin/gli_/detail.kt index 6040e0d..c94c984 100644 --- a/src/main/kotlin/gli_/detail.kt +++ b/src/main/kotlin/gli_/detail.kt @@ -52,9 +52,8 @@ object detail { class FormatInfo(val blockSize: Int, val blockExtend: Vec3i, val component: Int, val swizzles: Swizzles, val flags: Int) - internal val tableF by lazy { - - val table = arrayOf( + internal val tableFormatInfos: Array by lazy { + arrayOf( FormatInfo(1, Vec3i(1, 1, 1), 2, Swizzles(RED, GREEN, ZERO, ONE), PACKED8_BIT or NORMALIZED_BIT or UNSIGNED_BIT or DDS_GLI_EXT_BIT), //FORMAT_R4G4_UNORM, FormatInfo(2, Vec3i(1, 1, 1), 4, Swizzles(RED, GREEN, BLUE, ALPHA), PACKED16_BIT or NORMALIZED_BIT or UNSIGNED_BIT or DDS_GLI_EXT_BIT), //FORMAT_RGBA4_UNORM, FormatInfo(2, Vec3i(1, 1, 1), 4, Swizzles(BLUE, GREEN, RED, ALPHA), PACKED16_BIT or NORMALIZED_BIT or UNSIGNED_BIT), //FORMAT_BGRA4_UNORM, @@ -296,17 +295,16 @@ object detail { FormatInfo(1, Vec3i(1, 1, 1), 3, Swizzles(RED, GREEN, BLUE, ONE), PACKED8_BIT or NORMALIZED_BIT or UNSIGNED_BIT or DDS_GLI_EXT_BIT) //FORMAT_RG3B2_UNORM_PACK8, ) - - assert(table.size == FORMAT_COUNT, { "GLI error: format descriptor list doesn't match number of supported formats" }) - - table + .apply { + assert(size == Format.COUNT) { "GLI error: format descriptor list doesn't match number of supported formats" } + } } internal val tableS by lazy { val table = arrayOf(gl.Swizzle.RED, gl.Swizzle.GREEN, gl.Swizzle.BLUE, gl.Swizzle.ALPHA, gl.Swizzle.ZERO, gl.Swizzle.ONE) - assert(table.size == SWIZZLE_COUNT, { "GLI error: swizzle descriptor list doesn't match number of supported swizzles" }) + assert(table.size == Swizzle.COUNT) { "GLI error: swizzle descriptor list doesn't match number of supported swizzles" } table } diff --git a/src/main/kotlin/gli_/dx.kt b/src/main/kotlin/gli_/dx.kt index 3bc850e..562a936 100644 --- a/src/main/kotlin/gli_/dx.kt +++ b/src/main/kotlin/gli_/dx.kt @@ -8,6 +8,7 @@ import glm_.i import glm_.vec4.Vec4i import gli_.detail.has import gli_.detail.hasnt +import gli_.get /** * Created by elect on 02/04/17. @@ -17,36 +18,32 @@ import gli_.detail.hasnt object dx { fun translate(format: gli_.Format): dx.Format { - assert(format.i in FORMAT_FIRST.i..FORMAT_LAST.i) - return table[format.i - FORMAT_FIRST.i] + assert(format.isValid) + return table[format] } - fun find(fourCC: D3dfmt) = gli_.Format.of((FORMAT_FIRST.i..FORMAT_LAST.i) - .firstOrNull { table[it - FORMAT_FIRST.i].d3DFormat == fourCC } ?: FORMAT_INVALID) + fun find(fourCC: D3dfmt): gli_.Format = + (gli_.Format.FIRST..gli_.Format.LAST) + .firstOrNull { table[it].d3DFormat == fourCC } + ?: gli_.Format.UNDEFINED fun find(fourCC: D3dfmt, format: DxgiFormat): gli_.Format { assert(fourCC == DX10 || fourCC == GLI1) - var result = FORMAT_INVALID - - for (currentFormat in FORMAT_FIRST..FORMAT_LAST) { + for (currentFormat in gli_.Format.FIRST..gli_.Format.LAST) { val info = currentFormat.formatInfo - val dxFormat = table[currentFormat.i - FORMAT_FIRST.i] + val dxFormat = table[currentFormat] - if (fourCC == GLI1 && info.flags has detail.Cap.DDS_GLI_EXT_BIT && dxFormat.dxgiFormat.gli == format.gli) { - result = currentFormat.i - break - } + if (fourCC == GLI1 && info.flags has detail.Cap.DDS_GLI_EXT_BIT && dxFormat.dxgiFormat.gli == format.gli) + return currentFormat - if (fourCC == DX10 && info.flags hasnt detail.Cap.DDS_GLI_EXT_BIT && dxFormat.dxgiFormat.dds == format.dds) { - result = currentFormat.i - break - } + if (fourCC == DX10 && info.flags hasnt detail.Cap.DDS_GLI_EXT_BIT && dxFormat.dxgiFormat.dds == format.dds) + return currentFormat } - return gli_.Format.of(result) + return gli_.Format.UNDEFINED } fun isDdsExt(target: Target, format: gli_.Format): Boolean { @@ -519,8 +516,8 @@ object dx { : this(ddPixelFormat, d3DFormat, DxgiFormat(dxgiFormatGLI), mask) } - private val table by lazy { - val table = arrayOf( + private val table: Array by lazy { + arrayOf( Format(FOURCC, GLI1, RG4_UNORM_GLI, Vec4i(0x000F, 0x00F0, 0x0000, 0x0000)), //FORMAT_RG4_UNORM, Format(FOURCC, GLI1, RGBA4_UNORM_GLI, Vec4i(0x000F, 0x00F0, 0x0F00, 0xF000)), //FORMAT_RGBA4_UNORM, Format(FOURCC, A4R4G4B4, B4G4R4A4_UNORM, Vec4i(0x0F00, 0x00F0, 0x000F, 0xF000)), //FORMAT_BGRA4_UNORM, @@ -761,10 +758,8 @@ object dx { Format(FOURCC, DX10, B8G8R8X8_UNORM_SRGB, Vec4i(0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000)), //FORMAT_BGR8_SRGB_PACK32, Format(FOURCC, GLI1, R3G3B2_UNORM_GLI, Vec4i(0x70, 0x38, 0xC0, 0x00)) //FORMAT_RG3B2_UNORM, - ) - - assert(table.size == FORMAT_COUNT, { "GLI error: format descriptor list doesn't match number of supported formats" }) - - table + ).apply { + assert(size == gli_.Format.COUNT) { "GLI error: format descriptor list doesn't match number of supported formats" } + } } } \ No newline at end of file diff --git a/src/main/kotlin/gli_/format.kt b/src/main/kotlin/gli_/format.kt index 26a26fe..d659536 100644 --- a/src/main/kotlin/gli_/format.kt +++ b/src/main/kotlin/gli_/format.kt @@ -2,7 +2,7 @@ package gli_ import gli_.detail.Cap.* import gli_.detail.has -import gli_.detail.tableF +import gli_.detail.tableFormatInfos import java.nio.ByteBuffer import java.nio.IntBuffer @@ -256,15 +256,21 @@ enum class Format { RG3B2_UNORM_PACK8; - val i = ordinal // INVALID -> -1 + val i = ordinal companion object { - infix fun of(i: Int) = values().find { it.i == i } ?: UNDEFINED + val FIRST: Format = RG4_UNORM_PACK8 + val LAST: Format = RG3B2_UNORM_PACK8 + val COUNT = LAST.i - FIRST.i + 1 + infix fun of(i: Int): Format = values().find { it.i == i } ?: UNDEFINED } - val isValid get() = this in FORMAT_FIRST..FORMAT_LAST + val isValid: Boolean + get() = this != UNDEFINED - val formatInfo by lazy { tableF[i - FORMAT_FIRST.i] } + /** *get_format_info */ + val formatInfo: detail.FormatInfo + get() = tableFormatInfos[i - FIRST.i].also { assert(isValid) } val bitsPerPixel by lazy { formatInfo.blockSize * 8 / (formatInfo.blockExtend.x * formatInfo.blockExtend.y * formatInfo.blockExtend.z) } @@ -315,8 +321,11 @@ enum class Format { override fun hasNext() = next < endInclusive } - override fun contains(value: Format) = value.i in start.i..endInclusive.i + override fun contains(value: Format): Boolean = + value.i in start.i..endInclusive.i } + + operator fun minus(format: Format): Int = i - format.i } @@ -332,25 +341,20 @@ enum class Swizzle { val i = ordinal companion object { - infix fun of(i: Int) = values().first { it.i == i } + val FIRST = RED + val LAST = ONE + val CHANNEL_FIRST = RED + val CHANNEL_LAST = ALPHA + val COUNT = LAST.i - FIRST.i + 1 + infix fun of(i: Int): Swizzle = values().first { it.i == i } } - fun isChannel() = this in SWIZZLE_CHANNEL_FIRST..SWIZZLE_CHANNEL_LAST + val isChannel: Boolean + get () = this in CHANNEL_FIRST..CHANNEL_LAST } -val FORMAT_FIRST = Format.RG4_UNORM_PACK8 -val FORMAT_LAST = Format.RG3B2_UNORM_PACK8 -val FORMAT_INVALID = -1 -val FORMAT_COUNT = FORMAT_LAST.i - FORMAT_FIRST.i + 1 - -val SWIZZLE_FIRST = Swizzle.RED -val SWIZZLE_LAST = Swizzle.ONE -val SWIZZLE_CHANNEL_FIRST = Swizzle.RED -val SWIZZLE_CHANNEL_LAST = Swizzle.ALPHA -val SWIZZLE_COUNT = SWIZZLE_LAST.i - SWIZZLE_FIRST.i + 1 - data class Swizzles(var r: Swizzle, var g: Swizzle, var b: Swizzle, var a: Swizzle) { - constructor(x: Int, y: Int, z: Int, w: Int) : this(Swizzle.of(x), Swizzle.of(y), Swizzle.of(z), Swizzle.of(w)) + constructor(x: Int, y: Int, z: Int, w: Int) : this(Swizzle of x, Swizzle of y, Swizzle of z, Swizzle of w) constructor(swizzle: Swizzle) : this(swizzle, swizzle, swizzle, swizzle) constructor(swizzles: Swizzles) : this(swizzles.r, swizzles.g, swizzles.b, swizzles.a) constructor() : this(Swizzle.RED, Swizzle.GREEN, Swizzle.BLUE, Swizzle.ALPHA) diff --git a/src/main/kotlin/gli_/gl.kt b/src/main/kotlin/gli_/gl.kt index b834277..e67a4cd 100644 --- a/src/main/kotlin/gli_/gl.kt +++ b/src/main/kotlin/gli_/gl.kt @@ -27,15 +27,15 @@ object gl { updateTable() } - fun translate(texture: Texture) = translate(texture.target) to translate(texture.format, texture.swizzles) + fun translate(texture: Texture): Pair = translate(texture.target) to translate(texture.format, texture.swizzles) - fun translate(target: gli_.Target) = tableT[target.i] + fun translate(target: gli_.Target): Target = tableTargets[target.i] fun translate(format: gli_.Format, swizzles: gli_.Swizzles): Format { - assert(format in FORMAT_FIRST..FORMAT_LAST) + assert(format.isValid) - val formatDesc = tableF[format.i - FORMAT_FIRST.i] + val formatDesc = tableFormatDesc[format - gli_.Format.FIRST] return Format(formatDesc.internal, formatDesc.external, formatDesc.type, computeSwizzle(formatDesc, swizzles)) } @@ -54,26 +54,27 @@ object gl { fun find(internalFormat: InternalFormat, externalFormat: ExternalFormat, type: TypeFormat): gli_.Format { /* Important, filter internalFormat by i, because some values may be double, such as: Internal.LUMINANCE8 has same value of Internal.L8 */ - val format = tableF.find { it.internal.i == internalFormat.i && it.external == externalFormat && it.type == type } - return if (format == null) gli_.Format.UNDEFINED - else gli_.Format.of(tableF.indexOf(format) + 1) // +1 to offset UNDEFINED + val format = tableFormatDesc.find { it.internal.i == internalFormat.i && it.external == externalFormat && it.type == type } + return when (format) { + null -> gli_.Format.UNDEFINED + else -> gli_.Format.of(tableFormatDesc.indexOf(format) + gli_.Format.FIRST.i) // +FIRST to offset UNDEFINED + } } - private val tableT by lazy { - val table = arrayOf( - gl.Target._1D, - gl.Target._1D_ARRAY, - gl.Target._2D, - gl.Target._2D_ARRAY, - gl.Target._3D, - gl.Target.RECT, - gl.Target.RECT_ARRAY, - gl.Target.CUBE, - gl.Target.CUBE_ARRAY) - - assert(table.size == TARGET_COUNT, { "GLI error: target descriptor list doesn't match number of supported targets" }) - - table + private val tableTargets: Array by lazy { + arrayOf( + Target._1D, + Target._1D_ARRAY, + Target._2D, + Target._2D_ARRAY, + Target._3D, + Target.RECT, + Target.RECT_ARRAY, + Target.CUBE, + Target.CUBE_ARRAY) + .apply { + assert(size == gli_.Target.COUNT) { "GLI error: target descriptor list doesn't match number of supported targets" } + } } private class FormatDesc(val internal: InternalFormat, val external: ExternalFormat, val type: TypeFormat, val properties: Int) @@ -426,13 +427,13 @@ object gl { else -> throw Error() } - infix fun to(buffer: ByteBuffer):ByteBuffer = buffer.putInt(0, r.i).putInt(1, g.i).putInt(2, b.i).putInt(3, a.i) + infix fun to(buffer: ByteBuffer): ByteBuffer = buffer.putInt(0, r.i).putInt(1, g.i).putInt(2, b.i).putInt(3, a.i) infix fun to(intBuffer: IntBuffer): IntBuffer = intBuffer.put(0, r.i).put(1, g.i).put(2, b.i).put(3, a.i) } class Format(val internal: InternalFormat, val external: ExternalFormat, val type: TypeFormat, val swizzles: Swizzles) - private lateinit var tableF: Array + private lateinit var tableFormatDesc: Array fun updateTable() { @@ -462,7 +463,7 @@ object gl { val typeF16 = if (profile == Profile.ES20) TypeFormat.F16_OES else TypeFormat.F16 - tableF = arrayOf( + tableFormatDesc = arrayOf( FormatDesc(RG4_EXT, RG, UINT8_RG4_REV_GTC, 0), //FORMAT_R4G4_UNORM, FormatDesc(RGBA4, RGBA, UINT16_RGBA4_REV, 0), //FORMAT_RGBA4_UNORM, FormatDesc(RGBA4, RGBA, UINT16_RGBA4, FORMAT_PROPERTY_BGRA_TYPE_BIT), //FORMAT_BGRA4_UNORM, @@ -704,6 +705,6 @@ object gl { FormatDesc(RG3B2, RGB, UINT8_RG3B2_REV, 0) //FORMAT_RG3B2_UNORM, ) - .apply { assert(size == FORMAT_COUNT, { "GLI error: format descriptor list doesn't match number of supported formats" }) } + .apply { assert(size == gli_.Format.COUNT) { "GLI error: format descriptor list doesn't match number of supported formats" } } } } diff --git a/src/main/kotlin/gli_/gli.kt b/src/main/kotlin/gli_/gli.kt index 7196570..47edda4 100644 --- a/src/main/kotlin/gli_/gli.kt +++ b/src/main/kotlin/gli_/gli.kt @@ -31,11 +31,13 @@ object gli : LINEAR; val i = ordinal - 1 - } - val FILTER_FIRST = Filter.NEAREST - val FILTER_LAST = Filter.LINEAR - val FILTER_COUNT = FILTER_LAST.i - FILTER_FIRST.i + 1 + companion object { + val FIRST = NEAREST + val LAST = LINEAR + val COUNT = LAST.i - FIRST.i + 1 + } + } } @@ -54,5 +56,5 @@ 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 = 12 +const val GLI_VERSION_BUILD = 13 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_/loadKtx.kt b/src/main/kotlin/gli_/loadKtx.kt index 653837b..3b9b231 100644 --- a/src/main/kotlin/gli_/loadKtx.kt +++ b/src/main/kotlin/gli_/loadKtx.kt @@ -63,7 +63,7 @@ interface loadKtx { gl.InternalFormat.of(header.glInternalFormat), gl.ExternalFormat.of(header.glFormat), gl.TypeFormat.of(header.glType)) - assert(format != Format.UNDEFINED) + assert(format.isValid) val blockSize = format.blockSize diff --git a/src/main/kotlin/gli_/misc.kt b/src/main/kotlin/gli_/misc.kt index 829dee8..67122ef 100644 --- a/src/main/kotlin/gli_/misc.kt +++ b/src/main/kotlin/gli_/misc.kt @@ -33,4 +33,7 @@ fun flipY(buffer: ByteArray, width: Int, height: Int) : ByteBuffer { result.pos = 0 return result -} \ No newline at end of file +} + +operator fun Array.get(index: Format): dx.Format = + get(index.i - Format.FIRST.i) \ No newline at end of file diff --git a/src/main/kotlin/gli_/saveDds.kt b/src/main/kotlin/gli_/saveDds.kt index ae49d8c..37b4e51 100644 --- a/src/main/kotlin/gli_/saveDds.kt +++ b/src/main/kotlin/gli_/saveDds.kt @@ -23,7 +23,6 @@ interface saveDds { fun getDimension(target: Target): Int { - val table = arrayOf( detail.D3d10resourceDimension.TEXTURE1D, //TARGET_1D, detail.D3d10resourceDimension.TEXTURE1D, //TARGET_1D_ARRAY, @@ -35,7 +34,7 @@ interface saveDds { detail.D3d10resourceDimension.TEXTURE2D, //TARGET_CUBE, detail.D3d10resourceDimension.TEXTURE2D //TARGET_CUBE_ARRAY ) - assert(table.size == TARGET_COUNT, { "Table needs to be updated" }) + assert(table.size == Target.COUNT) { "Table needs to be updated" } return table[target.i].i } diff --git a/src/main/kotlin/gli_/target.kt b/src/main/kotlin/gli_/target.kt index 10623e8..a54820a 100644 --- a/src/main/kotlin/gli_/target.kt +++ b/src/main/kotlin/gli_/target.kt @@ -46,11 +46,9 @@ enum class Target { } companion object { - infix fun of(int: Int) = values().first { it.i == int } + val FIRST = _1D + val LAST = CUBE_ARRAY + val COUNT = LAST.i - FIRST.i + 1 + infix fun of(int: Int): Target = values().first { it.i == int } } -} - -val TARGET_FIRST = Target._1D -val TARGET_LAST = Target.CUBE_ARRAY -val TARGET_COUNT = Target.values().size - 1 // INVALID -val TARGET_INVALID = -1 \ No newline at end of file +} \ No newline at end of file diff --git a/src/test/kotlin/gli_/coreFormat.kt b/src/test/kotlin/gli_/coreFormat.kt index 3ee7b8a..f24bbad 100644 --- a/src/test/kotlin/gli_/coreFormat.kt +++ b/src/test/kotlin/gli_/coreFormat.kt @@ -10,14 +10,14 @@ class coreFormat : StringSpec() { "valid" { - for (format in FORMAT_FIRST .. FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) format.isValid shouldBe true Format.UNDEFINED.isValid shouldBe false } "component" { - for (formatIndex in FORMAT_FIRST.i until FORMAT_COUNT) { + for (formatIndex in Format.FIRST.i until Format.COUNT) { val components = Format.values().first { it.i == formatIndex }.componentCount (components in 1..4) shouldBe true } diff --git a/src/test/kotlin/gli_/coreLoadGen1d.kt b/src/test/kotlin/gli_/coreLoadGen1d.kt index 5fd9c58..82524a4 100644 --- a/src/test/kotlin/gli_/coreLoadGen1d.kt +++ b/src/test/kotlin/gli_/coreLoadGen1d.kt @@ -11,7 +11,7 @@ class coreLoadGen1d : StringSpec() { "load 1d" { - for (format in FORMAT_FIRST .. FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val target = Target._1D diff --git a/src/test/kotlin/gli_/coreLoadGen1dArray.kt b/src/test/kotlin/gli_/coreLoadGen1dArray.kt index 45148ac..0823e01 100644 --- a/src/test/kotlin/gli_/coreLoadGen1dArray.kt +++ b/src/test/kotlin/gli_/coreLoadGen1dArray.kt @@ -11,7 +11,7 @@ class coreLoadGen1dArray : StringSpec() { "load 1d array" { - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val target = Target._1D_ARRAY diff --git a/src/test/kotlin/gli_/coreLoadGen2d.kt b/src/test/kotlin/gli_/coreLoadGen2d.kt index 2ed7d29..a336942 100644 --- a/src/test/kotlin/gli_/coreLoadGen2d.kt +++ b/src/test/kotlin/gli_/coreLoadGen2d.kt @@ -11,7 +11,7 @@ class coreLoadGen2d : StringSpec() { "load 2d" { - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val target = Target._2D diff --git a/src/test/kotlin/gli_/coreLoadGen2dArray.kt b/src/test/kotlin/gli_/coreLoadGen2dArray.kt index c698c8d..7ccfa81 100644 --- a/src/test/kotlin/gli_/coreLoadGen2dArray.kt +++ b/src/test/kotlin/gli_/coreLoadGen2dArray.kt @@ -11,7 +11,7 @@ class coreLoadGen2dArray : StringSpec() { "load 2d array" { - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val target = Target._2D_ARRAY diff --git a/src/test/kotlin/gli_/coreLoadGen3d.kt b/src/test/kotlin/gli_/coreLoadGen3d.kt index 300ab8d..22b0f12 100644 --- a/src/test/kotlin/gli_/coreLoadGen3d.kt +++ b/src/test/kotlin/gli_/coreLoadGen3d.kt @@ -11,7 +11,7 @@ class coreLoadGen3d : StringSpec() { "load 3d" { - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val target = Target._3D diff --git a/src/test/kotlin/gli_/coreLoadGenCube.kt b/src/test/kotlin/gli_/coreLoadGenCube.kt index 7594eef..73a1e5d 100644 --- a/src/test/kotlin/gli_/coreLoadGenCube.kt +++ b/src/test/kotlin/gli_/coreLoadGenCube.kt @@ -11,7 +11,7 @@ class coreLoadGenCube : StringSpec() { "load cube" { - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val target = Target.CUBE diff --git a/src/test/kotlin/gli_/coreLoadGenCubeArray.kt b/src/test/kotlin/gli_/coreLoadGenCubeArray.kt index 66b8230..fb5634a 100644 --- a/src/test/kotlin/gli_/coreLoadGenCubeArray.kt +++ b/src/test/kotlin/gli_/coreLoadGenCubeArray.kt @@ -11,7 +11,7 @@ class coreLoadGenCubeArray : StringSpec() { "load cube array" { - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val target = Target.CUBE_ARRAY diff --git a/src/test/kotlin/gli_/coreLoadGenRect.kt b/src/test/kotlin/gli_/coreLoadGenRect.kt index 811f189..01d691c 100644 --- a/src/test/kotlin/gli_/coreLoadGenRect.kt +++ b/src/test/kotlin/gli_/coreLoadGenRect.kt @@ -12,7 +12,7 @@ class coreLoadGenRect : StringSpec() { "load rect" { for (target in Target.RECT..Target.RECT_ARRAY) - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { if (format.isCompressed && target == Target._3D) continue diff --git a/src/test/kotlin/gli_/coreTexture.kt b/src/test/kotlin/gli_/coreTexture.kt index fd4bc1a..a29ba14 100644 --- a/src/test/kotlin/gli_/coreTexture.kt +++ b/src/test/kotlin/gli_/coreTexture.kt @@ -26,9 +26,9 @@ class coreTexture : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (target in TARGET_FIRST..TARGET_LAST) + for (target in Target.FIRST..Target.LAST) - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val faces = if (target.isTargetCube) 6 else 1 @@ -361,8 +361,8 @@ class coreTexture : StringSpec() { var error = 0 - val textures = ArrayList(FORMAT_COUNT) - for (format in FORMAT_FIRST..FORMAT_LAST) + val textures = ArrayList(Format.COUNT) + for (format in Format.FIRST .. Format.LAST) with(Texture2d(format, Vec2i(4), 9)) { textures += this error += if (this.empty()) 1 else 0 @@ -446,8 +446,8 @@ class coreTexture : StringSpec() { var error = 0 - val textures = ArrayList(FORMAT_COUNT) - for (format in FORMAT_FIRST..FORMAT_LAST) + val textures = ArrayList(Format.COUNT) + for (format in Format.FIRST .. Format.LAST) with(TextureCubeArray(format, Vec2i(4), 3, 3)) { textures += this error += if (this.empty()) 1 else 0 @@ -533,7 +533,7 @@ class coreTexture : StringSpec() { val ns = measureNanoTime { for (index in 0 until iterations) - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val texture = Texture(Target._2D_ARRAY, format, Vec3i(4, 4, 1), 1, 1, 3) error += if (texture.empty()) 1 else 0 } @@ -549,7 +549,7 @@ class coreTexture : StringSpec() { val ns = measureNanoTime { for (index in 0 until iterations) - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val texture = Texture2dArray(format, Vec2i(4), 1, 3) error += if (texture.empty()) 1 else 0 } @@ -565,7 +565,7 @@ class coreTexture : StringSpec() { val ns = measureNanoTime { for (index in 0 until iterations) - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val texture = Texture2d(format, Vec2i(4), 3) error += if (texture.empty()) 1 else 0 } @@ -581,7 +581,7 @@ class coreTexture : StringSpec() { val ns = measureNanoTime { for (index in 0 until iterations) - for (format in FORMAT_FIRST..FORMAT_LAST) { + for (format in Format.FIRST .. Format.LAST) { val texture = TextureCubeArray(format, Vec2i(4), 1, 3) error += if (texture.empty()) 1 else 0 } diff --git a/src/test/kotlin/gli_/coreTexture1d.kt b/src/test/kotlin/gli_/coreTexture1d.kt index 8b84ca4..2885d5d 100644 --- a/src/test/kotlin/gli_/coreTexture1d.kt +++ b/src/test/kotlin/gli_/coreTexture1d.kt @@ -20,7 +20,7 @@ class coreTexture1d : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) sizes.forEach { val size = Vec3i(it) diff --git a/src/test/kotlin/gli_/coreTexture1dArray.kt b/src/test/kotlin/gli_/coreTexture1dArray.kt index bc46b59..f3fe8fd 100644 --- a/src/test/kotlin/gli_/coreTexture1dArray.kt +++ b/src/test/kotlin/gli_/coreTexture1dArray.kt @@ -20,7 +20,7 @@ class coreTexture1dArray : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) sizes.forEach { val size = Vec1i(it) diff --git a/src/test/kotlin/gli_/coreTexture2d.kt b/src/test/kotlin/gli_/coreTexture2d.kt index 6dcb180..27ec016 100644 --- a/src/test/kotlin/gli_/coreTexture2d.kt +++ b/src/test/kotlin/gli_/coreTexture2d.kt @@ -78,7 +78,7 @@ class coreTexture2d : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) sizes.forEach { val size = Vec3i(it) @@ -491,7 +491,7 @@ class coreTexture2d : StringSpec() { } } - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) testFormat(format) } diff --git a/src/test/kotlin/gli_/coreTexture2dArray.kt b/src/test/kotlin/gli_/coreTexture2dArray.kt index adf9861..39ef1a5 100644 --- a/src/test/kotlin/gli_/coreTexture2dArray.kt +++ b/src/test/kotlin/gli_/coreTexture2dArray.kt @@ -21,7 +21,7 @@ class coreTexture2dArray : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) sizes.forEach { val size = Vec2i(it) diff --git a/src/test/kotlin/gli_/coreTexture3d.kt b/src/test/kotlin/gli_/coreTexture3d.kt index a14dcca..d3229ae 100644 --- a/src/test/kotlin/gli_/coreTexture3d.kt +++ b/src/test/kotlin/gli_/coreTexture3d.kt @@ -20,7 +20,7 @@ class coreTexture3d : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) sizes.forEach { val size = Vec3i(it) diff --git a/src/test/kotlin/gli_/coreTextureCube.kt b/src/test/kotlin/gli_/coreTextureCube.kt index 2abcf0c..678f346 100644 --- a/src/test/kotlin/gli_/coreTextureCube.kt +++ b/src/test/kotlin/gli_/coreTextureCube.kt @@ -23,7 +23,7 @@ class coreTextureCube : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) sizes.forEach { val size = Vec2i(it) diff --git a/src/test/kotlin/gli_/coreTextureCubeArray.kt b/src/test/kotlin/gli_/coreTextureCubeArray.kt index 9c7491e..9cf741a 100644 --- a/src/test/kotlin/gli_/coreTextureCubeArray.kt +++ b/src/test/kotlin/gli_/coreTextureCubeArray.kt @@ -21,7 +21,7 @@ class coreTextureCubeArray : StringSpec() { val sizes = intArrayOf(16, 32, 15, 17, 1) - for (format in FORMAT_FIRST..FORMAT_LAST) + for (format in Format.FIRST .. Format.LAST) sizes.forEach { val size = Vec2i(it)