PopcornKing

12-06-2003, 05: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

{

public:

FrameBuffer(int,int,int);

FrameBuffer();

~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;

}

}

}

Here is my code...

class FrameBuffer

{

public:

FrameBuffer(int,int,int);

FrameBuffer();

~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;

}

}

}