Skip to content

Commit d227203

Browse files
committed
fix: order of execution
1 parent 7fd8b99 commit d227203

File tree

1 file changed

+6
-9
lines changed
  • common/src/main/kotlin/com/lambda/graphics/texture

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,11 @@ import org.lwjgl.opengl.GL45C.*
2525
import java.awt.image.BufferedImage
2626

2727
open class Texture(
28-
private val image: BufferedImage?,
28+
image: BufferedImage?,
2929
private val levels: Int = 4,
3030
) {
3131
val id = glGenTextures()
3232

33-
open fun init() = image
34-
?.let {
35-
bind()
36-
upload(it)
37-
bind(0)
38-
}
39-
4033
open fun bind(slot: Int = 0) {
4134
bindTexture(id, slot)
4235
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, RenderSettings.lodBias)
@@ -70,6 +63,10 @@ open class Texture(
7063
}
7164

7265
init {
73-
init() // The overridden method will run and not the base one due to kotlin's order of execution ;)
66+
image?.let {
67+
bind()
68+
upload(it)
69+
bind(0)
70+
}
7471
}
7572
}

0 commit comments

Comments
 (0)