more texture buffer error checking
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
2b706a231a
commit
1db6059821
@ -167,6 +167,9 @@ public class Texture {
|
|||||||
height = 1;
|
height = 1;
|
||||||
try {
|
try {
|
||||||
BufferedImage image_data = ImageIO.read(FileUtils.getAssetFile(path));
|
BufferedImage image_data = ImageIO.read(FileUtils.getAssetFile(path));
|
||||||
|
|
||||||
|
//
|
||||||
|
//transparency check
|
||||||
if (
|
if (
|
||||||
image_data.getType() == BufferedImage.TYPE_3BYTE_BGR ||
|
image_data.getType() == BufferedImage.TYPE_3BYTE_BGR ||
|
||||||
image_data.getType() == BufferedImage.TYPE_INT_RGB
|
image_data.getType() == BufferedImage.TYPE_INT_RGB
|
||||||
@ -178,6 +181,9 @@ public class Texture {
|
|||||||
){
|
){
|
||||||
hasTransparency = true;
|
hasTransparency = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//create buffer
|
||||||
width = image_data.getWidth();
|
width = image_data.getWidth();
|
||||||
height = image_data.getHeight();
|
height = image_data.getHeight();
|
||||||
if(hasTransparency){
|
if(hasTransparency){
|
||||||
@ -185,19 +191,15 @@ public class Texture {
|
|||||||
} else {
|
} else {
|
||||||
data = BufferUtils.createByteBuffer(width * height * 3);
|
data = BufferUtils.createByteBuffer(width * height * 3);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
imgBuffer = BufferUtils.createByteBuffer(4 * dimX * dimY);
|
//
|
||||||
for(int x = 0; x < dimX; x++){
|
//error check
|
||||||
for(int y = 0; y < dimY; y++){
|
if(data == null){
|
||||||
Color temp = new Color(image_data.getRGB(x, y));
|
throw new IllegalStateException("Failed to allocate buffer for texture");
|
||||||
data.put((byte)(temp.getRed());
|
|
||||||
data.put((byte)(temp.getGreen());
|
|
||||||
data.put((byte)(temp.getBlue());
|
|
||||||
data.put((byte)(temp.getAlpha());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
imgBuffer.flip();
|
//
|
||||||
*/
|
//buffer data
|
||||||
for(int y = height - 1; y > -1; y--){
|
for(int y = height - 1; y > -1; y--){
|
||||||
for(int x = 0; x < width; x++){
|
for(int x = 0; x < width; x++){
|
||||||
Color temp = new Color(image_data.getRGB(x, y), true);
|
Color temp = new Color(image_data.getRGB(x, y), true);
|
||||||
@ -208,9 +210,6 @@ public class Texture {
|
|||||||
if(hasTransparency){
|
if(hasTransparency){
|
||||||
data.put((byte)temp.getAlpha());
|
data.put((byte)temp.getAlpha());
|
||||||
}
|
}
|
||||||
// data[x * y * 3 + 0] = temp.getRed();
|
|
||||||
// data[x * y * 3 + 1] = temp.getGreen();
|
|
||||||
// data[x * y * 3 + 2] = temp.getBlue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -221,6 +220,8 @@ public class Texture {
|
|||||||
data.put((byte)0);
|
data.put((byte)0);
|
||||||
data.put((byte)0);
|
data.put((byte)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoggerInterface.loggerRenderer.DEBUG("Flip buffer");
|
||||||
data.flip();
|
data.flip();
|
||||||
|
|
||||||
//call if width != height so opengl figures out how to unpack it properly
|
//call if width != height so opengl figures out how to unpack it properly
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user