Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.