Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: have a problem about texture mapping??

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    taiwan
    Posts
    17

    have a problem about texture mapping??

    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.

  2. #2
    Guest

    Re: have a problem about texture mapping??

    Have you enabled texturing?

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    taiwan
    Posts
    17

    Re: have a problem about texture mapping??

    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........

  4. #4
    Intern Newbie
    Join Date
    Jun 2002
    Posts
    31

    Re: have a problem about texture mapping??

    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

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2002
    Posts
    27

    Re: have a problem about texture mapping??

    Does your texture's width and height match 2^a x 2^b (i.e. 64x256) ?

  6. #6
    Guest

    Re: have a problem about texture mapping??

    Do you share the textures if you are using several contexts?

  7. #7
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    taiwan
    Posts
    17

    Re: have a problem about texture mapping??

    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!

  8. #8
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    taiwan
    Posts
    17

    Re: have a problem about texture mapping??

    Originally posted by Liquid:
    Does your texture's width and height match 2^a x 2^b (i.e. 64x256) ?
    yes,it is 256x256......

  9. #9
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    taiwan
    Posts
    17

    Re: have a problem about texture mapping??

    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!

  10. #10
    Guest

    Re: have a problem about texture mapping??

    I guess you know if you are using more than one context so skip the above.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •