Question is regards to glbind

I am working on an 2D iPhone game using OpenGL ES and am still somewhat new to the world of OpenGL…

I have a level that is approximately 6000x2000 and I am currently drawing all of the levels elements on every iteration of my game loop. This requires many glBind calls. I have read that these calls are expensive and I am noticing some lag in my game.

What I was thinking of doing is to do a check on the elements and only draw them if they are within the current visible section of the level.

What I would like to know is if making these logic checks ( will need 4 checks for the bounds of the current rect) is less expensive than a glBind call.


Culling your scene to the “view volume” is always a win. It’s not just the “bind” calls - it’s all of the rendering that goes on as a result.

Assuming you represent each “object” in your scene as an enclosing sphere, you can do the field-of-view test in very little code. Represent the six faces of your view volume by their plane equations - substitute the origin of the sphere into the equation and you get the signed distance from that point to the nearest point on the plane using 3 multiplies and 3 additions. Compare that to the radius of the sphere and you now know whether the sphere is inside, outside or straddling that plane. Repeat for all 6 planes - and now you know whether to cull the object or draw it.

In many applications, you can ignore the front and back face of the view volume - and use symmetry to cut the amount of plane-equation math substantially.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.