I'm opening an OpenGL context using SDL in OSX 10.8.5.
I've already run some tutorials that draw lines/triangles etc. I then started trying the more modern tutorials at www.open.gl
I'm running into trouble with the OpenGL 3+ API. I already include gl3.h in my headers:
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <OpenGL/gl3.h>
I get a warning, which is expected since I think the sdl headers open gl.h
. That's okay, but the problem is that the but the compiler still reports that glGenVertexArrays
as undefined even though gl3.h is included, saying error: use of undeclared identifier 'glGenVertexArrays' glGenVertexArrays(1, &vao);
I believe I've seen this problem myself. I had to add an ifdef statement in one of my headers
#ifdef __APPLE__
#define glGenVertexArrays glGenVertexArraysAPPLE
#define glBindVertexArray glBindVertexArrayAPPLE
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
#endif
Also, you should be including either the SDL OpenGL header or the native system header. However, if you want to use the SDL OpenGL header, you should problaby do it like this
#define GL_GLEXT_PROTOTYPES 1
#include <SDL2/SDL_opengl.h>
or you'll only get the older OpenGL 1.x functions.
You don't have to include SDL_opengl.h
, just include :
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With