@gjsify/webgl 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +14 -0
  2. package/lib/cjs/@types/glsl-tokenizer/index.d.js +0 -0
  3. package/lib/cjs/extensions/ext-blend-minmax.js +37 -0
  4. package/lib/cjs/extensions/ext-texture-filter-anisotropic.js +37 -0
  5. package/lib/cjs/extensions/oes-element-index-unit.js +33 -0
  6. package/lib/cjs/extensions/oes-standard-derivatives.js +36 -0
  7. package/lib/cjs/extensions/oes-texture-float-linear.js +33 -0
  8. package/lib/cjs/extensions/oes-texture-float.js +33 -0
  9. package/lib/cjs/extensions/stackgl-destroy-context.js +31 -0
  10. package/lib/cjs/extensions/stackgl-resize-drawing-buffer.js +31 -0
  11. package/lib/cjs/html-canvas-element.js +89 -0
  12. package/lib/cjs/index.js +34 -0
  13. package/lib/cjs/index.spec.js +175 -0
  14. package/lib/cjs/linkable.js +69 -0
  15. package/lib/cjs/test.js +25 -0
  16. package/lib/cjs/types/constructor.js +15 -0
  17. package/lib/cjs/types/extension.js +15 -0
  18. package/lib/cjs/types/index.js +21 -0
  19. package/lib/cjs/types/typed-array.js +15 -0
  20. package/lib/cjs/types/webgl-constants.js +15 -0
  21. package/lib/cjs/types/webgl-context-attribute-options.js +15 -0
  22. package/lib/cjs/utils.js +241 -0
  23. package/lib/cjs/webgl-active-info.js +29 -0
  24. package/lib/cjs/webgl-buffer.js +37 -0
  25. package/lib/cjs/webgl-context-attributes.js +43 -0
  26. package/lib/cjs/webgl-drawing-buffer-wrapper.js +29 -0
  27. package/lib/cjs/webgl-framebuffer.js +128 -0
  28. package/lib/cjs/webgl-program.js +45 -0
  29. package/lib/cjs/webgl-renderbuffer.js +43 -0
  30. package/lib/cjs/webgl-rendering-context.js +3355 -0
  31. package/lib/cjs/webgl-shader-precision-format.js +30 -0
  32. package/lib/cjs/webgl-shader.js +42 -0
  33. package/lib/cjs/webgl-texture-unit.js +31 -0
  34. package/lib/cjs/webgl-texture.js +41 -0
  35. package/lib/cjs/webgl-uniform-location.js +34 -0
  36. package/lib/cjs/webgl-vertex-attribute.js +166 -0
  37. package/lib/esm/@types/glsl-tokenizer/index.d.js +0 -0
  38. package/lib/esm/extensions/ext-blend-minmax.js +18 -0
  39. package/lib/esm/extensions/ext-texture-filter-anisotropic.js +18 -0
  40. package/lib/esm/extensions/oes-element-index-unit.js +14 -0
  41. package/lib/esm/extensions/oes-standard-derivatives.js +17 -0
  42. package/lib/esm/extensions/oes-texture-float-linear.js +14 -0
  43. package/lib/esm/extensions/oes-texture-float.js +14 -0
  44. package/lib/esm/extensions/stackgl-destroy-context.js +12 -0
  45. package/lib/esm/extensions/stackgl-resize-drawing-buffer.js +12 -0
  46. package/lib/esm/html-canvas-element.js +70 -0
  47. package/lib/esm/index.js +18 -0
  48. package/lib/esm/index.spec.js +146 -0
  49. package/lib/esm/linkable.js +50 -0
  50. package/lib/esm/test.js +3 -0
  51. package/lib/esm/types/constructor.js +0 -0
  52. package/lib/esm/types/extension.js +0 -0
  53. package/lib/esm/types/index.js +5 -0
  54. package/lib/esm/types/typed-array.js +0 -0
  55. package/lib/esm/types/webgl-constants.js +0 -0
  56. package/lib/esm/types/webgl-context-attribute-options.js +0 -0
  57. package/lib/esm/utils.js +212 -0
  58. package/lib/esm/webgl-active-info.js +10 -0
  59. package/lib/esm/webgl-buffer.js +18 -0
  60. package/lib/esm/webgl-context-attributes.js +24 -0
  61. package/lib/esm/webgl-drawing-buffer-wrapper.js +10 -0
  62. package/lib/esm/webgl-framebuffer.js +109 -0
  63. package/lib/esm/webgl-program.js +26 -0
  64. package/lib/esm/webgl-renderbuffer.js +24 -0
  65. package/lib/esm/webgl-rendering-context.js +3343 -0
  66. package/lib/esm/webgl-shader-precision-format.js +11 -0
  67. package/lib/esm/webgl-shader.js +23 -0
  68. package/lib/esm/webgl-texture-unit.js +12 -0
  69. package/lib/esm/webgl-texture.js +22 -0
  70. package/lib/esm/webgl-uniform-location.js +15 -0
  71. package/lib/esm/webgl-vertex-attribute.js +147 -0
  72. package/lib/types/extensions/ext-blend-minmax.d.ts +7 -0
  73. package/lib/types/extensions/ext-texture-filter-anisotropic.d.ts +7 -0
  74. package/lib/types/extensions/oes-element-index-unit.d.ts +4 -0
  75. package/lib/types/extensions/oes-standard-derivatives.d.ts +6 -0
  76. package/lib/types/extensions/oes-texture-float-linear.d.ts +4 -0
  77. package/lib/types/extensions/oes-texture-float.d.ts +4 -0
  78. package/lib/types/extensions/stackgl-destroy-context.d.ts +6 -0
  79. package/lib/types/extensions/stackgl-resize-drawing-buffer.d.ts +6 -0
  80. package/lib/types/html-canvas-element.d.ts +38 -0
  81. package/lib/types/index.d.ts +18 -0
  82. package/lib/types/linkable.d.ts +13 -0
  83. package/lib/types/types/constructor.d.ts +3 -0
  84. package/lib/types/types/extension.d.ts +2 -0
  85. package/lib/types/types/index.d.ts +5 -0
  86. package/lib/types/types/typed-array.d.ts +1 -0
  87. package/lib/types/types/webgl-constants.d.ts +299 -0
  88. package/lib/types/types/webgl-context-attribute-options.d.ts +12 -0
  89. package/lib/types/utils.d.ts +32 -0
  90. package/lib/types/webgl-active-info.d.ts +7 -0
  91. package/lib/types/webgl-buffer.d.ts +10 -0
  92. package/lib/types/webgl-context-attributes.d.ts +14 -0
  93. package/lib/types/webgl-drawing-buffer-wrapper.d.ts +6 -0
  94. package/lib/types/webgl-framebuffer.d.ts +17 -0
  95. package/lib/types/webgl-program.d.ts +14 -0
  96. package/lib/types/webgl-renderbuffer.d.ts +12 -0
  97. package/lib/types/webgl-rendering-context.d.ts +260 -0
  98. package/lib/types/webgl-shader-precision-format.d.ts +7 -0
  99. package/lib/types/webgl-shader.d.ts +12 -0
  100. package/lib/types/webgl-texture-unit.d.ts +10 -0
  101. package/lib/types/webgl-texture.d.ts +14 -0
  102. package/lib/types/webgl-uniform-location.d.ts +18 -0
  103. package/lib/types/webgl-vertex-attribute.d.ts +38 -0
  104. package/meson.build +39 -0
  105. package/package.json +55 -0
  106. package/src/test/app.vala +60 -0
  107. package/src/ts/@types/glsl-tokenizer/index.d.ts +18 -0
  108. package/src/ts/extensions/angle-instanced-arrays.ts.off +232 -0
  109. package/src/ts/extensions/ext-blend-minmax.ts +18 -0
  110. package/src/ts/extensions/ext-texture-filter-anisotropic.ts +18 -0
  111. package/src/ts/extensions/oes-element-index-unit.ts +14 -0
  112. package/src/ts/extensions/oes-standard-derivatives.ts +17 -0
  113. package/src/ts/extensions/oes-texture-float-linear.ts +14 -0
  114. package/src/ts/extensions/oes-texture-float.ts +14 -0
  115. package/src/ts/extensions/oes-vertex-array-object.ts.off +128 -0
  116. package/src/ts/extensions/stackgl-destroy-context.ts +12 -0
  117. package/src/ts/extensions/stackgl-resize-drawing-buffer.ts +14 -0
  118. package/src/ts/extensions/webgl-draw-buffers.ts.off +107 -0
  119. package/src/ts/html-canvas-element.ts +98 -0
  120. package/src/ts/index.spec.ts +186 -0
  121. package/src/ts/index.ts +21 -0
  122. package/src/ts/linkable.ts +55 -0
  123. package/src/ts/test.ts +6 -0
  124. package/src/ts/types/constructor.ts +3 -0
  125. package/src/ts/types/extension.ts +3 -0
  126. package/src/ts/types/index.ts +26 -0
  127. package/src/ts/types/typed-array.ts +1 -0
  128. package/src/ts/types/webgl-constants.ts +300 -0
  129. package/src/ts/types/webgl-context-attribute-options.ts +12 -0
  130. package/src/ts/utils.ts +266 -0
  131. package/src/ts/webgl-active-info.ts +13 -0
  132. package/src/ts/webgl-buffer.ts +21 -0
  133. package/src/ts/webgl-context-attributes.ts +24 -0
  134. package/src/ts/webgl-drawing-buffer-wrapper.ts +10 -0
  135. package/src/ts/webgl-framebuffer.ts +133 -0
  136. package/src/ts/webgl-program.ts +30 -0
  137. package/src/ts/webgl-renderbuffer.ts +28 -0
  138. package/src/ts/webgl-rendering-context.ts +4050 -0
  139. package/src/ts/webgl-shader-precision-format.ts +12 -0
  140. package/src/ts/webgl-shader.ts +29 -0
  141. package/src/ts/webgl-texture-unit.ts +16 -0
  142. package/src/ts/webgl-texture.ts +27 -0
  143. package/src/ts/webgl-uniform-location.ts +18 -0
  144. package/src/ts/webgl-vertex-attribute.ts +169 -0
  145. package/src/vala/handle-types.vala +23 -0
  146. package/src/vala/webgl-rendering-context-base.vala +1265 -0
  147. package/src/vala/webgl-rendering-context.vala +265 -0
  148. package/src/vapi/epoxy.vapi +14558 -0
  149. package/src/vapi/glesv2.vapi +670 -0
  150. package/test.gjs.js +39972 -0
  151. package/test.gjs.js.meta.json +1 -0
  152. package/tmp/.tsbuildinfo +1 -0
  153. package/tsconfig.json +38 -0
  154. package/tsconfig.types.json +7 -0
@@ -0,0 +1,1265 @@
1
+
2
+ namespace Gwebgl {
3
+
4
+ using GL;
5
+
6
+ public errordomain TypeError {
7
+ CODE
8
+ }
9
+
10
+ // WebGL constants
11
+ // See https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#pixel_storage_modes
12
+
13
+ // Pixel storage modes
14
+ public const int UNPACK_FLIP_Y_WEBGL = 0x9240;
15
+ public const int UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241;
16
+ public const int UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243;
17
+
18
+ // WebGL constants which are not part of OpenGL ES
19
+ public const int CONTEXT_LOST_WEBGL = 0x9242;
20
+ public const int BROWSER_DEFAULT_WEBGL = 0x9244;
21
+
22
+ // ANGLE_instanced_arrays
23
+
24
+ /** Describes the frequency divisor used for instanced rendering. */
25
+ public const int VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE;
26
+
27
+ // WEBGL_debug_renderer_info
28
+
29
+ /** Passed to `getParameter` to get the vendor string of the graphics driver. */
30
+ public const int UNMASKED_VENDOR_WEBGL = 0x9245;
31
+ /** Passed to `getParameter` to get the renderer string of the graphics driver. */
32
+ public const int UNMASKED_RENDERER_WEBGL = 0x9246;
33
+
34
+ // WebGL Extensions
35
+
36
+ /** Maximum number of draw buffers */
37
+ public const int MAX_DRAW_BUFFERS_WEBGL = 0x8824;
38
+ /** Returns the maximum available anisotropy. */
39
+ public const int MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
40
+ /** Passed to texParameter to set the desired maximum anisotropy for a texture. */
41
+ public const int TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
42
+
43
+ public const int STENCIL_INDEX = 0x1901;
44
+ public const int VERSION = 0x1F02;
45
+ public const int IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A;
46
+ public const int IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
47
+
48
+ public class WebGLRenderingContextBase: Object {
49
+ HashTable<string, int> webgl_constants = new HashTable<string, int> (str_hash, str_equal);
50
+
51
+ protected bool unpack_flip_y = false;
52
+ protected bool unpack_premultiply_alpha = false;
53
+ protected int unpack_colorspace_conversion = 0x9244;
54
+ protected int unpack_alignment = 4;
55
+ protected int lastError = GL_NO_ERROR;
56
+
57
+
58
+ public WebGLRenderingContextBase() {
59
+
60
+ }
61
+
62
+ /* Constructor */
63
+ construct {
64
+
65
+ this.webgl_constants.insert("UNPACK_FLIP_Y_WEBGL", UNPACK_FLIP_Y_WEBGL);
66
+ this.webgl_constants.insert("UNPACK_PREMULTIPLY_ALPHA_WEBGL", UNPACK_PREMULTIPLY_ALPHA_WEBGL);
67
+ this.webgl_constants.insert("UNPACK_COLORSPACE_CONVERSION_WEBGL", UNPACK_COLORSPACE_CONVERSION_WEBGL);
68
+ this.webgl_constants.insert("CONTEXT_LOST_WEBGL", CONTEXT_LOST_WEBGL);
69
+ this.webgl_constants.insert("BROWSER_DEFAULT_WEBGL", BROWSER_DEFAULT_WEBGL);
70
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE", VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
71
+ this.webgl_constants.insert("UNMASKED_VENDOR_WEBGL", UNMASKED_VENDOR_WEBGL);
72
+ this.webgl_constants.insert("UNMASKED_RENDERER_WEBGL", UNMASKED_RENDERER_WEBGL);
73
+ this.webgl_constants.insert("MAX_DRAW_BUFFERS_WEBGL", MAX_DRAW_BUFFERS_WEBGL);
74
+ this.webgl_constants.insert("MAX_TEXTURE_MAX_ANISOTROPY_EXT", MAX_TEXTURE_MAX_ANISOTROPY_EXT);
75
+ this.webgl_constants.insert("TEXTURE_MAX_ANISOTROPY_EXT", TEXTURE_MAX_ANISOTROPY_EXT);
76
+ this.webgl_constants.insert("STENCIL_INDEX", STENCIL_INDEX);
77
+ this.webgl_constants.insert("VERSION", VERSION);
78
+ this.webgl_constants.insert("IMPLEMENTATION_COLOR_READ_TYPE", IMPLEMENTATION_COLOR_READ_TYPE);
79
+ this.webgl_constants.insert("IMPLEMENTATION_COLOR_READ_FORMAT", IMPLEMENTATION_COLOR_READ_FORMAT);
80
+ this.webgl_constants.insert("DEPTH_STENCIL", GL_DEPTH_STENCIL_OES);
81
+ this.webgl_constants.insert("DEPTH_STENCIL_ATTACHMENT", GL_DEPTH_STENCIL_ATTACHMENT);
82
+
83
+
84
+ // Also part of OpenGL ES
85
+ this.webgl_constants.insert("ACTIVE_ATTRIBUTES", GL_ACTIVE_ATTRIBUTES);
86
+ this.webgl_constants.insert("ACTIVE_TEXTURE", GL_ACTIVE_TEXTURE);
87
+ this.webgl_constants.insert("ACTIVE_UNIFORMS", GL_ACTIVE_UNIFORMS);
88
+ this.webgl_constants.insert("ALIASED_LINE_WIDTH_RANGE", GL_ALIASED_LINE_WIDTH_RANGE);
89
+ this.webgl_constants.insert("ALIASED_POINT_SIZE_RANGE", GL_ALIASED_POINT_SIZE_RANGE);
90
+ this.webgl_constants.insert("ALPHA", GL_ALPHA);
91
+ this.webgl_constants.insert("ALPHA_BITS", GL_ALPHA_BITS);
92
+ this.webgl_constants.insert("ALWAYS", GL_ALWAYS);
93
+ this.webgl_constants.insert("ARRAY_BUFFER", GL_ARRAY_BUFFER);
94
+ this.webgl_constants.insert("ARRAY_BUFFER_BINDING", GL_ARRAY_BUFFER_BINDING);
95
+ this.webgl_constants.insert("ATTACHED_SHADERS", GL_ATTACHED_SHADERS);
96
+ this.webgl_constants.insert("BACK", GL_BACK);
97
+ this.webgl_constants.insert("BLEND", GL_BLEND);
98
+ this.webgl_constants.insert("BLEND_COLOR", GL_BLEND_COLOR);
99
+ this.webgl_constants.insert("BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA);
100
+ this.webgl_constants.insert("BLEND_DST_RGB", GL_BLEND_DST_RGB);
101
+ this.webgl_constants.insert("BLEND_EQUATION", GL_BLEND_EQUATION);
102
+ this.webgl_constants.insert("BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA);
103
+ this.webgl_constants.insert("BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB);
104
+ this.webgl_constants.insert("BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA);
105
+ this.webgl_constants.insert("BLEND_SRC_RGB", GL_BLEND_SRC_RGB);
106
+ this.webgl_constants.insert("BLUE_BITS", GL_BLUE_BITS);
107
+ this.webgl_constants.insert("BOOL", GL_BOOL);
108
+ this.webgl_constants.insert("BOOL_VEC2", GL_BOOL_VEC2);
109
+ this.webgl_constants.insert("BOOL_VEC3", GL_BOOL_VEC3);
110
+ this.webgl_constants.insert("BOOL_VEC4", GL_BOOL_VEC4);
111
+ this.webgl_constants.insert("BUFFER_SIZE", GL_BUFFER_SIZE);
112
+ this.webgl_constants.insert("BUFFER_USAGE", GL_BUFFER_USAGE);
113
+ this.webgl_constants.insert("BYTE", GL_BYTE);
114
+ this.webgl_constants.insert("CCW", GL_CCW);
115
+ this.webgl_constants.insert("CLAMP_TO_EDGE", GL_CLAMP_TO_EDGE);
116
+ this.webgl_constants.insert("COLOR_ATTACHMENT0", GL_COLOR_ATTACHMENT0);
117
+ this.webgl_constants.insert("COLOR_BUFFER_BIT", GL_COLOR_BUFFER_BIT);
118
+ this.webgl_constants.insert("COLOR_CLEAR_VALUE", GL_COLOR_CLEAR_VALUE);
119
+ this.webgl_constants.insert("COLOR_WRITEMASK", GL_COLOR_WRITEMASK);
120
+ this.webgl_constants.insert("COMPILE_STATUS", GL_COMPILE_STATUS);
121
+ this.webgl_constants.insert("COMPRESSED_TEXTURE_FORMATS", GL_COMPRESSED_TEXTURE_FORMATS);
122
+ this.webgl_constants.insert("CONSTANT_ALPHA", GL_CONSTANT_ALPHA);
123
+ this.webgl_constants.insert("CONSTANT_COLOR", GL_CONSTANT_COLOR);
124
+ this.webgl_constants.insert("CULL_FACE", GL_CULL_FACE);
125
+ this.webgl_constants.insert("CULL_FACE_MODE", GL_CULL_FACE_MODE);
126
+ this.webgl_constants.insert("CURRENT_PROGRAM", GL_CURRENT_PROGRAM);
127
+ this.webgl_constants.insert("CURRENT_VERTEX_ATTRIB", GL_CURRENT_VERTEX_ATTRIB);
128
+ this.webgl_constants.insert("CW", GL_CW);
129
+ this.webgl_constants.insert("DECR", GL_DECR);
130
+ this.webgl_constants.insert("DECR_WRAP", GL_DECR_WRAP);
131
+ this.webgl_constants.insert("DELETE_STATUS", GL_DELETE_STATUS);
132
+ this.webgl_constants.insert("DEPTH_ATTACHMENT", GL_DEPTH_ATTACHMENT);
133
+ this.webgl_constants.insert("DEPTH_BITS", GL_DEPTH_BITS);
134
+ this.webgl_constants.insert("DEPTH_BUFFER_BIT", GL_DEPTH_BUFFER_BIT);
135
+ this.webgl_constants.insert("DEPTH_CLEAR_VALUE", GL_DEPTH_CLEAR_VALUE);
136
+ this.webgl_constants.insert("DEPTH_COMPONENT", GL_DEPTH_COMPONENT);
137
+ this.webgl_constants.insert("DEPTH_COMPONENT16", GL_DEPTH_COMPONENT16);
138
+ this.webgl_constants.insert("DEPTH_FUNC", GL_DEPTH_FUNC);
139
+ this.webgl_constants.insert("DEPTH_RANGE", GL_DEPTH_RANGE);
140
+ this.webgl_constants.insert("DEPTH_TEST", GL_DEPTH_TEST);
141
+ this.webgl_constants.insert("DEPTH_WRITEMASK", GL_DEPTH_WRITEMASK);
142
+ this.webgl_constants.insert("DITHER", GL_DITHER);
143
+ this.webgl_constants.insert("DONT_CARE", GL_DONT_CARE);
144
+ this.webgl_constants.insert("DST_ALPHA", GL_DST_ALPHA);
145
+ this.webgl_constants.insert("DST_COLOR", GL_DST_COLOR);
146
+ this.webgl_constants.insert("DYNAMIC_DRAW", GL_DYNAMIC_DRAW);
147
+ this.webgl_constants.insert("ELEMENT_ARRAY_BUFFER", GL_ELEMENT_ARRAY_BUFFER);
148
+ this.webgl_constants.insert("ELEMENT_ARRAY_BUFFER_BINDING", GL_ELEMENT_ARRAY_BUFFER_BINDING);
149
+ this.webgl_constants.insert("EQUAL", GL_EQUAL);
150
+ this.webgl_constants.insert("FASTEST", GL_FASTEST);
151
+ this.webgl_constants.insert("FLOAT", GL_FLOAT);
152
+ this.webgl_constants.insert("FLOAT_MAT2", GL_FLOAT_MAT2);
153
+ this.webgl_constants.insert("FLOAT_MAT3", GL_FLOAT_MAT3);
154
+ this.webgl_constants.insert("FLOAT_MAT4", GL_FLOAT_MAT4);
155
+ this.webgl_constants.insert("FLOAT_VEC2", GL_FLOAT_VEC2);
156
+ this.webgl_constants.insert("FLOAT_VEC3", GL_FLOAT_VEC3);
157
+ this.webgl_constants.insert("FLOAT_VEC4", GL_FLOAT_VEC4);
158
+ this.webgl_constants.insert("FRAGMENT_SHADER", GL_FRAGMENT_SHADER);
159
+ this.webgl_constants.insert("FRAMEBUFFER", GL_FRAMEBUFFER);
160
+ this.webgl_constants.insert("FRAMEBUFFER_ATTACHMENT_OBJECT_NAME", GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
161
+ this.webgl_constants.insert("FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE", GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
162
+ this.webgl_constants.insert("FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE", GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE);
163
+ this.webgl_constants.insert("FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL", GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL);
164
+ this.webgl_constants.insert("FRAMEBUFFER_BINDING", GL_FRAMEBUFFER_BINDING);
165
+ this.webgl_constants.insert("FRAMEBUFFER_COMPLETE", GL_FRAMEBUFFER_COMPLETE);
166
+ this.webgl_constants.insert("FRAMEBUFFER_INCOMPLETE_ATTACHMENT", GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
167
+ this.webgl_constants.insert("FRAMEBUFFER_INCOMPLETE_DIMENSIONS", GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES);
168
+ this.webgl_constants.insert("FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT", GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
169
+ this.webgl_constants.insert("FRAMEBUFFER_UNSUPPORTED", GL_FRAMEBUFFER_UNSUPPORTED);
170
+ this.webgl_constants.insert("FRONT", GL_FRONT);
171
+ this.webgl_constants.insert("FRONT_AND_BACK", GL_FRONT_AND_BACK);
172
+ this.webgl_constants.insert("FRONT_FACE", GL_FRONT_FACE);
173
+ this.webgl_constants.insert("FUNC_ADD", GL_FUNC_ADD);
174
+ this.webgl_constants.insert("FUNC_REVERSE_SUBTRACT", GL_FUNC_REVERSE_SUBTRACT);
175
+ this.webgl_constants.insert("FUNC_SUBTRACT", GL_FUNC_SUBTRACT);
176
+ this.webgl_constants.insert("GENERATE_MIPMAP_HINT", GL_GENERATE_MIPMAP_HINT);
177
+ this.webgl_constants.insert("GEQUAL", GL_GEQUAL);
178
+ this.webgl_constants.insert("GREATER", GL_GREATER);
179
+ this.webgl_constants.insert("GREEN_BITS", GL_GREEN_BITS);
180
+ this.webgl_constants.insert("HIGH_FLOAT", GL_HIGH_FLOAT);
181
+ this.webgl_constants.insert("HIGH_INT", GL_HIGH_INT);
182
+ this.webgl_constants.insert("IMPLEMENTATION_COLOR_READ_FORMAT", GL_IMPLEMENTATION_COLOR_READ_FORMAT);
183
+ this.webgl_constants.insert("IMPLEMENTATION_COLOR_READ_TYPE", GL_IMPLEMENTATION_COLOR_READ_TYPE);
184
+ this.webgl_constants.insert("INCR", GL_INCR);
185
+ this.webgl_constants.insert("INCR_WRAP", GL_INCR_WRAP);
186
+ this.webgl_constants.insert("INT", GL_INT);
187
+ this.webgl_constants.insert("INT_VEC2", GL_INT_VEC2);
188
+ this.webgl_constants.insert("INT_VEC3", GL_INT_VEC3);
189
+ this.webgl_constants.insert("INT_VEC4", GL_INT_VEC4);
190
+ this.webgl_constants.insert("INVALID_ENUM", GL_INVALID_ENUM);
191
+ this.webgl_constants.insert("INVALID_FRAMEBUFFER_OPERATION", GL_INVALID_FRAMEBUFFER_OPERATION);
192
+ this.webgl_constants.insert("INVALID_OPERATION", GL_INVALID_OPERATION);
193
+ this.webgl_constants.insert("INVALID_VALUE", GL_INVALID_VALUE);
194
+ this.webgl_constants.insert("INVERT", GL_INVERT);
195
+ this.webgl_constants.insert("KEEP", GL_KEEP);
196
+ this.webgl_constants.insert("LEQUAL", GL_LEQUAL);
197
+ this.webgl_constants.insert("LESS", GL_LESS);
198
+ this.webgl_constants.insert("LINEAR", GL_LINEAR);
199
+ this.webgl_constants.insert("LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR);
200
+ this.webgl_constants.insert("LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST);
201
+ this.webgl_constants.insert("LINES", GL_LINES);
202
+ this.webgl_constants.insert("LINE_LOOP", GL_LINE_LOOP);
203
+ this.webgl_constants.insert("LINE_STRIP", GL_LINE_STRIP);
204
+ this.webgl_constants.insert("LINE_WIDTH", GL_LINE_WIDTH);
205
+ this.webgl_constants.insert("LINK_STATUS", GL_LINK_STATUS);
206
+ this.webgl_constants.insert("LOW_FLOAT", GL_LOW_FLOAT);
207
+ this.webgl_constants.insert("LOW_INT", GL_LOW_INT);
208
+ this.webgl_constants.insert("LUMINANCE", GL_LUMINANCE);
209
+ this.webgl_constants.insert("LUMINANCE_ALPHA", GL_LUMINANCE_ALPHA);
210
+ this.webgl_constants.insert("MAX_COMBINED_TEXTURE_IMAGE_UNITS", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
211
+ this.webgl_constants.insert("MAX_CUBE_MAP_TEXTURE_SIZE", GL_MAX_CUBE_MAP_TEXTURE_SIZE);
212
+ this.webgl_constants.insert("MAX_FRAGMENT_UNIFORM_VECTORS", GL_MAX_FRAGMENT_UNIFORM_VECTORS);
213
+ this.webgl_constants.insert("MAX_RENDERBUFFER_SIZE", GL_MAX_RENDERBUFFER_SIZE);
214
+ this.webgl_constants.insert("MAX_TEXTURE_IMAGE_UNITS", GL_MAX_TEXTURE_IMAGE_UNITS);
215
+ this.webgl_constants.insert("MAX_TEXTURE_SIZE", GL_MAX_TEXTURE_SIZE);
216
+ this.webgl_constants.insert("MAX_VARYING_VECTORS", GL_MAX_VARYING_VECTORS);
217
+ this.webgl_constants.insert("MAX_VERTEX_ATTRIBS", GL_MAX_VERTEX_ATTRIBS);
218
+ this.webgl_constants.insert("MAX_VERTEX_TEXTURE_IMAGE_UNITS", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
219
+ this.webgl_constants.insert("MAX_VERTEX_UNIFORM_VECTORS", GL_MAX_VERTEX_UNIFORM_VECTORS);
220
+ this.webgl_constants.insert("MAX_VIEWPORT_DIMS", GL_MAX_VIEWPORT_DIMS);
221
+ this.webgl_constants.insert("MEDIUM_FLOAT", GL_MEDIUM_FLOAT);
222
+ this.webgl_constants.insert("MEDIUM_INT", GL_MEDIUM_INT);
223
+ this.webgl_constants.insert("MIRRORED_REPEAT", GL_MIRRORED_REPEAT);
224
+ this.webgl_constants.insert("NEAREST", GL_NEAREST);
225
+ this.webgl_constants.insert("NEAREST_MIPMAP_LINEAR", GL_NEAREST_MIPMAP_LINEAR);
226
+ this.webgl_constants.insert("NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST);
227
+ this.webgl_constants.insert("NEVER", GL_NEVER);
228
+ this.webgl_constants.insert("NICEST", GL_NICEST);
229
+ this.webgl_constants.insert("NONE", GL_NONE);
230
+ this.webgl_constants.insert("NOTEQUAL", GL_NOTEQUAL);
231
+ this.webgl_constants.insert("NO_ERROR", GL_NO_ERROR);
232
+ this.webgl_constants.insert("ONE", GL_ONE);
233
+ this.webgl_constants.insert("ONE_MINUS_CONSTANT_ALPHA", GL_ONE_MINUS_CONSTANT_ALPHA);
234
+ this.webgl_constants.insert("ONE_MINUS_CONSTANT_COLOR", GL_ONE_MINUS_CONSTANT_COLOR);
235
+ this.webgl_constants.insert("ONE_MINUS_DST_ALPHA", GL_ONE_MINUS_DST_ALPHA);
236
+ this.webgl_constants.insert("ONE_MINUS_DST_COLOR", GL_ONE_MINUS_DST_COLOR);
237
+ this.webgl_constants.insert("ONE_MINUS_SRC_ALPHA", GL_ONE_MINUS_SRC_ALPHA);
238
+ this.webgl_constants.insert("ONE_MINUS_SRC_COLOR", GL_ONE_MINUS_SRC_COLOR);
239
+ this.webgl_constants.insert("OUT_OF_MEMORY", GL_OUT_OF_MEMORY);
240
+ this.webgl_constants.insert("PACK_ALIGNMENT", GL_PACK_ALIGNMENT);
241
+ this.webgl_constants.insert("POINTS", GL_POINTS);
242
+ this.webgl_constants.insert("POLYGON_OFFSET_FACTOR", GL_POLYGON_OFFSET_FACTOR);
243
+ this.webgl_constants.insert("POLYGON_OFFSET_FILL", GL_POLYGON_OFFSET_FILL);
244
+ this.webgl_constants.insert("POLYGON_OFFSET_UNITS", GL_POLYGON_OFFSET_UNITS);
245
+ this.webgl_constants.insert("RED_BITS", GL_RED_BITS);
246
+ this.webgl_constants.insert("RENDERBUFFER", GL_RENDERBUFFER);
247
+ this.webgl_constants.insert("RENDERBUFFER_ALPHA_SIZE", GL_RENDERBUFFER_ALPHA_SIZE);
248
+ this.webgl_constants.insert("RENDERBUFFER_BINDING", GL_RENDERBUFFER_BINDING);
249
+ this.webgl_constants.insert("RENDERBUFFER_BLUE_SIZE", GL_RENDERBUFFER_BLUE_SIZE);
250
+ this.webgl_constants.insert("RENDERBUFFER_DEPTH_SIZE", GL_RENDERBUFFER_DEPTH_SIZE);
251
+ this.webgl_constants.insert("RENDERBUFFER_GREEN_SIZE", GL_RENDERBUFFER_GREEN_SIZE);
252
+ this.webgl_constants.insert("RENDERBUFFER_HEIGHT", GL_RENDERBUFFER_HEIGHT);
253
+ this.webgl_constants.insert("RENDERBUFFER_INTERNAL_FORMAT", GL_RENDERBUFFER_INTERNAL_FORMAT);
254
+ this.webgl_constants.insert("RENDERBUFFER_RED_SIZE", GL_RENDERBUFFER_RED_SIZE);
255
+ this.webgl_constants.insert("RENDERBUFFER_STENCIL_SIZE", GL_RENDERBUFFER_STENCIL_SIZE);
256
+ this.webgl_constants.insert("RENDERBUFFER_WIDTH", GL_RENDERBUFFER_WIDTH);
257
+ this.webgl_constants.insert("RENDERER", GL_RENDERER);
258
+ this.webgl_constants.insert("REPEAT", GL_REPEAT);
259
+ this.webgl_constants.insert("REPLACE", GL_REPLACE);
260
+ this.webgl_constants.insert("RGB", GL_RGB);
261
+ this.webgl_constants.insert("RGB565", GL_RGB565);
262
+ this.webgl_constants.insert("RGB5_A1", GL_RGB5_A1);
263
+ this.webgl_constants.insert("RGBA", GL_RGBA);
264
+ this.webgl_constants.insert("RGBA4", GL_RGBA4);
265
+ this.webgl_constants.insert("SAMPLER_2D", GL_SAMPLER_2D);
266
+ this.webgl_constants.insert("SAMPLER_CUBE", GL_SAMPLER_CUBE);
267
+ this.webgl_constants.insert("SAMPLES", GL_SAMPLES);
268
+ this.webgl_constants.insert("SAMPLE_ALPHA_TO_COVERAGE", GL_SAMPLE_ALPHA_TO_COVERAGE);
269
+ this.webgl_constants.insert("SAMPLE_BUFFERS", GL_SAMPLE_BUFFERS);
270
+ this.webgl_constants.insert("SAMPLE_COVERAGE", GL_SAMPLE_COVERAGE);
271
+ this.webgl_constants.insert("SAMPLE_COVERAGE_INVERT", GL_SAMPLE_COVERAGE_INVERT);
272
+ this.webgl_constants.insert("SAMPLE_COVERAGE_VALUE", GL_SAMPLE_COVERAGE_VALUE);
273
+ this.webgl_constants.insert("SCISSOR_BOX", GL_SCISSOR_BOX);
274
+ this.webgl_constants.insert("SCISSOR_TEST", GL_SCISSOR_TEST);
275
+ this.webgl_constants.insert("SHADER_TYPE", GL_SHADER_TYPE);
276
+ this.webgl_constants.insert("SHADING_LANGUAGE_VERSION", GL_SHADING_LANGUAGE_VERSION);
277
+ this.webgl_constants.insert("SHORT", GL_SHORT);
278
+ this.webgl_constants.insert("SRC_ALPHA", GL_SRC_ALPHA);
279
+ this.webgl_constants.insert("SRC_ALPHA_SATURATE", GL_SRC_ALPHA_SATURATE);
280
+ this.webgl_constants.insert("SRC_COLOR", GL_SRC_COLOR);
281
+ this.webgl_constants.insert("STATIC_DRAW", GL_STATIC_DRAW);
282
+ this.webgl_constants.insert("STENCIL_ATTACHMENT", GL_STENCIL_ATTACHMENT);
283
+ this.webgl_constants.insert("STENCIL_BACK_FAIL", GL_STENCIL_BACK_FAIL);
284
+ this.webgl_constants.insert("STENCIL_BACK_FUNC", GL_STENCIL_BACK_FUNC);
285
+ this.webgl_constants.insert("STENCIL_BACK_PASS_DEPTH_FAIL", GL_STENCIL_BACK_PASS_DEPTH_FAIL);
286
+ this.webgl_constants.insert("STENCIL_BACK_PASS_DEPTH_PASS", GL_STENCIL_BACK_PASS_DEPTH_PASS);
287
+ this.webgl_constants.insert("STENCIL_BACK_REF", GL_STENCIL_BACK_REF);
288
+ this.webgl_constants.insert("STENCIL_BACK_VALUE_MASK", GL_STENCIL_BACK_VALUE_MASK);
289
+ this.webgl_constants.insert("STENCIL_BACK_WRITEMASK", GL_STENCIL_BACK_WRITEMASK);
290
+ this.webgl_constants.insert("STENCIL_BITS", GL_STENCIL_BITS);
291
+ this.webgl_constants.insert("STENCIL_BUFFER_BIT", GL_STENCIL_BUFFER_BIT);
292
+ this.webgl_constants.insert("STENCIL_CLEAR_VALUE", GL_STENCIL_CLEAR_VALUE);
293
+ this.webgl_constants.insert("STENCIL_FAIL", GL_STENCIL_FAIL);
294
+ this.webgl_constants.insert("STENCIL_FUNC", GL_STENCIL_FUNC);
295
+ this.webgl_constants.insert("STENCIL_INDEX8", GL_STENCIL_INDEX8);
296
+ this.webgl_constants.insert("STENCIL_PASS_DEPTH_FAIL", GL_STENCIL_PASS_DEPTH_FAIL);
297
+ this.webgl_constants.insert("STENCIL_PASS_DEPTH_PASS", GL_STENCIL_PASS_DEPTH_PASS);
298
+ this.webgl_constants.insert("STENCIL_REF", GL_STENCIL_REF);
299
+ this.webgl_constants.insert("STENCIL_TEST", GL_STENCIL_TEST);
300
+ this.webgl_constants.insert("STENCIL_VALUE_MASK", GL_STENCIL_VALUE_MASK);
301
+ this.webgl_constants.insert("STENCIL_WRITEMASK", GL_STENCIL_WRITEMASK);
302
+ this.webgl_constants.insert("STREAM_DRAW", GL_STREAM_DRAW);
303
+ this.webgl_constants.insert("SUBPIXEL_BITS", GL_SUBPIXEL_BITS);
304
+ this.webgl_constants.insert("TEXTURE", GL_TEXTURE);
305
+ this.webgl_constants.insert("TEXTURE0", GL_TEXTURE0);
306
+ this.webgl_constants.insert("TEXTURE1", GL_TEXTURE1);
307
+ this.webgl_constants.insert("TEXTURE10", GL_TEXTURE10);
308
+ this.webgl_constants.insert("TEXTURE11", GL_TEXTURE11);
309
+ this.webgl_constants.insert("TEXTURE12", GL_TEXTURE12);
310
+ this.webgl_constants.insert("TEXTURE13", GL_TEXTURE13);
311
+ this.webgl_constants.insert("TEXTURE14", GL_TEXTURE14);
312
+ this.webgl_constants.insert("TEXTURE15", GL_TEXTURE15);
313
+ this.webgl_constants.insert("TEXTURE16", GL_TEXTURE16);
314
+ this.webgl_constants.insert("TEXTURE17", GL_TEXTURE17);
315
+ this.webgl_constants.insert("TEXTURE18", GL_TEXTURE18);
316
+ this.webgl_constants.insert("TEXTURE19", GL_TEXTURE19);
317
+ this.webgl_constants.insert("TEXTURE2", GL_TEXTURE2);
318
+ this.webgl_constants.insert("TEXTURE20", GL_TEXTURE20);
319
+ this.webgl_constants.insert("TEXTURE21", GL_TEXTURE21);
320
+ this.webgl_constants.insert("TEXTURE22", GL_TEXTURE22);
321
+ this.webgl_constants.insert("TEXTURE23", GL_TEXTURE23);
322
+ this.webgl_constants.insert("TEXTURE24", GL_TEXTURE24);
323
+ this.webgl_constants.insert("TEXTURE25", GL_TEXTURE25);
324
+ this.webgl_constants.insert("TEXTURE26", GL_TEXTURE26);
325
+ this.webgl_constants.insert("TEXTURE27", GL_TEXTURE27);
326
+ this.webgl_constants.insert("TEXTURE28", GL_TEXTURE28);
327
+ this.webgl_constants.insert("TEXTURE29", GL_TEXTURE29);
328
+ this.webgl_constants.insert("TEXTURE3", GL_TEXTURE3);
329
+ this.webgl_constants.insert("TEXTURE30", GL_TEXTURE30);
330
+ this.webgl_constants.insert("TEXTURE31", GL_TEXTURE31);
331
+ this.webgl_constants.insert("TEXTURE4", GL_TEXTURE4);
332
+ this.webgl_constants.insert("TEXTURE5", GL_TEXTURE5);
333
+ this.webgl_constants.insert("TEXTURE6", GL_TEXTURE6);
334
+ this.webgl_constants.insert("TEXTURE7", GL_TEXTURE7);
335
+ this.webgl_constants.insert("TEXTURE8", GL_TEXTURE8);
336
+ this.webgl_constants.insert("TEXTURE9", GL_TEXTURE9);
337
+ this.webgl_constants.insert("TEXTURE_2D", GL_TEXTURE_2D);
338
+ this.webgl_constants.insert("TEXTURE_BINDING_2D", GL_TEXTURE_BINDING_2D);
339
+ this.webgl_constants.insert("TEXTURE_BINDING_CUBE_MAP", GL_TEXTURE_BINDING_CUBE_MAP);
340
+ this.webgl_constants.insert("TEXTURE_CUBE_MAP", GL_TEXTURE_CUBE_MAP);
341
+ this.webgl_constants.insert("TEXTURE_CUBE_MAP_NEGATIVE_X", GL_TEXTURE_CUBE_MAP_NEGATIVE_X);
342
+ this.webgl_constants.insert("TEXTURE_CUBE_MAP_NEGATIVE_Y", GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);
343
+ this.webgl_constants.insert("TEXTURE_CUBE_MAP_NEGATIVE_Z", GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
344
+ this.webgl_constants.insert("TEXTURE_CUBE_MAP_POSITIVE_X", GL_TEXTURE_CUBE_MAP_POSITIVE_X);
345
+ this.webgl_constants.insert("TEXTURE_CUBE_MAP_POSITIVE_Y", GL_TEXTURE_CUBE_MAP_POSITIVE_Y);
346
+ this.webgl_constants.insert("TEXTURE_CUBE_MAP_POSITIVE_Z", GL_TEXTURE_CUBE_MAP_POSITIVE_Z);
347
+ this.webgl_constants.insert("TEXTURE_MAG_FILTER", GL_TEXTURE_MAG_FILTER);
348
+ this.webgl_constants.insert("TEXTURE_MIN_FILTER", GL_TEXTURE_MIN_FILTER);
349
+ this.webgl_constants.insert("TEXTURE_WRAP_S", GL_TEXTURE_WRAP_S);
350
+ this.webgl_constants.insert("TEXTURE_WRAP_T", GL_TEXTURE_WRAP_T);
351
+ this.webgl_constants.insert("TRIANGLES", GL_TRIANGLES);
352
+ this.webgl_constants.insert("TRIANGLE_FAN", GL_TRIANGLE_FAN);
353
+ this.webgl_constants.insert("TRIANGLE_STRIP", GL_TRIANGLE_STRIP);
354
+ this.webgl_constants.insert("UNPACK_ALIGNMENT", GL_UNPACK_ALIGNMENT);
355
+ this.webgl_constants.insert("UNSIGNED_BYTE", GL_UNSIGNED_BYTE);
356
+ this.webgl_constants.insert("UNSIGNED_INT", GL_UNSIGNED_INT);
357
+ this.webgl_constants.insert("UNSIGNED_SHORT", GL_UNSIGNED_SHORT);
358
+ this.webgl_constants.insert("UNSIGNED_SHORT_4_4_4_4", GL_UNSIGNED_SHORT_4_4_4_4);
359
+ this.webgl_constants.insert("UNSIGNED_SHORT_5_5_5_1", GL_UNSIGNED_SHORT_5_5_5_1);
360
+ this.webgl_constants.insert("UNSIGNED_SHORT_5_6_5", GL_UNSIGNED_SHORT_5_6_5);
361
+ this.webgl_constants.insert("VALIDATE_STATUS", GL_VALIDATE_STATUS);
362
+ this.webgl_constants.insert("VENDOR", GL_VENDOR);
363
+ this.webgl_constants.insert("VERSION", GL_VERSION);
364
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
365
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_ENABLED", GL_VERTEX_ATTRIB_ARRAY_ENABLED);
366
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_NORMALIZED", GL_VERTEX_ATTRIB_ARRAY_NORMALIZED);
367
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_POINTER", GL_VERTEX_ATTRIB_ARRAY_POINTER);
368
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_SIZE", GL_VERTEX_ATTRIB_ARRAY_SIZE);
369
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_STRIDE", GL_VERTEX_ATTRIB_ARRAY_STRIDE);
370
+ this.webgl_constants.insert("VERTEX_ATTRIB_ARRAY_TYPE", GL_VERTEX_ATTRIB_ARRAY_TYPE);
371
+ this.webgl_constants.insert("VERTEX_SHADER", GL_VERTEX_SHADER);
372
+ this.webgl_constants.insert("VIEWPORT", GL_VIEWPORT);
373
+ this.webgl_constants.insert("ZERO", GL_ZERO);
374
+ }
375
+
376
+ public HashTable<string, int> get_webgl_constants() {
377
+ return this.webgl_constants;
378
+ }
379
+
380
+ public void _vertexAttribDivisor(uint index, uint divisor) {
381
+ glVertexAttribDivisor(index, divisor);
382
+ }
383
+
384
+ public void activeTexture(int texture) {
385
+ glActiveTexture(texture);
386
+ }
387
+
388
+ public void attachShader(/*WebGLProgram*/ uint program, /*WebGLShader*/ uint shader) {
389
+ glAttachShader(program, shader);
390
+ }
391
+
392
+ public void bindAttribLocation(/*WebGLProgram*/ uint program, uint index, string name) {
393
+ glBindAttribLocation(program, index, name);
394
+ }
395
+
396
+ public void bindBuffer(uint target, /*WebGLBuffer*/ uint buffer) {
397
+ glBindBuffer( target, buffer);
398
+ }
399
+
400
+ public void bindFramebuffer(int target, /*WebGLFramebuffer*/ uint framebuffer) {
401
+ glBindFramebuffer(target, framebuffer);
402
+ }
403
+
404
+ public void bindRenderbuffer(int target, /*WebGLFramebuffer*/ uint renderbuffer) {
405
+ glBindRenderbuffer(target, renderbuffer);
406
+ }
407
+
408
+ public void bindTexture(int target, /*WebGLTexture*/ uint texture) {
409
+ glBindTexture(target, texture);
410
+ }
411
+
412
+ public void blendColor(float red, float green, float blue, float alpha) {
413
+ glBlendColor(red, green, blue, alpha);
414
+ }
415
+
416
+ public void blendEquation(int mode) {
417
+ glBlendEquation(mode);
418
+ }
419
+
420
+ public void blendEquationSeparate(int modeRGB, int modeAlpha) {
421
+ glBlendEquationSeparate(modeRGB, modeAlpha);
422
+ }
423
+
424
+ public void blendFunc(int sfactor, int dfactor) {
425
+ glBlendFunc(sfactor, dfactor);
426
+ }
427
+
428
+ public void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
429
+ glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
430
+ }
431
+
432
+ public uint checkFramebufferStatus(uint target) {
433
+ return glCheckFramebufferStatus(target);
434
+ }
435
+
436
+ public void clear(uint mask) {
437
+ glClear(mask);
438
+ }
439
+
440
+ public void clearColor(float red, float green, float blue, float alpha) {
441
+ glClearColor(red, green, blue, alpha);
442
+ }
443
+
444
+ public void clearDepth(float depth) {
445
+ glClearDepthf(depth);
446
+ }
447
+
448
+ public void clearStencil(int s) {
449
+ glClearStencil(s);
450
+ }
451
+
452
+ public void colorMask(bool red, bool green, bool blue, bool alpha) {
453
+ glColorMask((uint8) red, (uint8) green, (uint8) blue, (uint8) alpha);
454
+ }
455
+
456
+ public void compileShader(/*WebGLShader*/ uint shader) {
457
+ glCompileShader(shader);
458
+ }
459
+
460
+ public void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border) {
461
+ glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
462
+ }
463
+
464
+ public void copyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, int width, int height) {
465
+ glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
466
+ }
467
+
468
+ public /*WebGLBuffer*/ uint createBuffer() {
469
+ uint[] buffers = new uint[1];
470
+ glGenBuffers(1, buffers);
471
+ return buffers[0];
472
+ }
473
+
474
+ public /*WebGLFramebuffer*/ uint createFramebuffer() {
475
+ uint[] frameBuffers = new uint[1];
476
+ glGenFramebuffers(1, frameBuffers);
477
+ return frameBuffers[0];
478
+ }
479
+
480
+ public /*WebGLProgram*/ uint createProgram() {
481
+ return glCreateProgram();
482
+ }
483
+
484
+ public /*WebGLFramebuffer*/ uint createRenderbuffer() {
485
+ /*WebGLFramebuffer*/ uint[] renderbuffer = new uint[1];
486
+ glGenRenderbuffers(1, renderbuffer);
487
+ return renderbuffer[0];
488
+ }
489
+
490
+ public uint createShader(int type) {
491
+ return glCreateShader(type);
492
+ }
493
+
494
+ public /*WebGLTexture*/ uint createTexture() {
495
+ // https://github.com/smx-smx/openSage/blob/518dc958156acf2f8bf58f29a35bd2aa89fd1355/src/GLEventHandler.vala#L20
496
+ /*WebGLTexture*/ uint[] textures = new uint[1];
497
+ glGenTextures(1, textures);
498
+ return textures[0];
499
+ }
500
+
501
+ public void cullFace(int mode) {
502
+ glCullFace(mode);
503
+ }
504
+
505
+ public void deleteBuffer(/*WebGLBuffer*/ uint buffer) {
506
+ uint[] buffers = new uint[1]{buffer};
507
+ glDeleteBuffers(1, buffers);
508
+ }
509
+
510
+ public void deleteFramebuffer(/*WebGLFramebuffer*/ uint framebuffer) {
511
+ uint[] framebuffers = new uint[1]{framebuffer};
512
+ glDeleteFramebuffers(1, framebuffers);
513
+ }
514
+
515
+ public void deleteProgram(/*WebGLProgram*/ uint program) {
516
+ glDeleteProgram(program);
517
+ }
518
+
519
+ public void deleteRenderbuffer(/*WebGLFramebuffer*/ uint renderbuffer) {
520
+ uint[] renderbuffers = new uint[1]{renderbuffer};
521
+ glDeleteRenderbuffers(1, renderbuffers);
522
+ }
523
+
524
+ public void deleteShader(/*WebGLShader*/ uint shader) {
525
+ glDeleteShader(shader);
526
+ }
527
+
528
+ public void deleteTexture(/*WebGLTexture*/ uint texture) {
529
+ uint[] textures = new uint[1]{texture};
530
+ glDeleteTextures(1, textures);
531
+ }
532
+
533
+ public void depthFunc(int func) {
534
+ glDepthFunc(func);
535
+ }
536
+
537
+ public void depthMask(bool flag) {
538
+ glDepthMask((GLboolean) flag);
539
+ }
540
+
541
+ public void depthRange(float zNear, float zFar) {
542
+ glDepthRangef(zNear, zFar);
543
+ }
544
+
545
+ // public void destroy() {
546
+ // dispose();
547
+ // }
548
+
549
+ public void detachShader(/*WebGLProgram*/ uint program, /*WebGLShader*/ uint shader) {
550
+ glDetachShader(program, shader);
551
+ }
552
+
553
+ public void disable(int cap) {
554
+ glDisable(cap);
555
+ }
556
+
557
+ public void disableVertexAttribArray(uint index) {
558
+ glDisableVertexAttribArray(index);
559
+ }
560
+
561
+ public void drawArrays(int mode, int first, int count) {
562
+ glDrawArrays(mode, first, count);
563
+ }
564
+
565
+ public void _drawArraysInstanced(int mode, int first, int count, int instancecount) {
566
+ glDrawArraysInstanced(mode, first, count, instancecount);
567
+ }
568
+
569
+ public void drawElements(int mode, int count, int type, long offset) {
570
+ glDrawElements(mode, count, type, (void*) offset);
571
+ }
572
+
573
+ public void _drawElementsInstanced(int mode, int count, int type, long offset, int instancecount) {
574
+ glDrawElementsInstanced(mode, count, type, (void*) offset, instancecount);
575
+ }
576
+
577
+ public void enable(int cap) {
578
+ glEnable(cap);
579
+ }
580
+
581
+ public void enableVertexAttribArray(uint index) {
582
+ glEnableVertexAttribArray(index);
583
+ }
584
+
585
+ public void finish() {
586
+ glFinish();
587
+ }
588
+
589
+ public void flush() {
590
+ glFlush();
591
+ }
592
+
593
+ public void framebufferRenderbuffer(int target, int attachment, int renderbufferTarget, /*WebGLFramebuffer*/ uint renderbuffer) {
594
+ glFramebufferRenderbuffer(target, attachment, renderbufferTarget, renderbuffer);
595
+ }
596
+
597
+ public void framebufferTexture2D(int target, int attachment, int textarget, /*WebGLTexture*/ uint texture, int level) {
598
+ glFramebufferTexture2D(target, attachment, textarget, texture, level);
599
+ }
600
+
601
+ public void frontFace(int mode) {
602
+ glFrontFace(mode);
603
+ }
604
+
605
+ public void generateMipmap(int target) {
606
+ glGenerateMipmap(target);
607
+ }
608
+
609
+ public WebGLActiveInfo getActiveAttrib(/*WebGLProgram*/ uint program, uint index) {
610
+ int[] bufSize = new int[1];
611
+ // TODO
612
+ GLsizei[] bufLength = new GLsizei[1];
613
+ // TODO
614
+ int[] size = new int[1];
615
+ // TODO
616
+ GLenum[] type = new GLenum[1];
617
+
618
+
619
+
620
+ glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, bufSize);
621
+ uint8[] name = new uint8[bufSize[0] + 1];
622
+ glGetActiveAttrib(program, index, bufSize[0], bufLength, size, type, name);
623
+
624
+ var res = WebGLActiveInfo() {
625
+ name = (string) name,
626
+ size = (int) size,
627
+ type = (int) type,
628
+ };
629
+
630
+ return res;
631
+ }
632
+
633
+ public WebGLActiveInfo getActiveUniform(/*WebGLProgram*/ uint program, uint index)
634
+ {
635
+ int[] bufSize = new int[1];
636
+ // TODO
637
+ GLsizei[] bufLength = new GLsizei[1];
638
+ // TODO
639
+ int[] size = new int[1];
640
+ // TODO
641
+ GLenum[] type = new GLenum[1];
642
+
643
+ glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, bufSize);
644
+ GLubyte[] name = new GLubyte[bufSize[0] + 1];
645
+ glGetActiveUniform(program, index, bufSize[0], bufLength, size, type, name);
646
+
647
+ var res = WebGLActiveInfo() {
648
+ name = (string) name,
649
+ size = (int) size,
650
+ type = (int) type,
651
+ };
652
+
653
+ return res;
654
+ }
655
+
656
+ public /*WebGLShader*/ uint[] getAttachedShaders(/*WebGLProgram*/ uint program) {
657
+ int[] bufSize = new int[1];
658
+ // TODO
659
+ GLsizei[] bufLength = new GLsizei[1];
660
+
661
+ glGetProgramiv(program, GL_ATTACHED_SHADERS, bufSize);
662
+ GLuint[] buf = new GLuint[bufSize[0] + 1]; // malloc((bufSize + 1) * sizeof(GLuint));
663
+ glGetAttachedShaders(program, bufSize[0], bufLength, buf);
664
+
665
+ if (bufLength[0] < bufSize[0]) {
666
+ buf.resize(bufLength[0] + 1);
667
+ }
668
+ buf[bufLength[0]] = 0;
669
+ return buf;
670
+ }
671
+
672
+ public int getAttribLocation(/*WebGLProgram*/ uint program, string name) {
673
+ return glGetAttribLocation(program, name);
674
+ }
675
+
676
+ public int[] getBufferParameteriv(int target, int pname) {
677
+ // TODO this is not an array?
678
+ int[] result = new int[0];
679
+ glGetBufferParameteriv(target, pname, result);
680
+ return result;
681
+ }
682
+
683
+ public int getError() {
684
+ GLenum error = glGetError();
685
+ if (this.lastError != GL_NO_ERROR) {
686
+ error = lastError;
687
+ }
688
+ lastError = GL_NO_ERROR;
689
+ return (int) error;
690
+ }
691
+
692
+ // https://github.com/stackgl/headless-gl/blob/ce1c08c0ef0c31d8c308cb828fd2f172c0bf5084/src/native/webgl.cc#L164
693
+ public void setError(int error) {
694
+ if (error == GL_NO_ERROR || this.lastError != GL_NO_ERROR) {
695
+ return;
696
+ }
697
+ GLenum prevError = this.getError();
698
+ if (prevError == GL_NO_ERROR) {
699
+ lastError = error;
700
+ }
701
+ }
702
+
703
+ public int getFramebufferAttachmentParameter(
704
+ int target,
705
+ int attachment,
706
+ int pname)
707
+ {
708
+ int[] result = new int[1];
709
+ glGetFramebufferAttachmentParameteriv(target, attachment, pname, result);
710
+ return result[0];
711
+ }
712
+
713
+ // Credits
714
+ // * https://github.com/stackgl/headless-gl/blob/ce1c08c0ef0c31d8c308cb828fd2f172c0bf5084/src/native/webgl.cc#L1745
715
+ // * https://github.com/mikeseven/node-webgl/blob/a918e74acc7860db1bb63029934e8f54a2730ce2/src/webgl.cc#L1502
716
+ public Variant getParameterx(int pname) {
717
+ switch(pname) {
718
+ case UNPACK_FLIP_Y_WEBGL: {
719
+ return new Variant("b", unpack_flip_y);
720
+ }
721
+
722
+ case UNPACK_PREMULTIPLY_ALPHA_WEBGL: {
723
+ return new Variant("b", unpack_premultiply_alpha);
724
+ }
725
+
726
+ case UNPACK_COLORSPACE_CONVERSION_WEBGL: {
727
+ return new Variant("i", unpack_colorspace_conversion);
728
+ }
729
+
730
+ case GL_BLEND:
731
+ case GL_CULL_FACE:
732
+ case GL_DEPTH_TEST:
733
+ case GL_DEPTH_WRITEMASK:
734
+ case GL_DITHER:
735
+ case GL_POLYGON_OFFSET_FILL:
736
+ case GL_SAMPLE_COVERAGE_INVERT:
737
+ case GL_SCISSOR_TEST:
738
+ case GL_STENCIL_TEST:
739
+ {
740
+ GLboolean[] params = new GLboolean[1];
741
+ glGetBooleanv(pname, params);
742
+ return new Variant("b", (bool) params[0]);
743
+ }
744
+
745
+ case GL_DEPTH_CLEAR_VALUE:
746
+ case GL_LINE_WIDTH:
747
+ case GL_POLYGON_OFFSET_FACTOR:
748
+ case GL_POLYGON_OFFSET_UNITS:
749
+ case GL_SAMPLE_COVERAGE_VALUE:
750
+ case MAX_TEXTURE_MAX_ANISOTROPY_EXT:
751
+ {
752
+ float[] params = new float[1];
753
+ glGetFloatv(pname, params);
754
+ return new Variant("f", (float) params[0]);
755
+ }
756
+
757
+ case GL_RENDERER:
758
+ case GL_SHADING_LANGUAGE_VERSION:
759
+ case GL_VENDOR:
760
+ case GL_VERSION:
761
+ case GL_EXTENSIONS:
762
+ {
763
+ var str = glGetString(pname);
764
+ return new Variant("s", str);
765
+ }
766
+
767
+ case GL_MAX_VIEWPORT_DIMS:
768
+ {
769
+ int[] params = new int[2];
770
+ glGetIntegerv(pname, params);
771
+ return new Variant("ai", (int[]) params);
772
+ }
773
+
774
+ case GL_SCISSOR_BOX:
775
+ case GL_VIEWPORT:
776
+ {
777
+ int[] params = new int[4];
778
+ glGetIntegerv(pname, params);
779
+ return new Variant("ai", (int[]) params);
780
+ }
781
+
782
+ case GL_ALIASED_LINE_WIDTH_RANGE:
783
+ case GL_ALIASED_POINT_SIZE_RANGE:
784
+ case GL_DEPTH_RANGE:
785
+ {
786
+ float[] params = new float[2];
787
+ glGetFloatv(pname, params);
788
+ return new Variant("af", (float[]) params);
789
+ }
790
+
791
+ case GL_BLEND_COLOR:
792
+ case GL_COLOR_CLEAR_VALUE:
793
+ {
794
+ float[] params = new float[4];
795
+ glGetFloatv(pname, params);
796
+ return new Variant("af", (float[]) params);
797
+ }
798
+
799
+ case GL_COLOR_WRITEMASK:
800
+ {
801
+ GLboolean[] params = new GLboolean[4];
802
+ glGetBooleanv(pname, params);
803
+ return new Variant("ab", (bool[]) params);
804
+ }
805
+
806
+ default:
807
+ {
808
+ int[] params = new int[1];
809
+ glGetIntegerv(pname, params);
810
+ return new Variant("i", (int) params[0]);
811
+ }
812
+ }
813
+ }
814
+
815
+ public bool getParameterb(int pname) {
816
+ GLboolean[] result = new GLboolean[1];
817
+ glGetBooleanv(pname, result);
818
+ return (bool) result[0];
819
+ }
820
+
821
+ public bool[] getParameterbv(int pname, int resultSize) {
822
+ GLboolean[] data = new GLboolean[resultSize];
823
+ glGetBooleanv(pname, data);
824
+ return (bool[]) data;
825
+ }
826
+
827
+ public float getParameterf(int pname) {
828
+ float[] data = new float[1];
829
+ glGetFloatv(pname, data);
830
+ return data[0];
831
+ }
832
+
833
+ public float[] getParameterfv(int pname, int resultSize) {
834
+ float[] data = new float[resultSize];
835
+ glGetFloatv(pname, data);
836
+ return data;
837
+ }
838
+
839
+ public int getParameteri(int pname) {
840
+ int[] data = new int[1];
841
+ glGetIntegerv(pname, data);
842
+ return data[0];
843
+ }
844
+
845
+ public int[] getParameteriv(int pname, int resultSize) {
846
+ // gpointer data = malloc(resultSize);
847
+ int[] data = new int[resultSize];
848
+ glGetIntegerv(pname, data);
849
+ return data;
850
+ }
851
+
852
+ public string getProgramInfoLog(/*WebGLProgram*/ uint program) {
853
+ GL.GLint[] params = new GL.GLint[1];
854
+ // TODO bufLength shoult not be an array?!
855
+ GLsizei[] bufLength = new GLsizei[1];
856
+ glGetProgramiv(program, GL_INFO_LOG_LENGTH, params);
857
+ int bufSize = params[0];
858
+ GLubyte[] infoLog = new GLubyte[bufSize + 1];
859
+ glGetProgramInfoLog(program, bufSize, bufLength, infoLog);
860
+ if (bufLength[0] < bufSize) {
861
+ infoLog.resize(bufLength[0] + 1);
862
+ }
863
+ infoLog[bufLength[0]] = 0;
864
+ return (string) infoLog;
865
+ }
866
+
867
+ public int getProgramParameter(/*WebGLProgram*/ uint program, int pname) {
868
+ GL.GLint[] params = new GL.GLint[1];
869
+ glGetProgramiv(program, pname, params);
870
+ int result = params[0];
871
+ return result;
872
+ }
873
+
874
+ public int getRenderbufferParameter(int target, int pname) {
875
+ int[] result = new int[1];
876
+ glGetRenderbufferParameteriv(target, pname, result);
877
+ return result[0];
878
+ }
879
+
880
+ public string getShaderInfoLog(/*WebGLShader*/ uint shader) {
881
+ int[] bufSize = new int[1];
882
+ GLsizei[] bufLength = new GLsizei[1];
883
+ glGetShaderiv(shader, GL_INFO_LOG_LENGTH, bufSize);
884
+ // char *buf = malloc((bufSize + 1) * sizeof(char));
885
+ GLubyte[] buf = new GLubyte[bufSize[0] + 1];
886
+ glGetShaderInfoLog(shader, bufSize[0], bufLength, buf);
887
+ if (bufLength[0] < bufSize[0])
888
+ {
889
+ // buf = realloc(buf, (bufLength + 1) * sizeof(char));
890
+ buf.resize(bufLength[0] + 1);
891
+ }
892
+ buf[bufLength[0]] = 0;
893
+ return (string) buf;
894
+ }
895
+
896
+ public int getShaderParameter(/*WebGLShader*/ uint shader, int pname) {
897
+ int[] result = new int[1];
898
+ glGetShaderiv(shader, pname, result);
899
+ return result[0];
900
+ }
901
+
902
+ public WebGLShaderPrecisionFormat getShaderPrecisionFormat(int shadertype, int precisiontype) {
903
+ int[] precision = new int[2];
904
+ int[] range = new int[2];
905
+
906
+ glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
907
+
908
+ var res = WebGLShaderPrecisionFormat() {
909
+ precision = (int) precision[0],
910
+ rangeMin = (int) range[0],
911
+ rangeMax = (int) range[1],
912
+ };
913
+ return res;
914
+ }
915
+
916
+ public string getShaderSource(/*WebGLShader*/ uint shader) {
917
+ int[] bufSize = new int[1];
918
+ GLsizei[] bufLength = new GLsizei[1];
919
+ glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, bufSize);
920
+ GLubyte[] buf = new GLubyte[bufSize[0] + 1];
921
+ glGetShaderSource(shader, bufSize[0], bufLength, buf);
922
+ if (bufLength[0] < bufSize[0]) {
923
+ buf.resize(bufLength[0] + 1);
924
+ }
925
+ buf[bufLength[0]] = 0;
926
+ return (string) buf;
927
+ }
928
+
929
+ public string getString(int pname) {
930
+ return glGetString(pname);
931
+ }
932
+
933
+ public string[] getSupportedExtensions() {
934
+ string result = glGetString(GL_EXTENSIONS);
935
+ string[] sp = result.split(" ", 0);
936
+ // char **sp = strsplit((const char *) result, " ", 0);
937
+ return sp;
938
+ }
939
+
940
+ // https://github.com/stackgl/headless-gl/blob/ce1c08c0ef0c31d8c308cb828fd2f172c0bf5084/src/native/webgl.cc#L1637
941
+ public Variant getTexParameterx(int target, int pname) {
942
+ if (pname == 0x84FE /* GL_TEXTURE_MAX_ANISOTROPY_EXT */) {
943
+ float[] param_value = new float[1];
944
+ glGetTexParameterfv(target, pname, param_value);
945
+ return new Variant("f", param_value[0]);
946
+ } else {
947
+ int[] param_value = new int[1];
948
+ glGetTexParameteriv(target, pname, param_value);
949
+ return new Variant("i", param_value[0]);
950
+ }
951
+ }
952
+
953
+ public float getTexParameterfv(int target, int pname) {
954
+ float[] result = new float[1];
955
+ glGetTexParameterfv(target, pname, result);
956
+ return result[0];
957
+ }
958
+
959
+ public int getTexParameteriv(int target, int pname) {
960
+ int[] result = new int[0];
961
+ glGetTexParameteriv(target, pname, result);
962
+ return result[0];
963
+ }
964
+
965
+ public /*WebGLUniformLocation*/ int getUniformLocation(/*WebGLProgram*/ uint program, string name) {
966
+ // print("getUniformLocation %u %s\n", program, name);
967
+ return glGetUniformLocation(program, name);
968
+ }
969
+
970
+ // https://github.com/stackgl/headless-gl/blob/ce1c08c0ef0c31d8c308cb828fd2f172c0bf5084/src/native/webgl.cc#L1976
971
+ public float[] getUniform(/*WebGLProgram*/ uint program, /*WebGLUniformLocation*/ int location) {
972
+ float[] result = new float[16];
973
+ glGetUniformfv(program, location, result);
974
+ return result;
975
+ }
976
+
977
+ public float[] getUniformf(/*WebGLProgram*/ uint program, /*WebGLUniformLocation*/ int location) {
978
+ float[] result = new float[0];
979
+ glGetUniformfv(program, location, result);
980
+ return result;
981
+ }
982
+
983
+ public float[] getUniformfv(/*WebGLProgram*/ uint program, /*WebGLUniformLocation*/ int location, int resultSize) {
984
+ float[] data = new float[resultSize];
985
+ glGetUniformfv(program, location, data);
986
+ return data;
987
+ }
988
+
989
+ public int[] getUniformi(/*WebGLProgram*/ uint program, /*WebGLUniformLocation*/ int location) {
990
+ int[] result = new int[0];
991
+ glGetUniformiv(program, location, result);
992
+ return result;
993
+ }
994
+
995
+ public int[] getUniformiv(/*WebGLProgram*/ uint program, /*WebGLUniformLocation*/ int location, int resultSize) {
996
+ int[] data = new int[resultSize];
997
+ glGetUniformiv(program, location, data);
998
+ return data;
999
+ }
1000
+
1001
+ public intptr getVertexAttribOffset(uint index, int pname) {
1002
+ long[] result = new long[1];
1003
+ // TODO result should not be an array?!
1004
+ glGetVertexAttribPointerv(index, pname, (GL.GLvoid[]) result);
1005
+ return (intptr) result[0];
1006
+ }
1007
+
1008
+ // https://github.com/stackgl/headless-gl/blob/ce1c08c0ef0c31d8c308cb828fd2f172c0bf5084/src/native/webgl.cc#L1993
1009
+ public Variant getVertexAttrib(uint index, int pname) throws TypeError {
1010
+ int[] value = new int[1];
1011
+ switch (pname) {
1012
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
1013
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: {
1014
+ glGetVertexAttribiv(index, pname, value);
1015
+ return new Variant("b", value[0] != 0);
1016
+ }
1017
+
1018
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE:
1019
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
1020
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE:
1021
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: {
1022
+ glGetVertexAttribiv(index, pname, value);
1023
+ return new Variant("i", value[0]);
1024
+ }
1025
+
1026
+ case GL_CURRENT_VERTEX_ATTRIB: {
1027
+ float[] vextex_attribs = new float[4];
1028
+ glGetVertexAttribfv(index, pname, vextex_attribs);
1029
+ return new Variant("af", vextex_attribs);
1030
+ }
1031
+ default: {
1032
+ throw new TypeError.CODE("GL_INVALID_ENUM %i", GL_INVALID_ENUM);
1033
+ }
1034
+ }
1035
+ }
1036
+
1037
+ public float[] getVertexAttribf(uint index, int pname) {
1038
+ float[] result = new float[0];
1039
+ glGetVertexAttribfv(index, pname, result);
1040
+ return result;
1041
+ }
1042
+
1043
+ public float[] getVertexAttribfv(uint index, int pname, int resultSize) {
1044
+ float[] data = new float[resultSize];
1045
+ glGetVertexAttribfv(index, pname, data);
1046
+ return data;
1047
+ }
1048
+
1049
+ public int[] getVertexAttribi(uint index, int pname) {
1050
+ int[] result = new int[0];
1051
+ glGetVertexAttribiv(index, pname, result);
1052
+ return result;
1053
+ }
1054
+
1055
+ public void hint(int target, int mode) {
1056
+ glHint(target, mode);
1057
+ }
1058
+
1059
+ public bool isBuffer(/*WebGLBuffer*/ uint buffer) {
1060
+ return (bool) glIsBuffer(buffer);
1061
+ }
1062
+
1063
+ public bool isEnabled(int cap) {
1064
+ return (bool) glIsEnabled(cap);
1065
+ }
1066
+
1067
+ public bool isFramebuffer(/*WebGLFramebuffer*/ uint framebuffer) {
1068
+ return (bool) glIsFramebuffer(framebuffer);
1069
+ }
1070
+
1071
+ public bool isProgram(/*WebGLProgram*/ uint program) {
1072
+ return (bool) glIsProgram(program);
1073
+ }
1074
+
1075
+ public bool isRenderbuffer(/*WebGLFramebuffer*/ uint renderbuffer) {
1076
+ return (bool) glIsRenderbuffer(renderbuffer);
1077
+ }
1078
+
1079
+ public bool isShader(/*WebGLShader*/ uint shader) {
1080
+ return (bool) glIsShader(shader);
1081
+ }
1082
+
1083
+ public bool isTexture(/*WebGLTexture*/ uint texture) {
1084
+ return (bool) glIsTexture(texture);
1085
+ }
1086
+
1087
+ public void lineWidth(float width) {
1088
+ glLineWidth(width);
1089
+ }
1090
+
1091
+ public void linkProgram(/*WebGLProgram*/ uint program) {
1092
+ glLinkProgram(program);
1093
+ }
1094
+
1095
+ // https://github.com/stackgl/headless-gl/blob/ce1c08c0ef0c31d8c308cb828fd2f172c0bf5084/src/native/webgl.cc#L374
1096
+ public void pixelStorei(int pname, int param) {
1097
+
1098
+ // Handle WebGL specific extensions
1099
+ switch(pname) {
1100
+ case UNPACK_FLIP_Y_WEBGL:
1101
+ this.unpack_flip_y = param != 0;
1102
+ break;
1103
+
1104
+ case UNPACK_PREMULTIPLY_ALPHA_WEBGL:
1105
+ this.unpack_premultiply_alpha = param != 0;
1106
+ break;
1107
+
1108
+ case UNPACK_COLORSPACE_CONVERSION_WEBGL:
1109
+ this.unpack_colorspace_conversion = param;
1110
+ break;
1111
+
1112
+ case GL_UNPACK_ALIGNMENT:
1113
+ this.unpack_alignment = param;
1114
+ glPixelStorei(pname, param);
1115
+ break;
1116
+
1117
+ case MAX_DRAW_BUFFERS_WEBGL:
1118
+ glPixelStorei(pname, param);
1119
+ break;
1120
+
1121
+ default:
1122
+ glPixelStorei(pname, param);
1123
+ break;
1124
+ }
1125
+
1126
+ }
1127
+
1128
+ public void polygonOffset(float factor, float units) {
1129
+ glPolygonOffset(factor, units);
1130
+ }
1131
+
1132
+ public void renderbufferStorage(int target, int internalFormat, int width, int height) {
1133
+ glRenderbufferStorage(target, internalFormat, width, height);
1134
+ }
1135
+
1136
+ public void sampleCoverage(float value, bool invert) {
1137
+ glSampleCoverage(value, (GLboolean) invert);
1138
+ }
1139
+
1140
+ public void scissor(int x, int y, int width, int height) {
1141
+ glScissor(x, y, width, height);
1142
+ }
1143
+
1144
+ public void shaderSource(/*WebGLShader*/ uint shader, string source) {
1145
+ string[] sources = new string[]{ source };
1146
+ int[] length = new int[1]{ source.length };
1147
+ glShaderSource(shader, 1, sources, length);
1148
+ }
1149
+
1150
+ public void stencilFunc(int func, int ref_, uint mask) {
1151
+ glStencilFunc(func, ref_, mask);
1152
+ }
1153
+
1154
+ public void stencilFuncSeparate(int face, int func, int ref_, uint mask) {
1155
+ glStencilFuncSeparate(face, func, ref_, mask);
1156
+ }
1157
+
1158
+ public void stencilMask(uint mask) {
1159
+ glStencilMask(mask);
1160
+ }
1161
+
1162
+ public void stencilMaskSeparate(int face, uint mask) {
1163
+ glStencilMaskSeparate(face, mask);
1164
+ }
1165
+
1166
+ public void stencilOp(int fail, int zfail, int zpass) {
1167
+ glStencilOp(fail, zfail, zpass);
1168
+ }
1169
+
1170
+ public void stencilOpSeparate(int face, int fail, int zfail, int zpass) {
1171
+ glStencilOpSeparate(face, fail, zfail, zpass);
1172
+ }
1173
+
1174
+ public void texParameterf(int target, int pname, float param) {
1175
+ glTexParameterf(target, pname, param);
1176
+ }
1177
+
1178
+ public void texParameteri(int target, int pname, int param) {
1179
+ glTexParameteri(target, pname, param);
1180
+ }
1181
+
1182
+ public void uniform1f(/*WebGLUniformLocation*/ int location, float x) {
1183
+ glUniform1f(location, x);
1184
+ }
1185
+
1186
+ public void uniform1i(/*WebGLUniformLocation*/ int location, int x) {
1187
+ glUniform1i(location, x);
1188
+ }
1189
+
1190
+ public void uniform2f(/*WebGLUniformLocation*/ int location, float x, float y) {
1191
+ glUniform2f(location, x, y);
1192
+ }
1193
+
1194
+ public void uniform2i(/*WebGLUniformLocation*/ int location, int x, int y) {
1195
+ glUniform2i(location, x, y);
1196
+ }
1197
+
1198
+ public void uniform3f(/*WebGLUniformLocation*/ int location, float x, float y, float z) {
1199
+ glUniform3f(location, x, y, z);
1200
+ }
1201
+
1202
+ public void uniform3i(/*WebGLUniformLocation*/ int location, int x, int y, int z) {
1203
+ glUniform3i(location, x, y, z);
1204
+ }
1205
+
1206
+ public void uniform4f(/*WebGLUniformLocation*/ int location, float x, float y, float z, float w) {
1207
+ glUniform4f(location, x, y, z, w);
1208
+ }
1209
+
1210
+ public void uniform4i(/*WebGLUniformLocation*/ int location, int x, int y, int z, int w) {
1211
+ glUniform4i(location, x, y, z, w);
1212
+ }
1213
+
1214
+ public void useProgram(/*WebGLProgram*/ uint program) {
1215
+ glUseProgram(program);
1216
+ }
1217
+
1218
+ public void validateProgram(/*WebGLProgram*/ uint program) {
1219
+ glValidateProgram(program);
1220
+ }
1221
+
1222
+ public void vertexAttrib1f(uint index, float x) {
1223
+ glVertexAttrib1f(index, x);
1224
+ }
1225
+
1226
+ public void vertexAttrib1fv(uint index, float[] v) {
1227
+ glVertexAttrib1fv(index, v);
1228
+ }
1229
+
1230
+ public void vertexAttrib2f(uint index, float x, float y) {
1231
+ glVertexAttrib2f(index, x, y);
1232
+ }
1233
+
1234
+ public void vertexAttrib2fv(uint index, float[] values) {
1235
+ glVertexAttrib2fv(index, values);
1236
+ }
1237
+
1238
+ public void vertexAttrib3f(uint index, float x, float y, float z) {
1239
+ glVertexAttrib3f(index, x, y, z);
1240
+ }
1241
+
1242
+ public void vertexAttrib3fv(uint index, float[] values) {
1243
+ glVertexAttrib3fv(index, values);
1244
+ }
1245
+
1246
+ public void vertexAttrib4f(uint index, float x, float y, float z, float w) {
1247
+ glVertexAttrib4f(index, x, y, z, w);
1248
+ }
1249
+
1250
+ public void vertexAttrib4fv(uint index, float[] values) {
1251
+ glVertexAttrib4fv(index, values);
1252
+ }
1253
+
1254
+ public void vertexAttribPointer(uint index, int size, uint type, bool _normalized, int stride, long offset) {
1255
+ uint8 normalized = (uint8) _normalized;
1256
+ // print("\nVertexAttribPointer index %u size %i type %u normalized %i stride %i offset %f", index, size, type, normalized, stride, offset);
1257
+ glVertexAttribPointer(index, size, type, normalized, stride, (void*) offset);
1258
+ }
1259
+
1260
+ public void viewport(int x, int y, int width, int height) {
1261
+ glViewport(x, y, width, height);
1262
+ }
1263
+
1264
+ }
1265
+ }