繁体   English   中英

在OSX 10.8.5中包含OpenGL / gl3.h之后,使用未声明的标识符'glGenVertexArrays'错误

[英]use of undeclared identifier 'glGenVertexArrays' error even after including OpenGL/gl3.h in OSX 10.8.5

我在OSX 10.8.5中使用SDL打开OpenGL上下文。

我已经运行了一些绘制线条/三角形的教程等。然后我开始在www.open.gl上尝试更现代的教程

我遇到了OpenGL 3+ API的问题。 我已在头文件中包含gl3.h:

#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <OpenGL/gl3.h>

我得到一个警告,这是预期的,因为我认为sdl标题打开gl.h 这没关系,但问题是但是编译器仍然报告glGenVertexArrays为undefined,即使包含了glGenVertexArrays ,也就是说error: use of undeclared identifier 'glGenVertexArrays' glGenVertexArrays(1, &vao);

我相信我自己也见过这个问题。 我必须在我的一个标题中添加一个ifdef语句

#ifdef __APPLE__
#define glGenVertexArrays glGenVertexArraysAPPLE
#define glBindVertexArray glBindVertexArrayAPPLE
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
#endif

此外,您还应该包括 SDL OpenGL头或本机系统头。 但是,如果你想使用SDL OpenGL标题,你应该像这样做

#define GL_GLEXT_PROTOTYPES 1
#include <SDL2/SDL_opengl.h>

或者你只会获得较旧的OpenGL 1.x功能。

您不必包含SDL_opengl.h ,只需包括:

#ifdef __APPLE__
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#endif

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM