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've recently started porting some old rendering demos I did to modern OpenGL. I had a debug drawing class in my old code which used immediate mode glBegin(), glEnd() etc. for rendering debug objects such as triangles, cubes and spheres etc.

Originally I replaced the code in these functions with code to generate the VAO and VBOs (for position and colour), bind them, assign the vertex data, render, then disable and delete the VBOs and VAO. Is there anything wrong with this?

I've been thinking about modifying the class so that every time it gets a draw primitive call it generates the VAO and VBOs and assigns the vertex data but doesn't actually do the rendering until after all the other rendering has been completed. Then it renders all the debug prims that have been stored at once.

I'm not sure of the benefits of either way of doing this and was just wondering what people thought.

share|improve this question
up vote 7 down vote accepted

If you are doing debug drawing, then performance really shouldn't be your highest concern. Getting it working is far more important. After all, you won't be using this stuff in release builds, so what does it matter?

However, if you are interested in one way to do it, this page on buffer object streaming suggests ways to improve performance for manually-generated vertex data. Pay particular attention to the "Buffer Update" method.

share|improve this answer

Whether you want to use immediate mode or VBOs, it depends on the complexity of the scene. I've seen some examples where tangent/normal lines are drawn using immediate mode.

There is nothing wrong with using VBOs for debugging. However, keep in mind that, generally speaking, batching will give you performance benefits no matter which approach you use, so always look to use it whenever possible. You can still benefit a lot from batching in immediate mode (maybe even more), because it will greatly reduce the number of state changes. If batched properly, you will only ever need one GlBegin() and GlEnd(), and all similar data is tightly grouped together. The only difference is that you'll be batching state calls instead of vertex data.

share|improve this answer
I'm not wanting to use immediate mode at all as it's been deprecated. At the minute I've replaced immediate mode so that on a call to say DrawDebugCube() it creates the vertex buffers, populates them with data, renders them and then deletes them. What I'm thinking of doing is having DrawDebugCube() just create the buffers and populate them. Then all of the debug prims that have been buffered get rendered all at once later on. – user10329 Oct 4 '11 at 22:39

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.