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,17 +167,23 @@ public class Texture {
|
||||
height = 1;
|
||||
try {
|
||||
BufferedImage image_data = ImageIO.read(FileUtils.getAssetFile(path));
|
||||
|
||||
//
|
||||
//transparency check
|
||||
if (
|
||||
image_data.getType() == BufferedImage.TYPE_3BYTE_BGR ||
|
||||
image_data.getType() == BufferedImage.TYPE_INT_RGB
|
||||
){
|
||||
image_data.getType() == BufferedImage.TYPE_3BYTE_BGR ||
|
||||
image_data.getType() == BufferedImage.TYPE_INT_RGB
|
||||
){
|
||||
hasTransparency = false;
|
||||
} else if(
|
||||
image_data.getType() == BufferedImage.TYPE_4BYTE_ABGR ||
|
||||
image_data.getType() == BufferedImage.TYPE_INT_ARGB
|
||||
){
|
||||
image_data.getType() == BufferedImage.TYPE_4BYTE_ABGR ||
|
||||
image_data.getType() == BufferedImage.TYPE_INT_ARGB
|
||||
){
|
||||
hasTransparency = true;
|
||||
}
|
||||
|
||||
//
|
||||
//create buffer
|
||||
width = image_data.getWidth();
|
||||
height = image_data.getHeight();
|
||||
if(hasTransparency){
|
||||
@ -185,19 +191,15 @@ public class Texture {
|
||||
} else {
|
||||
data = BufferUtils.createByteBuffer(width * height * 3);
|
||||
}
|
||||
/*
|
||||
imgBuffer = BufferUtils.createByteBuffer(4 * dimX * dimY);
|
||||
for(int x = 0; x < dimX; x++){
|
||||
for(int y = 0; y < dimY; y++){
|
||||
Color temp = new Color(image_data.getRGB(x, y));
|
||||
data.put((byte)(temp.getRed());
|
||||
data.put((byte)(temp.getGreen());
|
||||
data.put((byte)(temp.getBlue());
|
||||
data.put((byte)(temp.getAlpha());
|
||||
}
|
||||
|
||||
//
|
||||
//error check
|
||||
if(data == null){
|
||||
throw new IllegalStateException("Failed to allocate buffer for texture");
|
||||
}
|
||||
imgBuffer.flip();
|
||||
*/
|
||||
|
||||
//
|
||||
//buffer data
|
||||
for(int y = height - 1; y > -1; y--){
|
||||
for(int x = 0; x < width; x++){
|
||||
Color temp = new Color(image_data.getRGB(x, y), true);
|
||||
@ -208,9 +210,6 @@ public class Texture {
|
||||
if(hasTransparency){
|
||||
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) {
|
||||
@ -221,6 +220,8 @@ public class Texture {
|
||||
data.put((byte)0);
|
||||
data.put((byte)0);
|
||||
}
|
||||
|
||||
LoggerInterface.loggerRenderer.DEBUG("Flip buffer");
|
||||
data.flip();
|
||||
|
||||
//call if width != height so opengl figures out how to unpack it properly
|
||||
|
||||
Loading…
Reference in New Issue
Block a user