daj*_*daj 6 c++ opengl macos sdl
我在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>
Run Code Online (Sandbox Code Playgroud)
我得到一个警告,这是预期的,因为我认为sdl标头打开了gl.h.那没关系,但问题是但是编译器仍然报告glGenVertexArrays为未定义,即使包含gl3.h,说error: use of undeclared identifier 'glGenVertexArrays' glGenVertexArrays(1, &vao);
我相信我自己也见过这个问题.我必须在我的一个标题中添加一个ifdef语句
#ifdef __APPLE__
#define glGenVertexArrays glGenVertexArraysAPPLE
#define glBindVertexArray glBindVertexArrayAPPLE
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
#endif
Run Code Online (Sandbox Code Playgroud)
此外,您还应该包括任何的SDL OpenGL头或本机系统头.但是,如果你想使用SDL OpenGL标题,你应该像这样做
#define GL_GLEXT_PROTOTYPES 1
#include <SDL2/SDL_opengl.h>
Run Code Online (Sandbox Code Playgroud)
或者你只会获得较旧的OpenGL 1.x功能.
小智 5
您不必包含SDL_opengl.h,只需包含:
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#endif
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5887 次 |
| 最近记录: |