I am very new in openGL and I use LWJGL.
I do not know how to see if "Mipmaps are working"
This is how I load a Image (64x64) :
private int loadPNGTexture(String filename) {
ByteBuffer buf = null;
int tWidth = 0;
int tHeight = 0;
try {
InputStream in = new FileInputStream(ClassLoader.getSystemResource(filename).getPath());
decoder = new PNGDecoder(in);
tWidth = decoder.getWidth();
tHeight = decoder.getHeight();
buf = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight());
decoder.decode(buf, decoder.getWidth() * 4, PNGDecoder.Format.RGBA);
buf.flip();
in.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
int texId = GL11.glGenTextures();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tWidth, tHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf);
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
return texId;
}
And this is how I draw my Image :
public void drawGL() {
GL11.glPushMatrix();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, playerTextures[0]);
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(decoder.getWidth(), 0);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(decoder.getWidth(), decoder.getWidth());
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(0, 0);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(0, decoder.getWidth());
GL11.glEnd();
GL11.glPopMatrix();
}
The draw is correct, I can see my Image but if I change the DisplayMode (from 800x600 to 1280x960), the Image is not growing up. So the problem is that I need the Image grow up to scale with the resolution.