0

Anyone have links to tutorials on this topic? I cannot seem to find any related to 2d culling. Or if anyone here could explain how it's done. I use gluOrtho2D and gluLookAt currently.

genpfault
  • 51,148
  • 11
  • 85
  • 139
semajhan
  • 708
  • 3
  • 11
  • 24

2 Answers2

2

GL shouldn't be drawing outside of the clipping planes that you defined in gluOrtho2D

One way to convince yourself of this is to compare the frame rate you get when you display a portion of the map vs. zooming out and displaying the entire map.

For larger scenes, this may not be enough. In that case, determine which polygons are completely outside of the viewing frustum with code like in:

http://web.archive.org/web/20030207104008/http://www.markmorley.com/opengl/frustumculling.html

levis501
  • 4,117
  • 23
  • 25
  • So am I right in thinking I can draw the whole Vertex Array containing vertices for 200 triangles and if they are out of the clipping planes defined, they should be culled? And what if I were to move the camera to the right by 1 square's length? – semajhan Jan 23 '11 at 00:57
  • They will be culled regardless of where you put the camera. If you move the camera, the clipping planes move with it. – levis501 Jan 23 '11 at 02:18
1

If you mean geometry culling, then wouldn't it be just as simple as checking if the polygon you are drawing lies outside of the rectangle defined by your gluOrtho2D and gluLookAt? If it's outside, then don't draw it.

vmpstr
  • 5,051
  • 2
  • 25
  • 25
  • I got as far as that but the wall I can't get past is how NOT to draw. I create a large "map" say 100x100 and store the verts in a Vertex Array. What I don't understand is, I point to the Vertex Array to draw so it's going to draw the whole map. – semajhan Jan 22 '11 at 23:31
  • 2
    The way I approached a similar problem in the past is to draw using element arrays.. So for your map of 100x100, I would have the full array of vertex information, and then 20x20 arrays of element vectors that draw their own 5x5 data piece. That way I can cull away sets of 5x5 vertices pretty easily – vmpstr Jan 24 '11 at 04:09