468,512 Members | 1,338 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

error: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style

I want to convert a array parameter like 'double [i]' to point like "const GLfloat *"
in Visual Studio 2008,and the array is "double [i][j]".
thanks help!
Apr 17 '08 #1
2 4083
scruggsy
147 100+
I want to convert a array parameter like 'double [i]' to point like "const GLfloat *"
in Visual Studio 2008,and the array is "double [i][j]".
thanks help!
Post the code that gives you the compiler error.
Apr 17 '08 #2
TamusJRoyce
110 100+
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:
Expand|Select|Wrap|Line Numbers
  1. // You have an array of double's called "input"
  2. //    like double input[i];
  3.  
  4. // This is GLfloat *toConvertTo;  
  5. //    with i data elements allocated
  6. GLfloat toConvertTo[i]; 
  7.  
  8. // Probably don't need register.  Use register with caution...
  9. //    Bad use of register can slow program down.
  10. for (register int count = 0; count < i; ++count)
  11. {
  12.   toConvertTo[i] = (GLfloat)input[i];
  13. } // End for
  14.  
  15. // If passing to a parameter that takes in 
  16. //   const GLfloat *, just pass toConvertTo
  17. //   and ignore making it a const.
  18. const GLfloat *constConverteTo = toConvertTo;
  19.  
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
Apr 18 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Michael Wagner | last post: by
7 posts views Thread by Matthew Del Buono | last post: by
4 posts views Thread by troloo | last post: by
1 post views Thread by DiskMan | last post: by
669 posts views Thread by Xah Lee | last post: by
8 posts views Thread by Born Bugler | last post: by
3 posts views Thread by Markus Dehmann | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.