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

Thread: Texturing a line with 2-D texture element

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2008
    Posts
    12

    Texturing a line with 2-D texture element

    Hi Everyone,

    I am trying to texture a line segment with a 2-D texture element. In other words, I am providing same u value and increasing v value for my line.

    I try to do this in Cg (with this piece of code:

    Code :
    kd = (half3)tex2D(hairTexture, uv).xyz;
    ), what I want to know is that whether this is possible with the OpenGL part.

    If it is possible to texture a line primitive with a 2-D texture element with pure OpenGL, then I would know that the problem is with Cg part. (Recommendations with the Cg part are also welcomed )

    Thanks in advance

    Rifat

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    999

    Re: Texturing a line with 2-D texture element

    Code :
    glColor4f(1.0,1.0,1.0,1.0);
    glEnable(GL_TEXTURE_2D);
    glBegin(GL_LINES);
    glTexcoord2f(u,v1);
    glVertex3f(x1,y1,z1);
    glTexcoord2f(u,v2);
    glVertex3f(x2,y2,z2);
    glEnd();

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2008
    Posts
    12

    Re: Texturing a line with 2-D texture element

    Then I understand that it is possible to texture a line primitive with GL_TEXTURE_2D and glTexcoord2f.

    I am loading the texture, passing the texture identifier to Cg's sampler2D variable and try to access texture information with
    Code :
    (half3)tex2D(hairTexture, uv).xyz;
    Unfortunately, it does not seem to be reading correct color information; I cannot see texture drawn onto the line primitive.

    Am I doing something wrong?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    999

    Re: Texturing a line with 2-D texture element

    Quote Originally Posted by Rifat Aras
    Am I doing something wrong?
    I guess so..the question is 'what'

    Did you try the fixed function path? Are your sampler states correct? Try writing out the uv coords, maybe there's something wrong with them, etc.

    N.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2008
    Posts
    12

    Re: Texturing a line with 2-D texture element

    Hmm "uv coords" may be the problem... I dynamically calculate them at vertex shader. I thought they were correct, but maybe... When I get to home I will give it a try and let you know...

    Thanks anyway...

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Texturing a line with 2-D texture element

    Maybe you did not build mipmaps for your texture, by default mipmaps are needed.

Posting Permissions

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