View Full Version : glDrawPixels with dynamic "array"

12-06-2003, 04:16 PM
I was hoping someone could help me understand (or at least agree with me) why I am having problems using a dynamic array with glDrawPixels. I have no problem with glDrawPixels when declaring a static 3d array with predefined dimensions. Is the reason I sometimes get a null reference due to the fact that my dynamic "array" isnt necessarily contiguous whereas the static predefined one is?

Here is my code...

class FrameBuffer
GLfloat*** theBuffer;
int length,width,depth;

FrameBuffer::FrameBuffer(int x, int y, int colors)
width = x;
length = y;
depth = colors;
theBuffer = new GLfloat**[x];
for(int i = 0; i < width; i++)
theBuffer[i] = new GLfloat*[y];
for(int j = 0; j < length; j++)
theBuffer[i][j] = new GLfloat[depth];
for(int k = 0; k < depth; k++)
theBuffer[i][j][k] = 0.0f;


12-07-2003, 01:37 AM
Just like you say, it's becuase a tripple pointer is not a contiguous memory block. Allocate the whole image in one allocation instead, and make it a single pointer.