Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLES 3.0 including gl2ext.h

According to the Khronos OpenGL ES Registry, the extension header for GLES 3.0 is actually <GLES2/gl2ext.h>. gl3ext.h should be empty and provided only for legacy compatibility. Thus, if you want to include GLES 3.0 headers, you should do:

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

However, compiling with the Android NDK, it appears that that version of the gl2ext.h internally does #include <GLES2/gl2.h>, giving the following error *(I am compiling with 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);

This is because the prototype of glShaderSource changed from GLES 2.0 to GLES 3.0 core. Is this an error in the Android NDK version of the glext headers, or am I not doing something properly?

like image 973
MuertoExcobito Avatar asked Jun 23 '15 13:06

MuertoExcobito


1 Answers

Based on Michael's comments, I've found that this is fixed in API-21. However, if you still need to use API-18 or API-19, there is a work-around. You can simply:

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

When gl2ext.h includes gl2.h, the defined include guard will cause the contents of gl2.h to be skipped.

like image 179
MuertoExcobito Avatar answered Sep 22 '22 11:09

MuertoExcobito