Since you are asking how to do this, I'm assuming you can't compile this because you don't know how...
I'm assuming you are using OpenGL, and wanting to pass an array of GLfloat's, when you have double's. And more specifically, I'm guessing for manipulating the matrix opengl uses for projections?
Maybe not, but it's a guess : )
For the 1D array:
-
// You have an array of double's called "input"
-
// like double input[i];
-
-
// This is GLfloat *toConvertTo;
-
// with i data elements allocated
-
GLfloat toConvertTo[i];
-
-
// Probably don't need register. Use register with caution...
-
// Bad use of register can slow program down.
-
for (register int count = 0; count < i; ++count)
-
{
-
toConvertTo[i] = (GLfloat)input[i];
-
} // End for
-
-
// If passing to a parameter that takes in
-
// const GLfloat *, just pass toConvertTo
-
// and ignore making it a const.
-
const GLfloat *constConverteTo = toConvertTo;
-
Do a nestled loop (one loop inside another) similar to the above code for a 2D array of double's to GLfloats. GLfloat is usually just a "typedef float GLfloat;" which means it's equivalent to a float.
like: GLfloat pi = 3.14f; // where f tells the compiler that
// 3.14 is a float