View Full Version : Global Variables in Render List
09-23-2003, 05:14 PM
I'm attempting to load my Depth buffer into a GLfloat* that has been initialized with malloc(WindowWidth*WindowHeight*sizeof(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?
09-23-2003, 07:26 PM
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.
09-23-2003, 10:45 PM
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;
int* p = malloc( 4);
*p = 0;
*p = 1; // not good....
09-25-2003, 11:40 AM
hmm, not so much. But I just needed to know whether GL had a problem with it. Thanks.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.