add buffer limit checks to texture construction
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-08-28 22:57:08 -04:00
parent 1db6059821
commit 831df3d6af

View File

@ -202,12 +202,18 @@ public class Texture {
//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);
Color temp = new Color(image_data.getRGB(x, y), hasTransparency);
if(data.position() + 3 > data.limit() + 1){
throw new IllegalStateException("Hit buffer limit!");
}
data.put((byte)temp.getRed());
data.put((byte)temp.getGreen());
data.put((byte)temp.getBlue());
if(hasTransparency){
if(data.position() + 1 > data.limit() + 1){
throw new IllegalStateException("Hit buffer limit!");
}
data.put((byte)temp.getAlpha());
}
}