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);

Can you post the Cg code that’s fetching from the rectangular 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 ;
}

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 ;

}

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

CG_PROFILE_FP30

The float texture are read color.

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);

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 ;
}

Oh!

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

Sorry!