Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Texture Mapping

  1. #1
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    39

    Texture Mapping

    I completed to load a .tga file in cpp&opengl. The fallowing code is successful.
    ...
    glRasterPos2i(0,0);
    glDrawPixels..
    ..

    And I tried same .tga file to do texture mapping on the following codes,(I used same loader code) it didn't run :
    I try to solve problem.
    1-) Pixel number is more than the object size. Is it a problem?
    2-) There isn't a load error on program, but object is not covered with .tga. What can be the problem?

    glBegin(GL_TRIANGLE_STRIP);
    glTexCoord2f(2.0, 0.0); glVertex3f(2.0, -2.0, -2.0);
    glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -2.0, -2.0);
    glTexCoord2f(2.0, 2.0); glVertex3f(2.0, -2.0, 2.0);
    glTexCoord2f(0.0, 2.0); glVertex3f(-2.0, -2.0, 2.0);
    glEnd();

  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2005
    Location
    South Tyrol, Italy
    Posts
    105

    Re: Texture Mapping

    Have you bound your texture with glBindTexture? Did you also enable the texture with glEnable(GL_TEXTURE_2D)? You also need to set the minification and the magnification filters for the texture. Do you get any gl errors? You could check that for instance with GLIntercept.

    [ www.trenki.net | vector_math (3d math library) | software renderer ]

  3. #3
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    39

    Re: Texture Mapping

    I will check glBindTexture.
    Actually, second code runs with different .tga file which has same dimensions with object.
    I used glEnable(GL_TEXTURE_2D) already.
    There is not any error. But object surface is blank.
    ???

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2007
    Posts
    21

    Re: Texture Mapping

    Is the image a power of 2 in its dimensions?
    Joseph Steel

  5. #5
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    39

    Re: Texture Mapping

    .tga file is larger than object dimensions. I don't know how is larger. But it may be larger as twice as object dimensions or more.

  6. #6
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: Texture Mapping

    Can you post the whole code? I think that you are loading your texture in a wrong way... Also, on older cards texture size has to be a power-of-two, like 256x256 or 512x512 etc... The texture-to-object size ratio plays no role here

  7. #7
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    39

    Re: Texture Mapping

    It is not power-of-two.
    It is 1280*960. I think that's the problem.
    Because other .tga file has 256*256.

  8. #8
    Intern Newbie
    Join Date
    Jun 2005
    Posts
    39

    Re: Texture Mapping

    It is solved.
    I changed the .tga dimensions. It run.
    Thanks.

Posting Permissions

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