how to display a second picture in a delayed time

Hi,

I need to develop an application which do the following:

  1. The program will read in an image from disk and display it.
  2. The program will process the image.
  3. The program will also display the the processed the image.

In step 2 and step 3, I also need the original image being
displayed until the user close the image window or close the
application.

The problem is that, if I use glutmainloop() to display the
first picture, the program keep trapped with the loop and do
not proceed to process the image; while If I put the glutmainloop() after I processed the image, it violates my purpose since the I cannt got the image be displayed before
it was being processed.

In one words: I need a method to display an image (and keep
the window open) while proceed to process this image and then displayed the processed image in a second window.

Could anyone just tell me how can I do this?

Thanks a lot.

I usually use glfw instead of glut. It gives you all the control over the main loop.

Of course, there are solutions for glut also.

I am learning glfw, but stil dont know how.

Could you tell me how to keeping displaying an image while
proceed?

Just to give you a direction, create multiple forms - i.e if you are working on Windows MFC or Win Forms. Then each form has a device context. Create multiple graphics context and attach them to different device contexts. This will chanellize your graphics data to different forms. You can refer to wgl*() functions (wglCreateContext)that talk about making a graphics context etc.

In short you will have two graphic contexts. Make one of them the current one using wglSetCurrentContext() where you will render your image. Then when you are ready for processing, create another graphic context and make that current one.

I dont think you need two context here, use a single context. For displaying image, just display it normally. For processing image, you can either attach a timer callback (glutTimerFunc) and do processing it it or you can do the processing in the idle callback function (glutIdleFunc).
For displaying both images, just render the processed image at an offset from the original image.

I had thought of that option but following is required:

In one words: I need a method to display an image (and keep
the window open) while proceed to process this image and then displayed the processed image in a second window.

Two windows are needed here.

So you have two images, but you can still show them in the same window, side by side? That would be easier.

Then you need no timers. When the second image is available, you simply assign it to the other texture.