1
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .