Skip to content

Commit 1b856ec

Browse files
committed
better mipmap handling
1 parent 2e3a883 commit 1b856ec

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

common/src/main/kotlin/com/lambda/graphics/renderer/gui/font/sdf/DistanceFieldTexture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import java.awt.image.BufferedImage
3232
*
3333
* @param image Image data to upload
3434
*/
35-
class DistanceFieldTexture(image: BufferedImage) : Texture(image) {
35+
class DistanceFieldTexture(image: BufferedImage) : Texture(image, levels = 0) {
3636
private val frame = CachedFrame(width, height).write {
3737
FrameBuffer.pipeline.use {
3838
val (pos1, pos2) = Vec2d.ZERO to Vec2d(width, height)

common/src/main/kotlin/com/lambda/graphics/texture/Texture.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ package com.lambda.graphics.texture
2020
import com.lambda.graphics.texture.TextureUtils.bindTexture
2121
import com.lambda.graphics.texture.TextureUtils.readImage
2222
import com.lambda.graphics.texture.TextureUtils.setupTexture
23-
import com.lambda.module.modules.client.RenderSettings
24-
import org.lwjgl.opengl.GL11C
2523
import org.lwjgl.opengl.GL45C.*
2624
import java.awt.image.BufferedImage
2725
import java.lang.IllegalStateException
28-
import java.nio.ByteBuffer
2926

3027
/**
3128
* Represents a texture that can be uploaded and bound to the graphics pipeline
@@ -77,9 +74,9 @@ open class Texture(
7774
initialized = true
7875

7976
// Set this mipmap to `offset` to define the original texture
80-
setupTexture(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR)
8177
glTexImage2D(GL_TEXTURE_2D, offset, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, readImage(image))
82-
glGenerateMipmap(GL_TEXTURE_2D) // This take the derived values GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL to generate the stack
78+
setupTexture(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR)
79+
if (levels > 1) glGenerateMipmap(GL_TEXTURE_2D) // This take the derived values GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL to generate the stack
8380
}
8481

8582
open fun update(image: BufferedImage, offset: Int = 0) {

0 commit comments

Comments
 (0)