tags:

views:

76

answers:

4

For example if I draw a cube and turn my character around so as to face away from the cube does it use CPU/gpu processing to draw it even though it is not on screen? Do I as a programmer need to be smart enough to not make opengl draw calls if an object is not on screen or very far away?

+1  A: 

You can enable the 'scissor test' to clip drawing against the scissor rectangle.

That said, this doesn't stop all the rest of your drawing code from running - so unless your scene is quite simple you usually want to look into more complex methods.

Octrees and BSP trees are a good place to start.

sje397
+2  A: 

It doesn't render them as such, but it does use resources which I believe is what you're asking. Yes, you do. You're probably after frustum culling: http://www.lighthouse3d.com/opengl/viewfrustum/

Rushyo
+1  A: 

Yeah, GL does discard pixels which are out of view, but that still consumes resources, since it's per-pixel. Skipping the draw calls of non-visible primitives is a much better approach.

Matias Valdenegro
+1  A: 

Yes. All vertex data sent to OpenGL will consume resources, regardless of whether or not the corresponding geometry is in view. As suggested above, frustum culling is an optimization that identifies objects that will not be in the view volume and ignores/culls its vertex data. Thus, if the vertex data is never submitted to the GPU, then it will never be processed by the GPU.

Alex Wood