Why are there mismatching types in OpenGL?
For example, if I have a vertex buffer object,
GLuint handle = 0;
glGenBuffers(1, &handle_); // this function takes (GLsizei, GLuint*)
Now if I want to know the currently bound buffer
glGetIntegerv( GL_ARRAY_BUFFER_BINDING, reinterpret_cast<GLint *>(&handle ) ); // ouch, type mismatch
Why not have a glGetUnsignedIntegerv or
have glGenBuffers take an GLint * instead.
That is because glGetIntegerv function is intended to get any integral type of information back from OpenGL. It includes also GLint type values (negative ones). And also it includes multiple component values like GL_VIEWPORT:
From one point of view – it is simpler to have just one function for getting values back, instead of hundreds for each specific parameter.
Form other point of view – of course it’s a bit ugly to cast types.
But no idea why they didn’t use GLint for buffer id.
Anyway – you shouldn’t bee calling any glGet… functions. They are slow and often requires waiting on GPU complete previous commands – meaning CPU will wait idle in that time.