
GL.Uniform
Posted Saturday, 28 May, 2011 - 02:05 by Radar inHi all,
i am trying to implement my own math in OpenTK.
But i have a problem with the GL.Uniform when i try to send a vector or a matrix.
I am not sure how to make that. I thought i did it right but GetError() returns Invalid Op.
I try to send my Matrix like this:
unsafe { GL.UniformMatrix4(this.uniLoc(uniformLocation), 1, false, (float*)mat44); }
I overloaded two operators of my Matrix44 struct (i adapted that from the Vector4.cs):
unsafe public static explicit operator float*(Matrix44 v) { fixed (float* first = v.fields) //fields is array return first; } unsafe public static explicit operator IntPtr(Matrix44 v) { fixed (float* first = v.fields) return (IntPtr)(first); }
And the struct starts like this:
[StructLayout(LayoutKind.Sequential)] public struct Matrix44 { [MarshalAs(UnmanagedType.R4, SizeConst=16)] public float[] fields; // = new float[16]; ... ...
The matrix contains data. So it is not a problem of a uninitialized field-variable... well i guess.
I am still learning c# so if this is a noobish error i am sorry for that, but i don't understand why it does not work. I guess it must be my code.
Thank you very much in advance!!!


Comments
Re: GL.Uniform
I use this: