From bd0c54f1052cc2df5135edc98f093bfe8f7cd56d Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Sat, 16 Dec 2023 01:19:44 +0100 Subject: [PATCH] opengl: use nearest mipmaps by default --- .../opengl/texture/OpenGLTextureUtil.kt | 2 +- .../example/jonathan2520/SRGBAveragerTest.kt | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/test/java/example/jonathan2520/SRGBAveragerTest.kt diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/texture/OpenGLTextureUtil.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/texture/OpenGLTextureUtil.kt index d4f2aeb9e..02578efaf 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/texture/OpenGLTextureUtil.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/system/opengl/texture/OpenGLTextureUtil.kt @@ -27,7 +27,7 @@ object OpenGLTextureUtil { glBindTexture(GL_TEXTURE_2D_ARRAY, textureId) glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT) glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT) - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, if (mipmaps == 0) GL_NEAREST else GL_NEAREST_MIPMAP_LINEAR) + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, if (mipmaps == 0) GL_NEAREST else GL_NEAREST_MIPMAP_NEAREST) glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, mipmaps) diff --git a/src/test/java/example/jonathan2520/SRGBAveragerTest.kt b/src/test/java/example/jonathan2520/SRGBAveragerTest.kt new file mode 100644 index 000000000..dc10cc0bd --- /dev/null +++ b/src/test/java/example/jonathan2520/SRGBAveragerTest.kt @@ -0,0 +1,34 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ +package example.jonathan2520 + +import kotlin.test.Test +import kotlin.test.assertEquals + +internal class SRGBAveragerTest { + + @Test + fun `mix transparent 1`() { + assertEquals(0xFFFFFFFF.toInt(), SRGBAverager.average(0xFFFFFF00.toInt(), 0xFFFFFFFF.toInt(), 0xFFFFFFFF.toInt(), 0xFFFFFFFF.toInt())) + } + + @Test + fun `mix transparent 2`() { + assertEquals(0x00, SRGBAverager.average(0xFFFFFF00.toInt(), 0xFFFFFF00.toInt(), 0xFFFFFFFF.toInt(), 0xFFFFFFFF.toInt())) + } + + @Test + fun `mix transparent 3`() { + assertEquals(0x00, SRGBAverager.average(0xFFFFFF00.toInt(), 0xFFFFFF00.toInt(), 0xFFFFFF00.toInt(), 0xFFFFFFFF.toInt())) + } +}