PDA

View Full Version : have a problem about texture mapping??



randychou
07-11-2002, 07:15 PM
I'd like to paste the texture over the wireframe model, but I've tried many ways, there's only color changed on mesh, no texture within the grid. Anyone know where the problem is? Thank you in advance.

07-11-2002, 09:26 PM
Have you enabled texturing?

randychou
07-11-2002, 09:51 PM
yes,i am sure that i have done every thing that must to do.(ex:loadBmp,loadTexture,glGenTextures,glBindTex ture,glTexCoord2f)....but it still don't work???
here is my code:
1.loadTexture......

TextureImage=LoadBMP("pot4.bmp")
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,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);

2.use Texture..........

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);

glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);glVertex3f(10,20,10);
glTexCoord2f(1.0,0.0);glVertex3f(20,20,20);
glTexCoord2f(1.0,1.0);glVertex3f(10,20,30);
glTexCoord2f(0.0,1.0);glVertex3f(20,20,30);
glEnd();

and i draw it in a Dialog........

fringe
07-12-2002, 03:17 AM
I am not really sure but I think that to have a textured surface you will have to switch the mode from drawing wire frame to drawing solid. glPolygonMode( GL_FRONT, GL_FILL );
If this is not helpful just ignore it,

Fringe

Liquid
07-12-2002, 02:03 PM
Does your texture's width and height match 2^a x 2^b (i.e. 64x256) ?

07-12-2002, 10:11 PM
Do you share the textures if you are using several contexts?

randychou
07-13-2002, 08:02 PM
Originally posted by fringe:
I am not really sure but I think that to have a textured surface you will have to switch the mode from drawing wire frame to drawing solid. glPolygonMode( GL_FRONT, GL_FILL );
If this is not helpful just ignore it,

Fringe

i will try it,thank you very much!

randychou
07-13-2002, 08:06 PM
Originally posted by Liquid:
Does your texture's width and height match 2^a x 2^b (i.e. 64x256) ?

yes,it is 256x256......

randychou
07-13-2002, 08:09 PM
Originally posted by Zico:
Do you share the textures if you are using several contexts?

sorry, i am not sure that i understand what you mean,can you explain it again! thanks a lot!

07-13-2002, 10:33 PM
I guess you know if you are using more than one context so skip the above. http://www.opengl.org/discussion_boards/ubb/smile.gif

t0y
07-14-2002, 06:56 AM
Texturing works ok in wireframe mode...
The problem is probably in the the LoadBMP/glTexImage2D calls. Check for errors!

randychou
07-14-2002, 09:28 PM
i have solved this problem! i am so thank you to every one who help me ! thank you again! http://www.opengl.org/discussion_boards/ubb/biggrin.gif