PDA

View Full Version : Problems with Textures...



Music_Man
11-26-2002, 03:04 AM
Please help... it seems that there are only a very limited number of .png files that I can display with java. I dont know what it is, but some png's just wont display. They are all in a size ^2, so its not that....

Please help, I am goin spare!

Thanks in advance

Music_Man http://www.opengl.org/discussion_boards/ubb/confused.gif

What3v3r
11-26-2002, 08:45 AM
Do you enabled GL_TEXTURE_2D ?
Do you set texture coordinates ?
Pay attention to the format you used when created texture with glTexImage2D() or gluBuild2DMipmaps()

Bye

Deiussum
11-26-2002, 09:22 AM
What do you use for your PNG loading? Perhaps that routine doesn't correctly handle certain forms of PNGs.

Music_Man
11-26-2002, 11:10 AM
Cheers for the replies, I am now using MS Paint of all things to convert the images to png. It seems to be working except for the fact that it will only display the last texture that I have loaded.... My code is below, please help....

public void LoadGLTextures()
{
PngTextureLoader texLoader = new PngTextureLoader(gl, glu);
texLoader.readTexture(getCodeBase(), "MetalFloor.PNG");
if(texLoader.isOk()) {
//Create Texture
gl.glGenTextures(5, texture);
gl.glBindTexture(GL_TEXTURE_2D, texture[0]);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl.glTexImage2D( GL_TEXTURE_2D, 0, 3, texLoader.getImageWidth(),
texLoader.getImageHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE,
texLoader.getTexture());
}

// PngTextureLoader texLoader2 = new PngTextureLoader(gl, glu);
texLoader.readTexture(getCodeBase(), "Marble.png");
if(texLoader.isOk()) {
//Create Texture
gl.glGenTextures(5, texture);
gl.glBindTexture(GL_TEXTURE_2D, texture[1]);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl.glTexImage2D( GL_TEXTURE_2D, 0, 3, texLoader.getImageWidth(),
texLoader.getImageHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE,
texLoader.getTexture());
}

}

Again, many thanks in advance

Music_Man http://www.opengl.org/discussion_boards/ubb/confused.gif

Music_Man
11-26-2002, 11:32 AM
It's ok now. Cheers for all the help, my housemate just walked in, looked at my code and went 'ooo, you dont need the gl.glGenTextures(5, texture);
bit in there twice.... took it out and it worked fine.... i'm just gonna go bang my head against a brick wall....

Cheers

Music_Man :-)