Problem with projective textures

Hi, i’m trying to make projective textures with shaders. I have the issue that the projected texture applied to the object is actually moving inside it as i move the camera. I suppose there is an error with the texture matrix.
Can you help me ? Here is the code:

 
void SetShader()
{
...
cgGLSetStateMatrixParameter(vModelViewProj,CG_GL_MODELVIEW_PROJECTION_MATRIX,CG_GL_MATRIX_IDENTITY);
glMatrixMode( GL_TEXTURE );
float   proj[16];
float   modl[16];
glPushMatrix();
glLoadIdentity();
glGetFloatv( GL_PROJECTION_MATRIX, proj );
glGetFloatv( GL_MODELVIEW_MATRIX, modl );
glTranslatef( 0.5f, 0.5f, 0.5f ); 
glScalef( 0.5f, 0.5f, 0.5f );
glMultMatrixf( proj );
glMultMatrixf( modl );
vTex  = cgGetNamedParameter(fogv, "vTexProj");
cgGLSetStateMatrixParameter( vTexProj, CG_GL_TEXTURE_MATRIX, CG_GL_MATRIX_IDENTITY );
glPopMatrix();
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
...
}
 
  
/****************
* vertex shader *
****************/
void fogv(float4 vPos	: POSITION, 
           float4 vTex	: TEXCOORD0,
	   float3 vNormal: NORMAL,
              out float4 oPos	: POSITION,            
              out float3 oF	: COLOR0,
              out float4 oTexcoord0 : TEXCOORD0,
	      out float3 oPosition  : TEXCOORD1,
	      uniform float3 vEyePos,
	      uniform float4x4 vModelViewProj,
	       uniform float4x4 vTexProj
	 )
{
	oPos = mul( vModelViewProj, vPos );
	oPosition.xyz = vPos.xyz;
	oTexcoord0 = mul( vTexProj, vPos );
	float z = length(vPos.xyz - vEyePos.xyz);
		
}
 
/****************
* pixel  shader *
****************/
void fogf(
	float3 F  : COLOR0,
        float4 Texcoord0  : TEXCOORD0,
        float3 Pos        : TEXCOORD1,
        out  float4 Color : COLOR,
        uniform float3      fLightDir,
        uniform float3      fFogColor,
        uniform float4      fSunColorIntensity,
	uniform sampler2D   fSampler0  		   )
{  
   Color      = tex2Dproj( fSampler0, Texcoord0);           // Apply texture   
}
 

From the code it looks like the texture matrix is based the modelview and projection matrices that are used to project the vertex during the rendering and not on matrices that correspond to the projector.