/// <summary> /// Converts a Matrix4 object to a float[16] that contains the matrix /// in top to bottom, left to right order. /// i.e. glMatrix[0] = matrix[0,0] /// glMatrix[1] = matrix[1,0] /// etc... /// </summary> /// <param name="matrix"></param> /// <returns></returns> private void MakeGLMatrix(ref Matrix4 matrix, float[] floats) { Matrix4 mat = matrix.Transpose(); mat.MakeFloatArray(floats); }
/// <summary> /// Sends a multiple value constant floating-point parameter to the program. /// </summary> /// <remarks> /// This method is made virtual to allow GpuProgramManagers, or even individual /// GpuProgram implementations to supply their own implementation if need be. /// An example would be where a Matrix needs to be transposed to row-major format /// before passing to the hardware. /// </remarks> /// <param name="index">Index of the contant register.</param> /// <param name="val">Structure containing 3 packed float values.</param> public void SetConstant(int index, Matrix4 val) { Matrix4 mat; // transpose the matrix if need be if(transposeMatrices) { mat = val.Transpose(); } else { mat = val; } // resize if necessary if (index + 4 >= float4VecConstantsCount) ResizeFloatConstants(index + 4); floatIsSet[index + 0] = true; floatIsSet[index + 1] = true; floatIsSet[index + 2] = true; floatIsSet[index + 3] = true; if (index + 4 >= maxSetCount) maxSetCount = index + 4; int eltIndex = index * 4; floatConstantsArray[eltIndex + 0] = mat.m00; floatConstantsArray[eltIndex + 1] = mat.m01; floatConstantsArray[eltIndex + 2] = mat.m02; floatConstantsArray[eltIndex + 3] = mat.m03; floatConstantsArray[eltIndex + 4] = mat.m10; floatConstantsArray[eltIndex + 5] = mat.m11; floatConstantsArray[eltIndex + 6] = mat.m12; floatConstantsArray[eltIndex + 7] = mat.m13; floatConstantsArray[eltIndex + 8] = mat.m20; floatConstantsArray[eltIndex + 9] = mat.m21; floatConstantsArray[eltIndex + 10] = mat.m22; floatConstantsArray[eltIndex + 11] = mat.m23; floatConstantsArray[eltIndex + 12] = mat.m30; floatConstantsArray[eltIndex + 13] = mat.m31; floatConstantsArray[eltIndex + 14] = mat.m32; floatConstantsArray[eltIndex + 15] = mat.m33; }