1#!/usr/bin/env bash
2##
3## Copyright (C) 2008-2019, Nigel Stewart <nigels[]users sourceforge net>
4## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
5## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
6##
7## This program is distributed under the terms and conditions of the GNU
8## General Public License Version 2 as published by the Free Software
9## Foundation or, at your option, any later version.
10##
11## Parameters:
12##
13##       $1: Extensions directory
14
15set -e
16
17# fix GL_NV_texture_compression_vtc
18    grep -v EXT $1/GL_NV_texture_compression_vtc > tmp
19    mv tmp $1/GL_NV_texture_compression_vtc
20
21# remove duplicates from GL_ARB_vertex_program and GL_ARB_fragment_program
22    tail -n +5 $1/GL_ARB_vertex_program > patterns
23    grep -v -F -f patterns $1/GL_ARB_fragment_program > tmp
24    mv tmp $1/GL_ARB_fragment_program
25
26# remove duplicates from GLX_EXT_visual_rating and GLX_EXT_visual_info
27    tail -n +5 $1/GLX_EXT_visual_info > patterns
28    grep -v -F -f patterns $1/GLX_EXT_visual_rating > tmp
29    mv tmp $1/GLX_EXT_visual_rating
30
31# GL_EXT_draw_buffers2 and GL_EXT_transform_feedback both define glGetBooleanIndexedvEXT but with different parameter names
32    grep -v glGetBooleanIndexedvEXT $1/GL_EXT_transform_feedback > tmp
33    mv tmp $1/GL_EXT_transform_feedback
34
35# GL_EXT_draw_buffers2 and GL_EXT_transform_feedback both define glGetIntegerIndexedvEXT but with different parameter names
36    grep -v glGetIntegerIndexedvEXT $1/GL_EXT_transform_feedback > tmp
37    mv tmp $1/GL_EXT_transform_feedback
38
39# remove duplicates from GL_NV_video_capture and GLX_NV_video_capture
40    grep -v glX $1/GL_NV_video_capture > tmp
41    mv tmp $1/GL_NV_video_capture
42
43# add missing functions to GL_NV_video_capture
44	cat >> $1/GL_NV_video_capture <<EOT
45    void glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint* params)
46    void glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat* params)
47    void glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble* params)
48    void glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint* params)
49    void glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat* params)
50    void glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble* params)
51EOT
52
53# fix WGL_NV_video_capture
54    cat >> $1/WGL_NV_video_capture <<EOT
55    DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
56EOT
57
58# fix GLX_NV_video_capture
59    cat >> $1/GLX_NV_video_capture <<EOT
60    typedef XID GLXVideoCaptureDeviceNV
61EOT
62
63# remove duplicates from GL_NV_present_video and GLX_NV_present_video
64    tail -n +5 $1/GLX_NV_present_video > patterns
65    grep -v -F -f patterns $1/GL_NV_present_video > tmp
66    mv tmp $1/GL_NV_present_video
67
68# fix WGL_NV_present_video
69    cat >> $1/WGL_NV_present_video <<EOT
70    DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
71EOT
72
73# fix WGL_NV_video_output
74    cat >> $1/WGL_NV_video_output <<EOT
75    DECLARE_HANDLE(HPVIDEODEV);
76EOT
77
78# fix GL_NV_occlusion_query and GL_HP_occlusion_test
79    grep -v '_HP' $1/GL_NV_occlusion_query > tmp
80    mv tmp $1/GL_NV_occlusion_query
81
82# add deprecated constants to GL_ATI_fragment_shader
83    cat >> $1/GL_ATI_fragment_shader <<EOT
84	GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
85	GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
86	GL_NUM_PASSES_ATI 0x8970
87	GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
88	GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
89	GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
90	GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
91	GL_COLOR_ALPHA_PAIRING_ATI 0x8975
92	GL_SWIZZLE_STRQ_ATI 0x897A
93	GL_SWIZZLE_STRQ_DQ_ATI 0x897B
94EOT
95
96# add deprecated constants to GL_NV_texture_shader
97    cat >> $1/GL_NV_texture_shader <<EOT
98	GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1
99	GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3
100	GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2
101EOT
102
103# fix WGL_ATI_pixel_format_float
104    cat >> $1/WGL_ATI_pixel_format_float <<EOT
105	GL_RGBA_FLOAT_MODE_ATI 0x8820
106	GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
107EOT
108
109# fix WGL_ARB_make_current_read
110    cat >> $1/WGL_ARB_make_current_read <<EOT
111	ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
112	ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
113EOT
114
115# fix WGL_EXT_make_current_read
116    cat >> $1/WGL_EXT_make_current_read <<EOT
117	ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
118EOT
119
120# add typedefs to GL_ARB_vertex_buffer_object; (from personal communication
121# with Marco Fabbricatore).
122#
123# Rationale.  The spec says:
124#
125#   "Both types are defined as signed integers large enough to contain
126#   any pointer value [...] The idea of making these types unsigned was
127#   considered, but was ultimately rejected ..."
128    cat >> $1/GL_ARB_vertex_buffer_object <<EOT
129	typedef ptrdiff_t GLsizeiptrARB
130	typedef ptrdiff_t GLintptrARB
131EOT
132
133# add typedefs to GLX_EXT_import_context
134    cat >> $1/GLX_EXT_import_context <<EOT
135	typedef XID GLXContextID
136EOT
137
138# add tokens to GLX_OML_swap_method
139    cat >> $1/GLX_OML_swap_method <<EOT
140	GLX_SWAP_EXCHANGE_OML 0x8061
141	GLX_SWAP_COPY_OML 0x8062
142	GLX_SWAP_UNDEFINED_OML 0x8063
143EOT
144
145# add typedefs to GLX_SGIX_fbconfig
146    cat >> $1/GLX_SGIX_fbconfig <<EOT
147	typedef XID GLXFBConfigIDSGIX
148	typedef struct __GLXFBConfigRec *GLXFBConfigSGIX
149EOT
150
151# Skip GLX_SGIX_dmbuffer and GLX_SGIX_video_source
152# unknown DMparams, DMbuffer, etc
153    rm -f $1/GLX_SGIX_dmbuffer
154    rm -f $1/GLX_SGIX_video_source
155
156# add typedefs to GLX_SGIX_pbuffer
157    cat >> $1/GLX_SGIX_pbuffer <<EOT
158    typedef XID GLXPbufferSGIX
159	typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX
160EOT
161
162# add typedef to GL_NV_half_float
163    cat >> $1/GL_NV_half_float <<EOT
164	typedef unsigned short GLhalf
165EOT
166
167# add handle to WGL_ARB_pbuffer
168    cat >> $1/WGL_ARB_pbuffer <<EOT
169	DECLARE_HANDLE(HPBUFFERARB);
170EOT
171
172# add handle to WGL_EXT_pbuffer
173    cat >> $1/WGL_EXT_pbuffer <<EOT
174	DECLARE_HANDLE(HPBUFFEREXT);
175EOT
176
177# get rid of GL_SUN_multi_draw_arrays
178    rm -f $1/GL_SUN_multi_draw_arrays
179
180# change variable names in GL_ARB_vertex_shader
181    perl -e 's/v0/x/g' -pi $1/GL_ARB_vertex_shader
182    perl -e 's/v1/y/g' -pi $1/GL_ARB_vertex_shader
183    perl -e 's/v2/z/g' -pi $1/GL_ARB_vertex_shader
184    perl -e 's/v3/w/g' -pi $1/GL_ARB_vertex_shader
185
186# remove triplicates in GL_ARB_shader_objects, GL_ARB_fragment_shader,
187# and GL_ARB_vertex_shader
188    tail -n +5 $1/GL_ARB_shader_objects > patterns
189    grep -v -F -f patterns $1/GL_ARB_fragment_shader > tmp
190    mv tmp $1/GL_ARB_fragment_shader
191    grep -v -F -f patterns $1/GL_ARB_vertex_shader > tmp
192    mv tmp $1/GL_ARB_vertex_shader
193
194# remove duplicates in GL_ARB_vertex_program and GL_ARB_vertex_shader
195    tail -n +5 $1/GL_ARB_vertex_program > patterns
196    grep -v -F -f patterns $1/GL_ARB_vertex_shader > tmp
197    mv tmp $1/GL_ARB_vertex_shader
198
199# remove triplicates in GL_ARB_fragment_program, GL_ARB_fragment_shader,
200# and GL_ARB_vertex_shader
201    tail -n +5 $1/GL_ARB_fragment_program > patterns
202    grep -v -F -f patterns $1/GL_ARB_fragment_shader > tmp
203    mv tmp $1/GL_ARB_fragment_shader
204    grep -v -F -f patterns $1/GL_ARB_vertex_shader > tmp
205    mv tmp $1/GL_ARB_vertex_shader
206
207# remove duplicates in GL_EXT_direct_state_access
208    grep -v "glGetBooleanIndexedvEXT" $1/GL_EXT_direct_state_access > tmp
209    mv tmp $1/GL_EXT_direct_state_access
210    grep -v "glGetIntegerIndexedvEXT" $1/GL_EXT_direct_state_access > tmp
211    mv tmp $1/GL_EXT_direct_state_access
212    grep -v "glDisableIndexedEXT" $1/GL_EXT_direct_state_access > tmp
213    mv tmp $1/GL_EXT_direct_state_access
214    grep -v "glEnableIndexedEXT" $1/GL_EXT_direct_state_access > tmp
215    mv tmp $1/GL_EXT_direct_state_access
216    grep -v "glIsEnabledIndexedEXT" $1/GL_EXT_direct_state_access > tmp
217    mv tmp $1/GL_EXT_direct_state_access
218
219# remove duplicates in GL_NV_explicit_multisample
220    grep -v "glGetBooleanIndexedvEXT" $1/GL_NV_explicit_multisample > tmp
221    mv tmp $1/GL_NV_explicit_multisample
222    grep -v "glGetIntegerIndexedvEXT" $1/GL_NV_explicit_multisample > tmp
223    mv tmp $1/GL_NV_explicit_multisample
224
225# fix bugs in GL_ARB_vertex_shader
226    grep -v "GL_FLOAT" $1/GL_ARB_vertex_shader > tmp
227    mv tmp $1/GL_ARB_vertex_shader
228    perl -e 's/handle /GLhandleARB /g' -pi $1/GL_ARB_vertex_shader
229
230# fix bugs in GL_ARB_shader_objects
231    grep -v "GL_FLOAT " $1/GL_ARB_shader_objects > tmp
232    mv tmp $1/GL_ARB_shader_objects
233    grep -v "GL_INT " $1/GL_ARB_shader_objects > tmp
234    mv tmp $1/GL_ARB_shader_objects
235
236# add typedefs to GL_ARB_shader_objects
237    cat >> $1/GL_ARB_shader_objects <<EOT
238	typedef char GLcharARB
239	typedef unsigned int GLhandleARB
240EOT
241
242# add missing functions to GL_ARB_transpose_matrix
243	cat >> $1/GL_ARB_transpose_matrix <<EOT
244	void glLoadTransposeMatrixfARB (GLfloat m[16])
245	void glLoadTransposeMatrixdARB (GLdouble m[16])
246	void glMultTransposeMatrixfARB (GLfloat m[16])
247	void glMultTransposeMatrixdARB (GLdouble m[16])
248EOT
249
250# add missing tokens to GL_EXT_framebuffer_multisample
251	cat >> $1/GL_EXT_framebuffer_multisample <<EOT
252	GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
253	GL_MAX_SAMPLES_EXT 0x8D57
254EOT
255
256# Filter out GL_NV_gpu_program_fp64 enums and functions
257    head -n4 $1/GL_NV_gpu_program_fp64 > tmp
258    mv tmp $1/GL_NV_gpu_program_fp64
259
260# Filter glGetUniformui64vNV from GL_NV_shader_buffer_load
261    grep -v "glGetUniformui64vNV" $1/GL_NV_shader_buffer_load > tmp
262    mv tmp $1/GL_NV_shader_buffer_load
263
264# Filter out profile enumerations from GLX_ARB_create_context
265    grep -v "_PROFILE_" $1/GLX_ARB_create_context > tmp
266    mv tmp $1/GLX_ARB_create_context
267
268# Filter only profile related enumerations for GLX_ARB_create_context_profile
269    head -n4 $1/GLX_ARB_create_context_profile > tmp
270    grep "_PROFILE_" $1/GLX_ARB_create_context_profile >> tmp
271    mv tmp $1/GLX_ARB_create_context_profile
272
273# Filter out profile enumerations from WGL_ARB_create_context
274    grep -v "_PROFILE_" $1/WGL_ARB_create_context > tmp
275    mv tmp $1/WGL_ARB_create_context
276
277# Filter only profile related enumerations for WGL_ARB_create_context_profile
278    head -n4 $1/WGL_ARB_create_context_profile > tmp
279    grep "_PROFILE_" $1/WGL_ARB_create_context_profile >> tmp
280    mv tmp $1/WGL_ARB_create_context_profile
281
282# add missing function to GLX_NV_copy_image
283	cat >> $1/GLX_NV_copy_image <<EOT
284  void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth)
285EOT
286
287# add missing function to WGL_NV_copy_image
288	cat >> $1/WGL_NV_copy_image <<EOT
289  BOOL wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth)
290EOT
291
292# Filter glProgramUniform from GL_EXT_separate_shader_objects
293    cat $1/GL_EXT_separate_shader_objects | grep -v "glProgramUniform" | grep -v "glProgramParameteri" > tmp
294    mv tmp $1/GL_EXT_separate_shader_objects
295
296# Filter out EXT functions from GL_ARB_viewport_array
297    grep -v "EXT" $1/GL_ARB_viewport_array > tmp
298    mv tmp $1/GL_ARB_viewport_array
299
300# Additional enumerations for GL_NV_vertex_buffer_unified_memory
301# These are mentioned in GL_ARB_draw_indirect.txt
302
303    cat >> $1/GL_NV_vertex_buffer_unified_memory <<EOT
304	GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40
305	GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41
306	GL_DRAW_INDIRECT_LENGTH_NV  0x8F42
307EOT
308
309# Filter glGetPointerv from GL_ARB_debug_output
310# It's part of OpenGL 1.1, after all
311
312    grep -v "glGetPointerv" $1/GL_ARB_debug_output > tmp
313    mv tmp $1/GL_ARB_debug_output
314
315# Filter glGetPointerv from GL_EXT_vertex_array
316# It's part of OpenGL 1.1, after all
317
318    grep -v "glGetPointerv" $1/GL_EXT_vertex_array > tmp
319    mv tmp $1/GL_EXT_vertex_array
320
321# add typedef to GL_AMD_debug_output
322# parse_spec.pl can't parse typedefs from New Types section, but ought to
323    cat >> $1/GL_AMD_debug_output <<EOT
324	typedef void (GLAPIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, void* userParam)
325EOT
326
327# add typedef to GL_ARB_debug_output
328# parse_spec.pl can't parse typedefs from New Types section, but ought to
329    cat >> $1/GL_ARB_debug_output <<EOT
330	typedef void (GLAPIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
331EOT
332
333# add typedef to GL_KHR_debug
334# parse_spec.pl can't parse typedefs from New Types section, but ought to
335    cat >> $1/GL_KHR_debug <<EOT
336	typedef void (GLAPIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
337EOT
338
339# Remove glGetPointerv from GL_KHR_debug
340    grep -v "glGetPointerv" $1/GL_KHR_debug > tmp
341    mv tmp $1/GL_KHR_debug
342
343# add typedefs to GL_ARB_cl_event
344# parse_spec.pl can't parse typedefs from New Types section, but ought to
345    cat >> $1/GL_ARB_cl_event <<EOT
346	typedef struct _cl_context *cl_context
347	typedef struct _cl_event *cl_event
348EOT
349
350# Filter out EXT functions from GL_ARB_gpu_shader_fp64
351    grep -v 'EXT ' $1/GL_ARB_gpu_shader_fp64 > tmp
352    mv tmp $1/GL_ARB_gpu_shader_fp64
353
354# add missing functions to GL_EXT_direct_state_access (GL_ARB_gpu_shader_fp64 related)
355	cat >> $1/GL_EXT_direct_state_access <<EOT
356    void glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x)
357    void glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y)
358    void glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z)
359    void glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
360    void glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value)
361    void glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value)
362    void glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value)
363    void glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value)
364    void glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
365    void glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
366    void glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
367    void glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
368    void glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
369    void glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
370    void glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
371    void glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
372    void glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value)
373EOT
374
375# add missing functions to GL_EXT_direct_state_access (GL_ARB_instanced_arrays related)
376# https://sourceforge.net/p/glew/bugs/242/
377    cat >> $1/GL_EXT_direct_state_access <<EOT
378    void glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor)
379EOT
380
381# Filter out GL_UNSIGNED_INT and GL_FLOAT from GL_AMD_performance_monitor
382    grep -v 'GL_UNSIGNED_INT ' $1/GL_AMD_performance_monitor > tmp
383    mv tmp $1/GL_AMD_performance_monitor
384    grep -v 'GL_FLOAT ' $1/GL_AMD_performance_monitor > tmp
385    mv tmp $1/GL_AMD_performance_monitor
386
387# Filter out GL_STORAGE_CACHED_APPLE and GL_STORAGE_SHARED_APPLE from GL_APPLE_texture_range
388    grep -v 'GL_STORAGE_CACHED_APPLE ' $1/GL_APPLE_texture_range > tmp
389    mv tmp $1/GL_APPLE_texture_range
390    grep -v 'GL_STORAGE_SHARED_APPLE ' $1/GL_APPLE_texture_range > tmp
391    mv tmp $1/GL_APPLE_texture_range
392
393# Filter out GL_RED from GL_ARB_texture_rg
394    grep -v 'GL_RED ' $1/GL_ARB_texture_rg > tmp
395    mv tmp $1/GL_ARB_texture_rg
396
397# Filter out _EXT enums from GL_ARB_texture_storage
398    grep -v '_EXT ' $1/GL_ARB_texture_storage > tmp
399    mv tmp $1/GL_ARB_texture_storage
400
401# Filter out TEXTURE_3D enums from GL_EXT_paletted_texture
402    grep -v 'TEXTURE_3D' $1/GL_EXT_paletted_texture > tmp
403    mv tmp $1/GL_EXT_paletted_texture
404
405# Filter out GL_VERSION_1_1 enums from GL_AMD_stencil_operation_extended
406    grep -v '0x150' $1/GL_AMD_stencil_operation_extended > tmp
407    mv tmp $1/GL_AMD_stencil_operation_extended
408
409# Filter out from GL_APPLE_ycbcr_422
410    grep -v 'GL_UNSIGNED_SHORT_8_8_APPLE' $1/GL_APPLE_ycbcr_422 > tmp
411    mv tmp $1/GL_APPLE_ycbcr_422
412    grep -v 'GL_UNSIGNED_SHORT_8_8_REV_APPLE' $1/GL_APPLE_ycbcr_422 > tmp
413    mv tmp $1/GL_APPLE_ycbcr_422
414
415# Filter out GL_FRAGMENT_DEPTH_EXT from GL_EXT_light_texture
416    grep -v 'GL_FRAGMENT_DEPTH_EXT' $1/GL_EXT_light_texture > tmp
417    mv tmp $1/GL_EXT_light_texture
418
419# Filter out GL_MULTISAMPLE_BIT_EXT from GL_SGIS_multisample
420    grep -v 'GL_MULTISAMPLE_BIT_EXT' $1/GL_SGIS_multisample > tmp
421    mv tmp $1/GL_SGIS_multisample
422
423# Filter out GL_COMPRESSED_RGB_S3TC_DXT1_EXT from GL_EXT_texture_compression_dxt1
424    grep -v 'GL_COMPRESSED_RGB_S3TC_DXT1_EXT' $1/GL_EXT_texture_compression_dxt1 > tmp
425    mv tmp $1/GL_EXT_texture_compression_dxt1
426
427# Filter out GL_COMPRESSED_RGBA_S3TC_DXT1_EXT from GL_EXT_texture_compression_dxt1
428    grep -v 'GL_COMPRESSED_RGBA_S3TC_DXT1_EXT' $1/GL_EXT_texture_compression_dxt1 > tmp
429    mv tmp $1/GL_EXT_texture_compression_dxt1
430
431# Append GLfixed to GL_ARB_ES2_compatibility
432# Probably ought to be explicitly mentioned in the spec language
433
434    cat >> $1/GL_ARB_ES2_compatibility <<EOT
435	typedef int GLfixed
436EOT
437
438# Append GLclampx to GL_REGAL_ES1_0_compatibility
439# Probably ought to be explicitly mentioned in the spec language
440
441    cat >> $1/GL_REGAL_ES1_0_compatibility <<EOT
442	typedef int GLclampx
443EOT
444
445# Append GLLOGPROCREGAL to GL_REGAL_log
446# Probably ought to be explicitly mentioned in the spec language
447
448    cat >> $1/GL_REGAL_log <<EOT
449	typedef void (APIENTRY *LOGPROCREGAL)(GLenum stream, GLsizei length, const GLchar *message, void *context)
450EOT
451
452# Fixup LOGPROCREGAL -> GLLOGPROCREGAL
453    perl -e 's/LOGPROCREGAL/GLLOGPROCREGAL/g' -pi $1/GL_REGAL_log
454
455# Filter out GL_BYTE from GL_OES_byte_coordinates
456    grep -v 'GL_BYTE' $1/GL_OES_byte_coordinates > tmp
457    mv tmp $1/GL_OES_byte_coordinates
458
459# Filter out fp64 (not widely supported) from GL_EXT_direct_state_access
460    egrep -v 'glProgramUniform.*[1234]d[v]?EXT' $1/GL_EXT_direct_state_access > tmp
461    mv tmp $1/GL_EXT_direct_state_access
462
463# Filter out all enums from GL_ANGLE_depth_texture
464    grep -v '0x' $1/GL_ANGLE_depth_texture > tmp
465    mv tmp $1/GL_ANGLE_depth_texture
466
467# Filter out GL_NONE enum from GL_ANGLE_depth_texture
468    grep -v 'GL_NONE' $1/GL_ANGLE_texture_usage > tmp
469    mv tmp $1/GL_ANGLE_texture_usage
470
471# Fixup REGAL and ANGLE urls
472
473    for i in $1/GL_REGAL_*; do perl -e 's#http://www.opengl.org/registry/specs/REGAL/.*#https://github.com/p3/regal/tree/master/doc/extensions#g' -pi $i; done
474    for i in $1/GL_ANGLE_*; do perl -e 's#http://www.opengl.org/registry/specs/ANGLE/.*#https://code.google.com/p/angleproject/source/browse/\#git%2Fextensions#g' -pi $i; done
475
476# Filter out GL_NV_blend_equation_advanced_coherent enums and functions
477    head -n4 $1/GL_NV_blend_equation_advanced_coherent > tmp
478    mv tmp $1/GL_NV_blend_equation_advanced_coherent
479
480# Filter out GL_AMD_gpu_shader_int64 enums and functions
481    head -n4 $1/GL_AMD_gpu_shader_int64 > tmp
482    mv tmp $1/GL_AMD_gpu_shader_int64
483
484# Filter out GL_NO_ERROR enum from GL_KHR_robustness
485    grep -v 'GL_NO_ERROR' $1/GL_KHR_robustness > tmp
486    mv tmp $1/GL_KHR_robustness
487
488# Filter out all enums from GL_KHR_blend_equation_advanced_coherent
489    grep -v '0x' $1/GL_KHR_blend_equation_advanced_coherent > tmp
490    mv tmp $1/GL_KHR_blend_equation_advanced_coherent
491
492# Filter out glBlendBarrierKHR enum from GL_KHR_blend_equation_advanced_coherent
493    grep -v 'glBlendBarrierKHR' $1/GL_KHR_blend_equation_advanced_coherent > tmp
494    mv tmp $1/GL_KHR_blend_equation_advanced_coherent
495
496# Filter out GL_NONE enum from GL_KHR_context_flush_control
497    grep -v 'GL_NONE' $1/GL_KHR_context_flush_control > tmp
498    mv tmp $1/GL_KHR_context_flush_control
499
500# Filter out CoverageModulation from NV_framebuffer_mixed_samples
501# Superset of EXT_raster_multisample
502
503    grep -v "CoverageModulation" $1/GL_NV_framebuffer_mixed_samples > tmp
504    mv tmp $1/GL_NV_framebuffer_mixed_samples
505
506# Filter out glRasterSamplesEXT from NV_framebuffer_mixed_samples
507# Superset of EXT_raster_multisample
508
509    grep -v "RasterSamplesEXT" $1/GL_NV_framebuffer_mixed_samples > tmp
510    mv tmp $1/GL_NV_framebuffer_mixed_samples
511
512# Filter out glNamedBufferStorageEXT from GL_ARB_buffer_storage
513
514    grep -v "glNamedBufferStorageEXT" $1/GL_ARB_buffer_storage > tmp
515    mv tmp $1/GL_ARB_buffer_storage
516
517# Filter out glFramebufferTextureEXT from GL_EXT_geometry_point_size
518# and GL_EXT_geometry_shader
519
520    grep -v "glFramebufferTextureEXT" $1/GL_EXT_geometry_point_size > tmp
521    mv tmp $1/GL_EXT_geometry_point_size
522
523    grep -v "glFramebufferTextureEXT" $1/GL_EXT_geometry_shader > tmp
524    mv tmp $1/GL_EXT_geometry_shader
525
526# Filter out glBindFragDataLocationEXT from GL_EXT_blend_func_extended
527
528    grep -v "glBindFragDataLocationEXT" $1/GL_EXT_blend_func_extended > tmp
529    mv tmp $1/GL_EXT_blend_func_extended
530
531# Filter out glDrawArraysInstancedEXT and glDrawElementsInstancedEXT from GL_EXT_blend_func_extended
532
533    grep -v "glDrawArraysInstancedEXT" $1/GL_EXT_instanced_arrays > tmp
534    mv tmp $1/GL_EXT_instanced_arrays
535
536    grep -v "glDrawElementsInstancedEXT" $1/GL_EXT_instanced_arrays > tmp
537    mv tmp $1/GL_EXT_instanced_arrays
538
539# Filter out glRenderbufferStorageMultisampleEXT from GL_EXT_multisampled_render_to_texture
540
541    grep -v "glRenderbufferStorageMultisampleEXT" $1/GL_EXT_multisampled_render_to_texture > tmp
542    mv tmp $1/GL_EXT_multisampled_render_to_texture
543
544# Filter out glTexturePageCommitmentEXT from GL_ARB_sparse_texture
545
546    grep -v "glTexturePageCommitmentEXT" $1/GL_ARB_sparse_texture > tmp
547    mv tmp $1/GL_ARB_sparse_texture
548
549# Filter out TextureStorage* from GL_ARB_texture_storage
550
551    grep -v "TextureStorage" $1/GL_ARB_texture_storage > tmp
552    mv tmp $1/GL_ARB_texture_storage
553
554# Filter out functions from GL_EXT_occlusion_query_boolean
555
556    grep -v "(" $1/GL_EXT_occlusion_query_boolean > tmp
557    mv tmp $1/GL_EXT_occlusion_query_boolean
558
559# Filter out duplicate enums from GL_EXT_protected_textures
560
561    cat $1/GL_EXT_protected_textures | grep -v GL_TRUE | grep -v GL_FALSE > tmp
562    mv tmp $1/GL_EXT_protected_textures
563
564# Filter out duplicate enums from GL_EXT_robustness
565
566    cat $1/GL_EXT_robustness | grep -v GL_NO_ERROR > tmp
567    mv tmp $1/GL_EXT_robustness
568
569# Filter  GL_EXT_shader_framebuffer_fetch_non_coherent
570
571    grep -v "FramebufferFetchBarrierEXT" $1/GL_EXT_shader_framebuffer_fetch_non_coherent > tmp
572    mv tmp $1/GL_EXT_shader_framebuffer_fetch_non_coherent
573
574# Filter GL_EXT_tessellation_shader
575
576    grep -v "PatchParameteriEXT" $1/GL_EXT_tessellation_shader > tmp
577    mv tmp $1/GL_EXT_tessellation_shader
578
579# Filter GL_EXT_texture_buffer
580
581    grep -v "TexBuffer" $1/GL_EXT_texture_buffer > tmp
582    mv tmp $1/GL_EXT_texture_buffer
583
584# Filter GL_EXT_texture_border_clamp
585
586    grep -v "TexParameter" $1/GL_EXT_texture_border_clamp > tmp
587    mv tmp $1/GL_EXT_texture_border_clamp
588
589# Filter GL_EXT_disjoint_timer_query
590
591    cat $1/GL_EXT_disjoint_timer_query | grep -v GetQueryObjecti64v | grep -v GetQueryObjectui64v > tmp
592    mv tmp $1/GL_EXT_disjoint_timer_query
593
594# Filter GL_NV_read_buffer_front
595
596    grep -v "ReadBufferNV" $1/GL_NV_read_buffer_front > tmp
597    mv tmp $1/GL_NV_read_buffer_front
598
599# Append GLVULKANPROCNV to GL_NV_draw_vulkan_image
600# Probably ought to be explicitly mentioned in the spec language
601
602    cat >> $1/GL_NV_draw_vulkan_image <<EOT
603    typedef void (APIENTRY *GLVULKANPROCNV)(void)
604EOT
605
606# GLU extensions are not relevant here
607    rm -f $1/GL_GLU_*
608
609# Not complete
610    rm -f $1/GL_SGIX_color_type
611
612# clean up
613    rm -f patterns $1/*.bak
614