Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of 3d models I want to draw and also for some of them I want to draw bounding boxes. Calculating the boundnig boxes is no problem, but I'm not sure as to what is the best approach to rendering them.

I have a vertex and fragment shader for my 3d models and they contain a ton of information not needed to draw simple bounding boxes (textures, normals, etc) linked up in a program. Now I also want draw bounding boxes for each of the models meshes and I can think of two ways using two shader programs (one for 3d models and one for bounding boxes):

  • after drawing each mesh change program to boundingbox and draw its boundingbox
  • after drawing all meshes, change program to boundingbox and draw all boundingboxes for all meshes

I am inclined to believe the 2nd option is better, but is the overhead of glUseProgram significant enough to notice?

share|improve this question

Well, I will assume you will need to draw the bounding boxes for debugging only, if I were you I will go with the easier solution; the solution that won't let me change a lot of code Since this is only for debugging I will not be concerned a lot about performance (even though your 2nd solution might be better for performance), you can introduce a preprocessor tag (assuming you are using C/C++) that will disable the box rendering piece of code in release mode, or you can do it in real time by using a flag to render or not.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.