PDA

View Full Version : How to use these GL Extensions?



marathon
01-16-2012, 10:16 AM
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....

Alfonse Reinheart
01-16-2012, 11:00 AM
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 `extern`ed 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".

marathon
01-16-2012, 11:14 AM
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.

marathon
01-17-2012, 10:23 PM
Any more information or links would be really helpful.

V-man
01-18-2012, 06:56 AM
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

marathon
01-19-2012, 12:16 AM
Thankyou so much.