HI, This is a newbie question, but how do you retain a scene and add on new “objects” in the scene… example, a picture of a field sprouting flowers, how do I make the previous flowers still present while I add on new flowers with each new scene?
You have to take care of that yourself, every time you start to render a frame you start all over again, so everything that was there on the previous frame has to be rendered again and then you also need to add any new stuff of course.
If you have a lot of static geometry you can create a display list and put it in there and just render the displaylist.
Another alternative is to save the framebuffer contents and the depth buffer contents with glReadPixels and then you can later put that “snapshot” back, and if you restore the depth buffer at the same time you can add new stuff to the image.
But in the end, OpenGL is just the rendering engine, the rest is up to you.
Thanks for the reply! I have 2 other questions for you if you don’t mind?
- For the scenario i described in the last message, I have data coming in from a class written in C++, which allows data to come in through the UART serial port.
I also have an array of variables and each element in the array represents a status of a particular flower.
So when the element shows 1, the flower must be rendered, if it shows 0, the flower must be removed.
But of course, the static scene must still be rendered.
So, is there a known ‘correct’ way to do this? if not, any advice for me?
2)The second question is regarding using opengl with MFC. I have been trying out MFC with OpenGL, but without Glut.
Right now I have the online version of the ‘RedBook’ but most of the examples use glut.
Is glut and MFC mutually exclusive? From my impression, both glut and MFC hande windows messages, right? So will they be incompatible?
Thanks for your attention! Have a nice day!
You should not mix the two, ether use the windows API or the GLUT, the advantage to glut is it is simple to use.
You scene is really not static, since it is subject to change. More a dynamic scene, based on if a flower is added or deleted.
Just create a flower array and only need to update then there is a change to the scene.
In ether windows or glut you would need an event loop:
flower = scan_uart(); //check for change in flowers state
if (flower) flower_event();
if (add_flower) flower_total++;
if (delete_flower) flower_total--;
simplestic example but maybe give you an idea.
thanks alot! will try it out… actually i was considering MFC with OpenGL at first because I had already started my work in MFC, but now I probably have to put my focus on glut because it is easier…thanks for the advice!
You also might want to try out SDL for easy setup when working with opengl.