I need to develop an application which do the following:
The program will read in an image from disk and display it.
The program will process the image.
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.
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.