Texture Problems ...

I do have some problems with texturing … I try to display a texture (a Ppm image) in a square, but I always have a blue window instead of my texture …
could anyone tell me what I am doing wrong?
Thx.

… hmm, hard to tell without any code snippets. post some of your sources!

:slight_smile:
seb

Of course … should have done that …
Here it is :
Pic = loadPpm( “mypic.ppm” );

glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_2D, texName);

glTexImage2D(GL_TEXTURE_2D, 0, 2, Pic->getWidth( ), Pic->getHeight( ), 0, GL_RGB, GL_FLOAT, Pic->getDrawable( ) );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_2D,GL_TEXTURE_ENV_MODE, GL_MODULATE);
glPolygonMode( GL_FRONT, GL_FILL );

That’s for initialization …
and now for drawing …

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texName);

glBegin(GL_QUADS);

glTexCoord2f(0.0, 1.0); glVertex3f( 0.0, 0.0, 0.0 );
glTexCoord2f(1.0, 1.0); glVertex3f( ( float )Pic->getWidth( ), 0.0, 0.0 );
glTexCoord2f(1.0, 0.0); glVertex3f( ( float )Pic->getWidth( ), ( float )Pic->getHeight( ), 0.0 );
glTexCoord2f(0.0, 0.0); glVertex3f( 0.0, ( float )Pic->getHeight( ), 0.0 );

glEnd();
glDisable(GL_TEXTURE_2D);

here it is …
Thanks.

i think, after your “glTexParameterf” you need to call “glTexImage2D” …
or try it instead with “gluBuild2DMipmaps”

(make a google-search on examples with one of these calls)

hope that works …

:slight_smile:
seb

I have the glTexImage2D just above the first glTexParameteri yet it doesn’t work …
Maybe I am going to look with the mipmaps …
Thanks again …

What is your projection matrix?

MtPOI

What do you mean ??

You are drawing a quad that is going from (0,0) to (width,height). Do you have an orthogonal projection or a perspective projection? Are you sure the quad fits on the screen?

MtPOI

I found my way out …
Thanks …