Global Variables in Render List

I’m attempting to load my Depth buffer into a GLfloat* that has been initialized with malloc(WindowWidthWindowHeightsizeof(GL_FLOAT) with glReadPixels. When I place the Malloc inside of the render list that also has the function to load/draw the depth buffer everything is fine, however, when I globally define my Buffer variable and malloc it outside of the render list I recieve a segmentation fault, and the depth pointer is somehow assigned to 0. Is there a problem with using globally defined/malloc’ed pointers for your variables in a display list or is there an independant problem?

I don’t see why that would be a problem. Maybe you have left the pointer definition within the local function, and so it is being used instead of the global pointer (due to scope). This might cause your problem but is a total guess.

Yes, you have messed up somewhere, and as said above, one of the more common mistakes is that you have left a local copy with the same name:

int* p = NULL;

void function()
{
int* p = malloc( 4);
*p = 0;
}

void function2()
{
*p = 1; // not good…
}

Mikael

hmm, not so much. But I just needed to know whether GL had a problem with it. Thanks.