Debuging OpenGL 3.0 without direct API ( aka glBegin() ... )

81 views Asked by At

it is clear to me that direct API (like glBegin(); glVertex(); glBegin(); ) is not effective for rendering complex scenes and real world applications like Games.

But for debugging and testing small things it is very useful. eg. for debugging physics of object in scene ( visualization of vectors, like velocity vector, force ... ).

You may ask - why not to fall back to OpenGL 1.x for such small things? Because the rest of program use OpenGL 3.0 features, and because I really like fragment shaders.

Is there any way to use it with OpenGL 3.0 and higher ? Or what is the strategy for debuging if I don't want to write the whole ceremony like

glGenVertexArrays(1, &vao);                 
glBindVertexArray(vao);                       
glGenBuffers(2, vbo);                       
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);      
glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), diamond, GL_STATIC_DRAW);     
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);                          
glEnableVertexAttribArray(0);               
glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);      
glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(GLfloat), colors, GL_STATIC_DRAW); 
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);        
glEnableVertexAttribArray(1);                                
glDrawArrays(GL_LINES, 0, 4);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDeleteProgram(shaderprogram);
glDeleteBuffers(2, vbo);
glDeleteVertexArrays(1, &vao);

for every single arrow I want to plot?

1

There are 1 answers

0
Reto Koradi On BEST ANSWER

You can still use all the legacy features with OpenGL 3.2 or later if you create a context with the Compatibility Profile. Only the Core Profile has the legacy features removed.

Most platforms still seem to support the Compatibility Profile. One notable exception is Mac OS, where 3.x contexts are only supported with the Core Profile.

Up to OpenGL 3.1, there was only a single profile. The split into Compatibility and Core happened in 3.2.

Using the newer interfaces isn't really that bad once you got the hang of it. If your debugging use is relatively repetitive, you could always write some nice utility classes that provide a more convenient interface.