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.
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.
Have you enabled texturing?
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........
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
Does your texture's width and height match 2^a x 2^b (i.e. 64x256) ?
Do you share the textures if you are using several contexts?
i will try it,thank you very much!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
yes,it is 256x256......Originally posted by Liquid:
Does your texture's width and height match 2^a x 2^b (i.e. 64x256) ?
sorry, i am not sure that i understand what you mean,can you explain it again! thanks a lot!Originally posted by Zico:
Do you share the textures if you are using several contexts?
I guess you know if you are using more than one context so skip the above.![]()