PDA

View Full Version : Undefined Reference to VBO functions



Quaver
07-29-2013, 09:22 AM
I am compiling using MingW with the following flags:

-lmingw32 -mwindows -lopengl32 -lglu32 -lwinmm -lws2_32

And in my project I include the following lines:

#include <gl/gl.h>
#include <gl/glu.h>
#define GL_GLEXT_PROTOTYPES
#include "../lib/glext.h"

However if I attempt to use any VBO related functions such as:

glBindBuffer
glBindBufferARB
glBufferData
glBufferDataARB

I get an undefined reference to them.

GClements
07-29-2013, 09:50 AM
However if I attempt to use any VBO related functions such as:

glBindBuffer
glBindBufferARB
glBufferData
glBufferDataARB

I get an undefined reference to them.

On Windows, opengl32.dll only exports the functions which are part of the OpenGL 1.1 API. For anything added after that, you have to use wglGetProcAddress() to obtain a pointer to the function (the OpenGL headers define the relevant pointer types), or use a library such as GLEW to do it for you.

Note that the function pointers can vary between contexts, so you shouldn't obtain a pointer with one context then use it with another context unless you know that the contexts are compatible. This is mainly an issue for heterogeneous multi-headed systems, where different screens may be using different OpenGL drivers. But in that situation you also run into the issue that the OpenGL version, supported extensions, implementation limits, etc will differ between screens.