Using glGenVertexArrays


#1

Hello,

I want to use some VertexBuffer functions (ie: glGenVertexArrays, glBindVertexArray) in my OpenGL application but I cannot seem to get it to work, even if I compile JUCE with the JUCE_OPENGL3 macro. I am using linux and JUCE version 4.3.1. Are these functions not available?

Thanks for your help!


#2
void* ptr = OpenGLHelpers::getExtensionFunction("glGenVertexArrays");
typedef void(*func_type)(GLsizei n, const GLuint *arrays);
((func_type)ptr)(1, &vertexArrayObject);

ptr = OpenGLHelpers::getExtensionFunction("glBindVertexArray");
typedef void(*func_type_2)(GLuint p1);
((func_type_2)ptr)(vertexArrayObject);

#3

Thank you! It works now.

Could you perhaps explain the logic behind how all the OpenGL functions are organized?

//For glGenVertexArrays:
void* ptr = OpenGLHelpers::getExtensionFunction("glGenVertexArrays");
typedef void(*func_type)(GLsizei n, const GLuint *arrays);
((func_type)ptr)(1, &vertexArrayObject);

//For glBindBuffer:
openGLContext.extensions.glGenBuffers(1, &vboID);

//For glViewport:
glViewport(0, 0, 300, 300); //No openGLContext necessary (?)

Why is there not one consistent method for accessing all available functions?


#4

Why is there not one consistent method for accessing all available functions?

Because there’s a metric shit load of 'em! You can use the OpenGLExtensionFunctions to access a solid chunk of them easily.