GLES 3.0包括gl2ext.h

时间:2015-06-23 13:16:19

标签: android c++ opengl-es android-ndk

根据Khronos OpenGL ES Registry,GLES 3.0的扩展标头实际上是<GLES2/gl2ext.h>gl3ext.h应为空,仅提供旧版兼容性。因此,如果要包含GLES 3.0标头,则应执行以下操作:

#include <GLES3/gl3.h>
#include <GLES2/gl2ext.h>

但是,使用Android NDK进行编译时,gl2ext.h内部版本似乎#include <GLES2/gl2.h>,出现以下错误*(我正在使用API​​-19进行编译):

C:\android-ndk-r10e\platforms\android-19\arch-arm\usr\include\GLES2\gl2ext.h(6): includes this header: 
C:\android-ndk-r10e\platforms\android-19\arch-arm\usr\include\GLES2\gl2.h(572,37): error : conflicting types for 'glShaderSource'
GL_APICALL void         GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
                                    ^
C:\android-ndk-r10e\platforms\android-19\arch-arm\usr\include\GLES3\gl3.h(905,39):  note: previous declaration is here
GL_APICALL void           GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);

这是因为glShaderSource的原型从GLES 2.0变为GLES 3.0核心。这是glext标头的Android NDK版本中的错误,还是我没有做正确的事情?

1 个答案:

答案 0 :(得分:8)

根据迈克尔的评论,我发现这在API-21中得到了修复。但是,如果您仍然需要使用API​​-18或API-19,则需要解决此问题。你可以简单地说:

#define __gl2_h_
#include <GLES2/gl2ext.h>

当gl2ext.h包含gl2.h时,定义的include guard将导致gl2.h的内容被跳过。