How to use these GL Extensions?

I have the following lines in a header file…

typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, int size, const GLvoid *data, GLenum usage);

PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL; PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL; PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL; PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;

and when I include this header in any other file, I always get a
"fatal error LNK1169: one or more multiply defined symbols found " in the visual studio.

I wanted to keep these declarations in a seperate header file.

any help appreciated.

thanks,
marathon.
still a long way to go…

You need to declare those function pointers extern. Just as with any other global variable you stick in a header. You also can’t initialize them to NULL in the header; that can only happen in the source file.

And since they’re externed in the header, you must define them in a source file (just one) somewhere. Probably the place you have your function pointer loading code.

Oh, and please stop using the extension form of buffer objects! It’s been core OpenGL functionality for near on a decade now. Use the core functions, the ones that don’t end in “ARB”.

Alfonse,

thanks for the good tip.

after a long search I realized the resources on VBO and I hope I come out of the jinx and start to use the programmable pipeline after going through the book.

thanks.

Any more information or links would be really helpful.

There is this
http://www.opengl.org/wiki/Load_OpenGL_Functions

but in my opinion, you are wasting your time getting function pointers. Use a library like GLEW or GL3
http://www.opengl.org/wiki/OpenGL_Loading_Library

and as for VBO
http://www.opengl.org/wiki/Vertex_Buffer_Object
http://www.opengl.org/wiki/VBO_-more
http://www.opengl.org/wiki/VBO-_just_examples

Thankyou so much.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.