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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hqcchina
    New Member
    • Apr 2008
    • 1

    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!
  • scruggsy
    New Member
    • Mar 2007
    • 147

    #2
    Originally posted by hqcchina
    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.

    Comment

    • TamusJRoyce
      New Member
      • Apr 2008
      • 108

      #3
      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:
      Code:
      // 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
      Last edited by TamusJRoyce; Apr 18 '08, 04:53 AM. Reason: spacing

      Comment

      Working...