OpenGL - game, NOT rendering objects, not in view.

I am working on a 2d game. Imagine a XY plane and you are a character. As your character walks, the rest of the scene comes into view.

Imagine that the XY plane is quite large and there are other characters outside of your current view.

Here is my question, with opengl, if those objects aren’t rendered outside of the current view, do they eat up processing time?

Also, what are some approaches to avoid having parts of the scene rendered that aren’t in view. If I have a cube that is 1000 units away from my current position, I don’t want that object rendered. How could I have opengl not render that.

I guess the easiest approaches is to calculate the position and then not draw that cube/object if it is too far away.

Well, there are many approaches. You can try checking if each part of the scene is viewed on the screen and if it is, draw it. But this is expensive and the approach I would prefer is to use a linked-tile approach where each tile stores pointers to adjacent tiles. This way when the viewed tile comes out of view, the application can load the corresponding adjacent tile and skip checking every single one of them(Another example of storage vs computation).

About characters-dynamic objects(sprites).
Each sprite can have a parent tile. When it moves to the edge of the tile it changes ownership accordingly, using the appropriate pointer(see above). When each tile is rendered it also renders its child sprites.

Hope that helps!!

If you are calling functions to draw geometry, then yes, you are taking up resources.

A technique to reduce the amount that gets drawn is to organize the scene into a octree (or quadtree in your case) based on position. Then, you can test a large section of the scene to see if it is visible. If it is, you can travel down the tree and test the child nodes or draw everything in that section. Generally, you do this before you start calling OpenGL functions.

Yes they take up processing and rendering time. OpenGL cannot tell whether they are visible until it has transfromed them.

Applications have an advantage over OpenGL in that they can often trivially detect whether an entire game object (rather than individual vertices in an object) is visible.

All well written 3D applicatiosn detect what is visible to some degree of granularity (not the polygon level usually game object/entity level) and only send this subset of the scene to OpenGL for rendering.

Search for “view frustum culling” to find lots of information on determining what is visible, not visible and potentially visible.