#!/bin/bash

# Print defined gl.* functions not in GL ES 3.0 or in
# (FIXME, none of these should be part of the ABI)
# GL_EXT_discard_framebuffer
# GL_EXT_map_buffer_range
# GL_EXT_multi_draw_arrays
# GL_NV_draw_buffers
# GL_NV_read_buffer
# GL_OES_EGL_image
# GL_OES_get_program_binary
# GL_OES_mapbuffer
# GL_OES_texture_3D
# GL_OES_vertex_array_object

FUNCS=$(nm -D --defined-only ${1-.libs/libGLESv2.so.2} | grep -o 'T gl.*' | cut -c 3- | while read func; do
( grep -q "^$func$" || echo $func )  <<EOF
glActiveTexture
glAttachShader
glBeginQuery
glBeginTransformFeedback
glBindAttribLocation
glBindBuffer
glBindBufferBase
glBindBufferRange
glBindFramebuffer
glBindRenderbuffer
glBindSampler
glBindTexture
glBindTransformFeedback
glBindVertexArray
glBindVertexArrayOES
glBlendColor
glBlendEquation
glBlendEquationSeparate
glBlendFunc
glBlendFuncSeparate
glBlitFramebuffer
glBufferData
glBufferSubData
glCheckFramebufferStatus
glClear
glClearBufferfi
glClearBufferfv
glClearBufferiv
glClearBufferuiv
glClearColor
glClearDepthf
glClearStencil
glClientWaitSync
glColorMask
glCompileShader
glCompressedTexImage2D
glCompressedTexImage3D
glCompressedTexImage3DOES
glCompressedTexSubImage2D
glCompressedTexSubImage3D
glCompressedTexSubImage3DOES
glCopyBufferSubData
glCopyTexImage2D
glCopyTexSubImage2D
glCopyTexSubImage3D
glCopyTexSubImage3DOES
glCreateProgram
glCreateShader
glCullFace
glDeleteBuffers
glDeleteFramebuffers
glDeleteProgram
glDeleteQueries
glDeleteRenderbuffers
glDeleteSamplers
glDeleteShader
glDeleteSync
glDeleteTextures
glDeleteTransformFeedbacks
glDeleteVertexArrays
glDeleteVertexArraysOES
glDepthFunc
glDepthMask
glDepthRangef
glDetachShader
glDisable
glDisableVertexAttribArray
glDiscardFramebufferEXT
glDrawArrays
glDrawArraysInstanced
glDrawBuffers
glDrawBuffersNV
glDrawElements
glDrawElementsInstanced
glDrawRangeElements
glEGLImageTargetRenderbufferStorageOES
glEGLImageTargetTexture2DOES
glEnable
glEnableVertexAttribArray
glEndQuery
glEndTransformFeedback
glFenceSync
glFinish
glFlush
glFlushMappedBufferRange
glFlushMappedBufferRangeEXT
glFramebufferRenderbuffer
glFramebufferTexture2D
glFramebufferTexture3DOES
glFramebufferTextureLayer
glFrontFace
glGenBuffers
glGenerateMipmap
glGenFramebuffers
glGenQueries
glGenRenderbuffers
glGenSamplers
glGenTextures
glGenTransformFeedbacks
glGenVertexArrays
glGenVertexArraysOES
glGetActiveAttrib
glGetActiveUniform
glGetActiveUniformBlockiv
glGetActiveUniformBlockName
glGetActiveUniformsiv
glGetAttachedShaders
glGetAttribLocation
glGetBooleanv
glGetBufferParameteri64v
glGetBufferParameteriv
glGetBufferPointerv
glGetBufferPointervOES
glGetError
glGetFloatv
glGetFragDataLocation
glGetFramebufferAttachmentParameteriv
glGetInteger64i_v
glGetInteger64v
glGetIntegeri_v
glGetIntegerv
glGetInternalformativ
glGetProgramBinary
glGetProgramBinaryOES
glGetProgramInfoLog
glGetProgramiv
glGetQueryiv
glGetQueryObjectuiv
glGetRenderbufferParameteriv
glGetSamplerParameterfv
glGetSamplerParameteriv
glGetShaderInfoLog
glGetShaderiv
glGetShaderPrecisionFormat
glGetShaderSource
glGetString
glGetStringi
glGetSynciv
glGetTexParameterfv
glGetTexParameteriv
glGetTransformFeedbackVarying
glGetUniformBlockIndex
glGetUniformfv
glGetUniformIndices
glGetUniformiv
glGetUniformLocation
glGetUniformuiv
glGetVertexAttribfv
glGetVertexAttribIiv
glGetVertexAttribIuiv
glGetVertexAttribiv
glGetVertexAttribPointerv
glHint
glInvalidateFramebuffer
glInvalidateSubFramebuffer
glIsBuffer
glIsEnabled
glIsFramebuffer
glIsProgram
glIsQuery
glIsRenderbuffer
glIsSampler
glIsShader
glIsSync
glIsTexture
glIsTransformFeedback
glIsVertexArray
glIsVertexArrayOES
glLineWidth
glLinkProgram
glMapBufferOES
glMapBufferRange
glMapBufferRangeEXT
glMultiDrawArraysEXT
glMultiDrawElementsEXT
glPauseTransformFeedback
glPixelStorei
glPolygonOffset
glProgramBinary
glProgramBinaryOES
glProgramParameteri
glReadBuffer
glReadBufferNV
glReadPixels
glReleaseShaderCompiler
glRenderbufferStorage
glRenderbufferStorageMultisample
glResumeTransformFeedback
glSampleCoverage
glSamplerParameterf
glSamplerParameterfv
glSamplerParameteri
glSamplerParameteriv
glScissor
glShaderBinary
glShaderSource
glStencilFunc
glStencilFuncSeparate
glStencilMask
glStencilMaskSeparate
glStencilOp
glStencilOpSeparate
glTexImage2D
glTexImage3D
glTexImage3DOES
glTexParameterf
glTexParameterfv
glTexParameteri
glTexParameteriv
glTexStorage2D
glTexStorage3D
glTexSubImage2D
glTexSubImage3D
glTexSubImage3DOES
glTransformFeedbackVaryings
glUniform1f
glUniform1fv
glUniform1i
glUniform1iv
glUniform1ui
glUniform1uiv
glUniform2f
glUniform2fv
glUniform2i
glUniform2iv
glUniform2ui
glUniform2uiv
glUniform3f
glUniform3fv
glUniform3i
glUniform3iv
glUniform3ui
glUniform3uiv
glUniform4f
glUniform4fv
glUniform4i
glUniform4iv
glUniform4ui
glUniform4uiv
glUniformBlockBinding
glUniformMatrix2fv
glUniformMatrix2x3fv
glUniformMatrix2x4fv
glUniformMatrix3fv
glUniformMatrix3x2fv
glUniformMatrix3x4fv
glUniformMatrix4fv
glUniformMatrix4x2fv
glUniformMatrix4x3fv
glUnmapBuffer
glUnmapBufferOES
glUseProgram
glValidateProgram
glVertexAttrib1f
glVertexAttrib1fv
glVertexAttrib2f
glVertexAttrib2fv
glVertexAttrib3f
glVertexAttrib3fv
glVertexAttrib4f
glVertexAttrib4fv
glVertexAttribDivisor
glVertexAttribI4i
glVertexAttribI4iv
glVertexAttribI4ui
glVertexAttribI4uiv
glVertexAttribIPointer
glVertexAttribPointer
glViewport
glWaitSync
EOF
done)

test ! -n "$FUNCS" || echo $FUNCS
test ! -n "$FUNCS"
