Note that there are some explanatory texts on larger screens.

plurals
  1. POShader and opengl transformations
    primarykey
    data
    text
    <p>When i add shaders (in cg) to my opengl program all the local transformations (glRotatef, glTranslatef and glScalef between glPushMatrix and glPopMatrix) stop working. Transforms outside push/pop still working though. So what might be the problem here?</p> <p>update: I have a rotating cube in the center of the scene:</p> <pre><code>glPushMatrix(); glRotatef(angle, 1, 0, 0); drawBox(); glPopMatrix(); </code></pre> <p>and after that i send worldview and worldviewprojection matrices to shader:</p> <pre><code>cgGLSetStateMatrixParameter( myCgVertexParam_modelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY ); cgGLSetStateMatrixParameter( myCgVertexParam_modelView, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY ); </code></pre> <p>Vertex shader code:</p> <pre><code>void C9E2v_fog(float4 position : POSITION, float4 color : COLOR, out float4 oPosition : POSITION, out float4 oColor : COLOR, out float fogExponent : TEXCOORD1, uniform float fogDensity, // Based on log2 uniform float4x4 modelViewProj : MODELVIEW_PROJECTION_MATRIX, uniform float4x4 modelView : MODELVIEW_MATRIX) { // Assume nonprojective modelview matrix float3 eyePosition = mul(modelView, position).xyz; float fogDistance = length(eyePosition); fogExponent = fogDistance * fogDensity; oPosition = mul(modelViewProj, position); //oDecalCoords = decalCoords; oColor = color; } </code></pre> <p>So in the end cube doesnt rotate, but if i do write (no push/pop)</p> <pre><code>glRotatef(angle, 1, 0, 0); drawBox(); </code></pre> <p>everything works fine. How do i fix that?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload