I'm trying to rewrite my c++ code which implements non-fixed pipeline matrices to C#, using OpenTK. I'm encountering problems, as I don't understand why this code is invalid.
static class ModelView
{
static private Stack<Matrix4> matrix = new Stack<Matrix4>();
static public Matrix4 Matrix
{
get
{
return matrix.Peek();
}
set
{
matrix.Pop();
matrix.Push(value);
}
}
static public Matrix4 MatrixNormal
{
get
{
Matrix4 m = matrix.Peek();
m.Invert();
m.Transpose();
return m;
}
}
static public int Uniform { get; set; }
static public int UniformNormal { get; set; }
static private void SetUniforms()
{
if (Uniform == -1 || UniformNormal == -1)
throw new Exception("Projection matrix uniform is uninitialized");
GL.UniformMatrix4(Uniform, false, ref Matrix);
GL.UniformMatrix4(UniformNormal, false, ref MatrixNormal);
}
/* stack & matrices manipulating funcs */
}
Visual Studio says that "A property, indexer or dynamic member access may not be passed as an out or ref parameter." on those lines:
GL.UniformMatrix4(Uniform, false, ref Matrix);
GL.UniformMatrix4(UniformNormal, false, ref MatrixNormal);
Why can't I pass Stack.Peek() as it should be only Object reference.