PDA

View Full Version : Texture Mapping using a PPM file



gjthomasopengl
04-09-2003, 06:59 AM
Hi-
I have a texture image in a PPM file and all the u, v coordinates. I am tring to render the texture for the model. The Red Book isnt helping me too much. Any hel really appreciated

Thx

Asgard
04-09-2003, 07:31 AM
See http://openil.sourceforge.net for DevIL which can load .ppm files.

Don Gazon
04-09-2003, 07:38 AM
Use an other textureLoader, not the AWT loader. I never used PPM's but I think this code should work

protected int texName[]={0};

// reads the image, call this function in you init() method.
public void init_texture()
{
// read PPM's
TextureLoader texLoader = new PPMAsciiTextureLoader(gl,glu);

texLoader.readTexture("yourimage.ppm");

gl.glPixelStorei(GL_UNPACK_ALIGNMENT,1);

// Generate texture names (id's)
gl.glGenTextures(1,texName);

gl.glBindTexture(GL_TEXTURE_2D,texName[0]);

gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);


texLoader.texImage2DNonScaled(true);
}