
OpenTK and Cg Parameters
Posted Friday, 17 October, 2008 - 20:46 by reven inHi, I'm currently using OpenTK and Tao.Cg to include shader support in the project.
There is, however a problem I cannot find a sane solution to, without adding methods doing more work than necessary. The problem is as follows:
I can get some a parameter from a cg effect file with like this:
Vector3 position = Vector3( );
IntPtr pos = Cg.cgGetEffectParameterBySemantic(CgEffect, "Position");
CgGl.cgGLSetParameter3fv(color, new float[] {position.X,position.Y,position.Z});
I'd like not to create that copy. I am aware that I can use cgGLSetParameter3f and then avoid the new array, but I really don't think that it should be necessary to use the property for each of the variables if they could just be returned as a float[].
Why does the class not provide that?
On a sidenote, anyone knows how I would provide my Cg effect file with a matrix that is not currently in the OpenGL state, but managed by myself? I.e. set a matrix parameter from something else than the state manager.


Comments
Re: OpenTK and Cg Parameters
A copy would still be needed even if the Vector class could be cast to
float[]. Only IfCgGl.cgGLSetParameter3fvprovides a "ref float" overload will you be able to avoid the copy: