Skip to content

Commit 87b7c18

Browse files
committed
docs: cleanup test sample
1 parent c6d653e commit 87b7c18

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/test/kotlin/direct/SampleRenderer.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package direct
33
import org.lwjgl.BufferUtils
44
import org.lwjgl.opengl.GL
55
import org.lwjgl.opengl.GL30.*
6-
import java.io.File
6+
import java.io.InputStream
77
import javax.imageio.ImageIO
88

99
//language=glsl
@@ -46,8 +46,8 @@ class SampleRenderer {
4646
if (initialized) return
4747

4848
val img = "image.png"
49-
val (id, _) = loadTexture(File(img))
50-
textureId = id
49+
val stream = javaClass.classLoader.getResourceAsStream(img) ?: error("Resource not found: $img")
50+
textureId = loadTexture(stream)
5151

5252
shaderProgram = glCreateProgram()
5353
val vertexShader = glCreateShader(GL_VERTEX_SHADER)
@@ -143,8 +143,8 @@ class SampleRenderer {
143143
}
144144
}
145145

146-
fun loadTexture(file: File): Pair<Int, Pair<Int, Int>> {
147-
val image = ImageIO.read(file)
146+
fun loadTexture(stream: InputStream): Int {
147+
val image = ImageIO.read(stream)
148148

149149
val width = image.width
150150
val height = image.height
@@ -190,5 +190,5 @@ fun loadTexture(file: File): Pair<Int, Pair<Int, Int>> {
190190
)
191191
glBindTexture(GL_TEXTURE_2D, 0)
192192

193-
return textureID to (width to height)
193+
return textureID
194194
}

src/test/resources/image.png

10.5 MB
Loading

0 commit comments

Comments
 (0)