I am trying to load textures into JOGL.
Whenever I load pictures in, it finds the nearest power of 2 resolution and uses them instead. What is happening? From what I can read the TextureIO-class should take care of this for me and make it the right resolution
I’m usin the following code:
public static Texture load(String fileName){
Texture text = null;
try{
// TextureIO.setTexRectEnabled(true);
text = TextureIO.newTexture(new File(fileName), true);
text.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
}catch(Exception e){
System.out.println(e.getMessage());
System.out.println("Error loading texture " + fileName);
}
return text;
}
And this is the context:
public class SpriteBuffer {
Texture spriteSheet;
int dimX,dimY;
double memory;
double frameWidth,frameHeight;
int rows,cols;
int[][] frames;
DisplaylistManager dManager;
double pixelX,pixelY;
public SpriteBuffer(String filename, int rows, int cols){
spriteSheet = TextureLoader.load(filename);
dimX = spriteSheet.getImageWidth();
dimY = spriteSheet.getImageHeight();
memory = spriteSheet.getEstimatedMemorySize();
this.rows = rows;
this.cols = cols;
this.frameHeight = 1/(double)rows;
this.frameWidth = 1/(double)cols;
pixelX = spriteSheet.getWidth()/cols;
pixelY = spriteSheet.getHeight()/rows;
dump(filename);
this.dManager = DisplaylistManager.getInstance();
frames = dManager.getSpriteList(this);
}
public void dump(String filename){
System.out.println("Filename: "+filename);
System.out.println("pixelX: "+pixelX+" pixelY: "+pixelY);
System.out.println("Framewidth: "+frameWidth+ " Frameheight: "+frameHeight);
System.out.println("rows: "+rows+" cols: "+cols);
System.out.println("dimX: "+dimX+" dimY: "+dimY);
System.out.println("1/cols: "+frameWidth);
}
}
An example is a picture “Attandrunn.png” which is 200x2400. It loads it in as dimX: 256 dimY: 4096. Which is not really the right resolution.
What is going on?