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 9 of 9

Thread: Texture Problems ...

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    France
    Posts
    5

    Texture Problems ...

    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.

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Stuttgart, Germany
    Posts
    27

    Re: Texture Problems ...

    ... hmm, hard to tell without any code snippets. post some of your sources!


    seb

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    France
    Posts
    5

    Re: Texture Problems ...

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Stuttgart, Germany
    Posts
    27

    Re: Texture Problems ...

    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

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    France
    Posts
    5

    Re: Texture Problems ...

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

  6. #6
    Email address no longer exists Contributor
    Join Date
    Apr 2000
    Location
    Hoegaarden, Belgium
    Posts
    71

    Re: Texture Problems ...

    What is your projection matrix?

    MtPOI

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    France
    Posts
    5

    Re: Texture Problems ...

    What do you mean ??

  8. #8
    Email address no longer exists Contributor
    Join Date
    Apr 2000
    Location
    Hoegaarden, Belgium
    Posts
    71

    Re: Texture Problems ...

    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

  9. #9
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    France
    Posts
    5

    Re: Texture Problems ...

    I found my way out ...
    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
  •