Moving/rotating object

Hello, I want to ask if you have many objects (each object contains many triangles), how do you get object id and later on rotate just this or move without clearing whole screen and sending all triangles again each frame??


Not sure what you mean by ‘get object id’. If you mean select it by clicking on it with the mouse, then you could use picking.

In all OpenGL programming I’ve ever done, the entire scene (i.e. all polygons) are redrawn each time the screen is updated. If you don’t want to do this, just don’t call glClear. The problem with updating only one object in a scene is that it is probably moving, changing shape, etc. That means you have to erase the old version of the object, before drawing the new version of the object. What if this object overlaps other objects? You’d have to check for this and redraw those other objects that got erased with the primary object. It gets messy. This is why all polygons in a scene are usually redrawn.

I see, what if scene has like 10 million or more polygons? It would take so long just for the CPU to tell where each polygon is?

You can look at layering - it depends a bit on your application. You can render to several framebuffers and merge. This can mean only some of your objects need to be redraw and the others are created with a blend of the frame buffers. You will need to handle sharing depth buffers.
I do this when rendering tins (ground terrain) followed by surface objects. I only need to re-render the tin when the camera changes.