/// <summary> /// Sets a matrix parameter on a special semantic in a Cg program</summary> /// <param name="parameter">Name of parameter that we want to set</param> /// <param name="semantic">The semantic that is needed to set a parameter in a special way</param> /// <returns>True if parameter set successfully</returns> public static bool SetMatrixParameter(string parameter, string semantic) { IntPtr param; int matrix = 0; int tranform = 0; try { m_cg_parameters.TryGetValue(parameter, out param); if (semantic == "WORLDVIEWPROJECTION") { matrix = CgGl.CG_GL_MODELVIEW_PROJECTION_MATRIX; tranform = CgGl.CG_GL_MATRIX_IDENTITY; } CgGl.cgGLSetStateMatrixParameter(param, matrix, tranform); return(true); } catch { } return(false); }
private void SetShaderParametersPass2(Vector3f eyeVect) { CgGl.cgGLSetParameter3f(m_CGparam_eyePositionPass2, ViewerPosition.x, ViewerPosition.y, ViewerPosition.z); checkForCgError("setting eyePos2"); // Track the combined model-view-projection matrix CgGl.cgGLSetStateMatrixParameter(m_CGparam_modelViewProjPass2, CgGl.CG_GL_MODELVIEW_PROJECTION_MATRIX, CgGl.CG_GL_MATRIX_IDENTITY); checkForCgError("setting model view projection matrix parameter2"); //set modelViewIT matrix CgGl.cgGLSetStateMatrixParameter(m_CGparam_modelViewITPass2, CgGl.CG_GL_MODELVIEW_MATRIX, CgGl.CG_GL_MATRIX_INVERSE_TRANSPOSE); checkForCgError("setting model view IT matrix parameter2"); CgGl.cgGLSetStateMatrixParameter(m_CGparam_modelViewPass2, CgGl.CG_GL_MODELVIEW_MATRIX, CgGl.CG_GL_MATRIX_IDENTITY); checkForCgError("setting model view matrix parameter2"); }