PDA

View Full Version : Texture Problems ...



Saintex
07-19-2002, 12:09 AM
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.

SebastianB
07-19-2002, 12:21 AM
... hmm, hard to tell without any code snippets. post some of your sources!

:)
seb

Saintex
07-19-2002, 12:35 AM
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.

SebastianB
07-19-2002, 02:57 AM
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 ....


:)
seb

Saintex
07-19-2002, 03:20 AM
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 ...

masterpoi
07-19-2002, 04:09 AM
What is your projection matrix?

MtPOI

Saintex
07-19-2002, 04:20 AM
What do you mean ??

masterpoi
07-19-2002, 06:25 AM
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

Saintex
07-22-2002, 06:38 AM
I found my way out ...
Thanks ...