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: Bind GL_TEXTURE_RECTANGLE_NV texture!

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Piscataway, NJ, USA
    Posts
    11

    Bind GL_TEXTURE_RECTANGLE_NV texture!

    Can I bind a float GL_TEXTURE_RECTANGLE_NV texture to a fragment program using
    cgGLSetTextureParameter( paraFpTexture, fptexture ) ?

    I used following code to test it, but the result it all black. Any idea?

    ---------------------------------------------
    cgGLBindProgram(vProgram);
    cgGLEnableProfile(vProfile);

    cgGLBindProgram(fProgram);
    cgGLEnableProfile(fProfile);

    cgGLSetStateMatrixParameter( paraVpModelViewProj,
    CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY ) ;

    cgGLSetTextureParameter( paraFpTexture, fptexture ) ;
    cgGLEnableTextureParameter( paraFpTexture ) ;

    glTranslatef(-0.5, -0.5,-0.9);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
    glTexCoord2f(width, 0.0); glVertex2f(1.0, 0.0);
    glTexCoord2f(width, height); glVertex2f(1.0, 1.0);
    glTexCoord2f(0.0, height); glVertex2f(0.0, 1.0);
    glEnd();

    cgGLDisableTextureParameter( paraFpTexture ) ;
    cgGLDisableProfile(vProfile);
    cgGLDisableProfile(fProfile);
    --------------------------------------------

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2001
    Location
    NVIDIA, Austin, TX
    Posts
    591

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    Can you post the Cg code that's fetching from the rectangular texture?

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Piscataway, NJ, USA
    Posts
    11

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    void main( float4 Position : POSITION ,
    float2 texCoord : TEXCOORD0 ,

    out float4 color : COLOR,

    uniform samplerRECT texture)
    {
    float4 texColor = texRECT( texture, texCoord ) ;

    color = texColor ;
    // color.x = 1.0 ;
    // color.y = 0.0 ;
    // color.z = 0.0 ;
    // color.w = 0.0 ;
    }

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Piscataway, NJ, USA
    Posts
    11

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    void main( float4 Position : POSITION ,
    float2 texCoord : TEXCOORD0 ,

    out float4 oPosition : POSITION ,
    out float2 oTexCoord : TEXCOORD0 ,

    uniform float4x4 ModelViewProj)
    {
    // transform vertex position into homogenous clip-space
    oPosition = mul(ModelViewProj, Position);

    oTexCoord = texCoord ;
    }

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Jan 2001
    Location
    NVIDIA, Austin, TX
    Posts
    591

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    What fragment profile are you using? What data is in the floating point texture?

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Piscataway, NJ, USA
    Posts
    11

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    CG_PROFILE_FP30

    The float texture are read color.

  7. #7
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Piscataway, NJ, USA
    Posts
    11

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    Actually, I render a normal texture to the a float pBuffer, and then copy them to a float texture. Later, for easy to test, I used a all red texture.

    --------------------------------------------
    cgGLBindProgram(vProgram);
    cgGLEnableProfile(vProfile);

    cgGLBindProgram(fProgram);
    cgGLEnableProfile(fProfile);

    cgGLSetStateMatrixParameter( paraVpModelViewProj,
    CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY ) ;

    cgGLSetTextureParameter( paraFpTexture, logotexture ) ;
    cgGLEnableTextureParameter( paraFpTexture ) ;

    glBegin(GL_QUADS);
    glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
    glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
    glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
    glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
    glEnd();

    cgGLDisableTextureParameter( paraFpTexture ) ;
    cgGLDisableProfile(vProfile);
    cgGLDisableProfile(fProfile);

    // copy contents of pbuffer to a texture
    glBindTexture(GL_TEXTURE_RECTANGLE_NV, fptexture);
    glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, width, height);

  8. #8
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Piscataway, NJ, USA
    Posts
    11

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    Vertex program is the same with above one.
    Here is the fragment program.

    -----------------------------------------
    void main( float4 Position : POSITION ,
    float2 texCoord : TEXCOORD0 ,

    out float4 color : COLOR,

    uniform
    sampler2D texture)
    {
    float4 texColor = tex2D( texture, texCoord ) ;
    // color.x = 1.0 ;
    // color.y = 0.0 ;
    // color.z = 0.0 ;
    // color.w = 1.0 ;
    }

  9. #9
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Piscataway, NJ, USA
    Posts
    11

    Re: Bind GL_TEXTURE_RECTANGLE_NV texture!

    Oh!

    I made a stupid mistake!
    I comment out a useful code
    color = texColor!

    Sorry!

Posting Permissions

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