opengl in loop help

Hey guys

I couldn’t find anyone to help on this problem so hope you guys can help

so this is how my program works

i have the glut init function, glut keyboard press and resize function already

int main
declare 3d array filled with ‘1s’
capture one frame from video/webcamera
process image (segmentation) resulting in a binary image
capture the corners
calibrate camera using those corners
loop through all the 3d coordinates and find the equivalent 2d coordinates.
for the corresponding 2d for each 3d, is checked on the binary image to see if it is black or white element and to see if the 3d location on the 3d array is 1 or a 0
if it is 1, the 3d coordinate is pushed into a vector of vertices
if binary pixel at 2d location is black than turn the element in the 3d array at the 3d coordinate location element to zero
else skip to next 3d coordinate and its equivalent 2d coordinate
loop to next frame

so on the first loop all elements in 3d array should be 1 and it should render a cuboid, which it does, but that’s it, it does not loop to next frame and re render.

so i was thinking maybe its the placement of the handler functions and the drawing function, timer function and mainloop function

i place the first two keyboard press and window resize at the beginning of the loop, and the display after it has looped through the 3d array and displays the resulting vector
and timerfunction and main loop at the end of the loop but still it doesn’t re render for second frame included

also i can use glutleavemainloop from freeglut, and i want that to leave the main loop comeout of the while loop and execute the second glut functions, this will render the final vector of vertices and display the final image.

but after glutleavemainloop i don’t know where it goes as i left a message before return and it didn’t print that message to indicate it has reached there. i don’t think it left the while loop it just stopped.

really need help with this