File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
common/src/main/kotlin/com/lambda/graphics/texture Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ package com.lambda.graphics.texture
2020import com.lambda.graphics.texture.TextureUtils.bindTexture
2121import com.lambda.graphics.texture.TextureUtils.readImage
2222import com.lambda.graphics.texture.TextureUtils.setupTexture
23+ import com.lambda.util.LambdaResource
24+ import com.lambda.util.readImage
2325import net.minecraft.client.texture.NativeImage
2426import org.lwjgl.opengl.GL45C.*
2527import java.awt.image.BufferedImage
@@ -36,6 +38,21 @@ open class Texture {
3638 private val levels: Int
3739 private val nativeFormat: NativeImage .Format // For mojang native images
3840
41+ /* *
42+ * @param path Lambda resource path
43+ * @param format The format of the image passed in
44+ * @param levels Number of mipmap levels to generate for the texture
45+ */
46+ constructor (path: LambdaResource , format: Int = GL_RGBA , levels: Int = 4 ) {
47+ val image = path.readImage()
48+ this .format = bufferedMapping[image.type] ? : format
49+ this .levels = levels
50+ this .nativeFormat = nativeMapping.getOrDefault(format, NativeImage .Format .RGBA )
51+
52+ bindTexture(id)
53+ upload(image)
54+ }
55+
3956 /* *
4057 * @param image Optional initial image to upload to the texture
4158 * @param format The format of the image passed in, if the [image] is null, then you must pass the appropriate format
You can’t perform that action at this time.
0 commit comments