i am used to code in ASM and had the need to switch to C++ for some OpenGL project. Anyway i got the following procedure:
glGenBuffers(Size, PointerToBuff);
According to what i understand the handles according to the Size argument (Number of buffers) will be stored on PointerToBuff. So i wanted to use an structure to save the 2 handles i will get in case i use:
glGenBuffers(2, *PointerToBuff);
So i create an struct:
struct VertexHandlers
{
GLuint cubevertex;
GLuint trianglevertex;
}VBHandlers;
And use the proc as this:
glGenBuffers(2, &VBHandlers);
The error i get its:
error C2664: 'void (GLsizei,GLuint *)' : cannot convert parameter 2 from 'main::VertexHandlers *' to 'GLuint *'
2> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
2>C:\Documents and Settings\Owner\My Documents\Downloads\OpenGL-tutorial_v0003\playground\playground.cpp(181): error C2664: 'void (GLsizei,GLuint *)' : cannot convert parameter 1 from 'main::VertexHandlers *' to 'GLsizei'
2> There is no context in which this conversion is possible
I am not used to “Typecast” barely know something, but when regarding pointers i tought (&) operator will take addr of the local variable created. Hope i get some help, thanks.
glGenBuffers()expects an array ofGLuints, not a pointer to an object that happens to have twoGLuints in a row. That’s why the compiler complains about it. Yes, they both may have the same memory representation on your machine, but it may not be the case on another.If you want to store the results of
glGenBuffers()into a structure, you can do something like this:This is the safest, portable way to do it, assuming
glGenBuffersdoesn’t fail.