title: OpenGl glTexImage2D data
body: <p>I am trying to read floatingpoint numbers from a <code>CSV file</code>, that contains a precomputed texture, store it in a 1 dimensional array, and then put that read data into a 2 dimensional texture.<br>
  I need to make sure the following code does that, because i have problems accessing the data and I cannot figure out where the error is:  </p>
  
  <pre><code>// Allocate memory  
  float * image = new float [width * height * 3 ];  
  for( int i = 0; i &lt; height; i++)  
      {  
          for( int j = 0; j &lt; width-1; j++)  
              {  
                  fscanf( fDataFile, "%f,", &amp;fData );  
                  image[ 4 * i * j + 0 ] = fData;  
                  image[ 4 * i * j + 1 ] = fData;  
                  image[ 4 * i * j + 2 ] = fData;  
              }  
          fscanf( fDataFile, "%f", &amp;fData );  
          image[ 4 * i * width-1 + 0 ] = fData;  
          image[ 4 * i * width-1 + 1 ] = fData;  
          image[ 4 * i * width-1 + 2 ] = fData;  
       }   
  </code></pre>
  
  <p>There shouldn't be a problem here, but what troubles me is the following:  </p>
  
  <pre><code>// create the texture  
  glGenTextures(1, &amp;texHandle);  
  glBindTexture(GL_TEXTURE_2D, texHandle);   
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_FLOAT, &amp;image[0]); 
  </code></pre>
  
  <p>Is it okay to just give <code>glTexImage2D</code> the pointer to my onedimensional array?<br>
  the size of the array is width*height*3 and the texture's format should be width*height with 3 channels... so the size should be okay i guess?!
  Still my program won't work as expected and this is one potential source for an error.</p>