-
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);
--------------------------------------------
-
Advanced Member
Frequent Contributor
Re: Bind GL_TEXTURE_RECTANGLE_NV texture!
Can you post the Cg code that's fetching from the rectangular texture?
-
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 ;
}
-
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 ;
}
-
Advanced Member
Frequent Contributor
Re: Bind GL_TEXTURE_RECTANGLE_NV texture!
What fragment profile are you using? What data is in the floating point texture?
-
Re: Bind GL_TEXTURE_RECTANGLE_NV texture!
CG_PROFILE_FP30
The float texture are read color.
-
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);
-
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 ;
}
-
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
-
Forum Rules