@nativescript/canvas 2.0.0-alpha.20 → 2.0.0-alpha.21

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 (234) hide show
  1. package/Canvas/common.d.ts +2 -0
  2. package/Canvas/common.js +6 -0
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +0 -2
  5. package/Canvas/index.android.js +8 -22
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +7 -0
  8. package/Canvas/index.ios.d.ts +0 -2
  9. package/Canvas/index.ios.js +7 -26
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasGradient/index.d.ts +1 -3
  12. package/Canvas2D/CanvasGradient/index.js +1 -10
  13. package/Canvas2D/CanvasGradient/index.js.map +1 -1
  14. package/Canvas2D/CanvasPattern/index.d.ts +1 -3
  15. package/Canvas2D/CanvasPattern/index.js +1 -10
  16. package/Canvas2D/CanvasPattern/index.js.map +1 -1
  17. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +0 -2
  18. package/Canvas2D/CanvasRenderingContext2D/index.js +120 -138
  19. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  20. package/Canvas2D/DOMMatrix/index.js +3 -3
  21. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  22. package/Canvas2D/ImageData/index.js +5 -5
  23. package/Canvas2D/ImageData/index.js.map +1 -1
  24. package/Canvas2D/Path2D/index.d.ts +0 -2
  25. package/Canvas2D/Path2D/index.js +34 -39
  26. package/Canvas2D/Path2D/index.js.map +1 -1
  27. package/ImageAsset/index.d.ts +2 -2
  28. package/ImageAsset/index.js +33 -37
  29. package/ImageAsset/index.js.map +1 -1
  30. package/ImageBitmap/index.d.ts +0 -2
  31. package/ImageBitmap/index.js +23 -29
  32. package/ImageBitmap/index.js.map +1 -1
  33. package/SVG/SVG.js +1 -1
  34. package/TextDecoder/index.d.ts +0 -2
  35. package/TextDecoder/index.js +3 -12
  36. package/TextDecoder/index.js.map +1 -1
  37. package/TextEncoder/index.d.ts +0 -2
  38. package/TextEncoder/index.js +4 -13
  39. package/TextEncoder/index.js.map +1 -1
  40. package/WebGL/WebGLExtensions/index.d.ts +0 -9
  41. package/WebGL/WebGLExtensions/index.js +17 -74
  42. package/WebGL/WebGLExtensions/index.js.map +1 -1
  43. package/WebGL/WebGLRenderingContext/common.d.ts +0 -2
  44. package/WebGL/WebGLRenderingContext/common.js +0 -10
  45. package/WebGL/WebGLRenderingContext/common.js.map +1 -1
  46. package/WebGL/WebGLRenderingContext/index.js +159 -298
  47. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  48. package/WebGL2/WebGL2RenderingContext/index.js +107 -195
  49. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  50. package/angular/esm2020/index.mjs +5 -5
  51. package/angular/fesm2015/nativescript-canvas-angular.mjs +4 -4
  52. package/angular/fesm2015/nativescript-canvas-angular.mjs.map +1 -1
  53. package/angular/fesm2020/nativescript-canvas-angular.mjs +4 -4
  54. package/angular/fesm2020/nativescript-canvas-angular.mjs.map +1 -1
  55. package/index.js.map +1 -1
  56. package/package.json +1 -1
  57. package/platforms/android/canvas-release.aar +0 -0
  58. package/platforms/android/include.gradle +15 -0
  59. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  60. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +87 -57
  61. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  62. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  63. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2589 -110
  64. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  65. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  66. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1174 -89
  67. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -2
  68. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  69. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +2 -2
  70. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  71. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  72. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +174 -114
  73. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative.h +10 -0
  74. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +142 -0
  75. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2589 -110
  76. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  77. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  78. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  79. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1174 -89
  80. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -2
  81. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  82. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -2
  83. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1174 -89
  84. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -2
  85. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  86. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +2 -2
  87. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +42 -31
  88. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  89. package/platforms/ios/Podfile +3 -0
  90. package/platforms/ios/build.xcconfig +3 -3
  91. package/platforms/ios/src/CanvasModule.h +0 -2
  92. package/platforms/ios/src/CanvasModule.mm +4 -4
  93. package/platforms/ios/src/NSOperationQueueWrapper.h +11 -0
  94. package/platforms/ios/src/NSOperationQueueWrapper.mm +74 -0
  95. package/platforms/ios/src/cpp/Caches.cpp +35 -0
  96. package/platforms/ios/src/cpp/Caches.h +186 -0
  97. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1582 -0
  98. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -34
  99. package/platforms/ios/src/cpp/Common.h +30 -0
  100. package/platforms/ios/src/cpp/ConcurrentMap.h +54 -0
  101. package/platforms/ios/src/cpp/Helpers.h +304 -38
  102. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +802 -0
  103. package/platforms/ios/src/cpp/ImageAssetImpl.h +44 -12
  104. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +189 -0
  105. package/platforms/ios/src/cpp/ImageBitmapImpl.h +22 -16
  106. package/platforms/ios/src/cpp/JSICallback.h +61 -5
  107. package/platforms/ios/src/cpp/JSIReadFileCallback.h +86 -6
  108. package/platforms/ios/src/cpp/JSIRuntime.cpp +21 -0
  109. package/platforms/ios/src/cpp/JSIRuntime.h +7 -0
  110. package/platforms/ios/src/cpp/OneByteStringResource.cpp +25 -0
  111. package/platforms/ios/src/cpp/OneByteStringResource.h +21 -0
  112. package/platforms/ios/src/cpp/RafImpl.cpp +8 -0
  113. package/platforms/ios/src/cpp/RafImpl.h +11 -8
  114. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +188 -0
  115. package/platforms/ios/src/cpp/TextDecoderImpl.h +20 -14
  116. package/platforms/ios/src/cpp/TextEncoderImpl.cpp +139 -0
  117. package/platforms/ios/src/cpp/TextEncoderImpl.h +20 -11
  118. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.cpp +71 -0
  119. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.h +27 -13
  120. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +89 -0
  121. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.h +26 -13
  122. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +2402 -0
  123. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.h +264 -21
  124. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.cpp +203 -0
  125. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.h +26 -12
  126. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +800 -0
  127. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +172 -13
  128. package/platforms/ios/src/cpp/canvas2d/Path2D.cpp +449 -0
  129. package/platforms/ios/src/cpp/canvas2d/Path2D.h +41 -12
  130. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.cpp +253 -0
  131. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.h +50 -12
  132. package/platforms/ios/src/cpp/gl.h +57 -7
  133. package/platforms/ios/src/cpp/gl3stub.c +425 -0
  134. package/platforms/ios/src/cpp/gl3stub.h +665 -0
  135. package/platforms/ios/src/cpp/gles3jni.h +37 -0
  136. package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
  137. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.cpp +93 -0
  138. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.h +33 -13
  139. package/platforms/ios/src/cpp/webgl/WebGLBuffer.h +41 -6
  140. package/platforms/ios/src/cpp/webgl/WebGLFramebuffer.h +46 -10
  141. package/platforms/ios/src/cpp/webgl/WebGLProgram.h +40 -5
  142. package/platforms/ios/src/cpp/webgl/WebGLRenderbuffer.h +40 -6
  143. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +6691 -0
  144. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.h +261 -390
  145. package/platforms/ios/src/cpp/webgl/{WebGLRenderingContextBase.mm → WebGLRenderingContextBase.cpp} +17 -16
  146. package/platforms/ios/src/cpp/webgl/WebGLRenderingContextBase.h +15 -36
  147. package/platforms/ios/src/cpp/webgl/WebGLShader.h +40 -6
  148. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.cpp +50 -0
  149. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.h +66 -11
  150. package/platforms/ios/src/cpp/webgl/WebGLTexture.h +40 -6
  151. package/platforms/ios/src/cpp/webgl/WebGLUniformLocation.h +44 -8
  152. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.cpp +126 -0
  153. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.h +25 -12
  154. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.cpp +35 -0
  155. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.h +25 -5
  156. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.cpp +41 -0
  157. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.h +25 -5
  158. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.cpp +323 -0
  159. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.h +47 -13
  160. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.h +49 -6
  161. package/platforms/ios/src/cpp/webgl/extensions/EXT_shader_texture_lodImpl.h +37 -15
  162. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.h +47 -6
  163. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.h +49 -6
  164. package/platforms/ios/src/cpp/webgl/extensions/OES_fbo_render_mipmap.h +36 -15
  165. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.h +44 -6
  166. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_floatImpl.h +38 -15
  167. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_float_linearImpl.h +37 -16
  168. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.h +41 -6
  169. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_float_linearImpl.h +40 -16
  170. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.cpp +102 -0
  171. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.h +69 -14
  172. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.h +51 -8
  173. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.h +49 -6
  174. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.h +49 -8
  175. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.h +76 -6
  176. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.h +57 -6
  177. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.h +53 -6
  178. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.h +59 -6
  179. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.h +46 -6
  180. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.cpp +43 -0
  181. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.h +126 -14
  182. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.cpp +32 -0
  183. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.h +61 -12
  184. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +4517 -0
  185. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.h +139 -343
  186. package/platforms/ios/src/cpp/webgl2/WebGLQuery.h +40 -4
  187. package/platforms/ios/src/cpp/webgl2/WebGLSampler.h +42 -3
  188. package/platforms/ios/src/cpp/webgl2/WebGLSyncImpl.h +44 -11
  189. package/platforms/ios/src/cpp/webgl2/WebGLTransformFeedback.h +42 -4
  190. package/platforms/ios/src/cpp/webgl2/WebGLVertexArrayObject.h +43 -4
  191. package/platforms/ios/src/module.modulemap +1 -0
  192. package/platforms/ios/src/cpp/CanvasJSIModule.mm +0 -1105
  193. package/platforms/ios/src/cpp/ImageAssetImpl.mm +0 -417
  194. package/platforms/ios/src/cpp/ImageBitmapImpl.mm +0 -126
  195. package/platforms/ios/src/cpp/RafImpl.mm +0 -10
  196. package/platforms/ios/src/cpp/TextDecoderImpl.mm +0 -97
  197. package/platforms/ios/src/cpp/TextEncoderImpl.mm +0 -60
  198. package/platforms/ios/src/cpp/VecMutableBuffer.h +0 -46
  199. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.cc +0 -6156
  200. package/platforms/ios/src/cpp/canvas-cxx/src/lib.rs.h +0 -2867
  201. package/platforms/ios/src/cpp/canvas2d/CanvasGradient.mm +0 -42
  202. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.mm +0 -49
  203. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.mm +0 -1972
  204. package/platforms/ios/src/cpp/canvas2d/ImageDataImpl.mm +0 -68
  205. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.mm +0 -149
  206. package/platforms/ios/src/cpp/canvas2d/Path2D.mm +0 -335
  207. package/platforms/ios/src/cpp/canvas2d/TextMetricsImpl.mm +0 -68
  208. package/platforms/ios/src/cpp/rust/cxx.cc +0 -793
  209. package/platforms/ios/src/cpp/rust/cxx.h +0 -1111
  210. package/platforms/ios/src/cpp/webgl/WebGLActiveInfoImpl.mm +0 -39
  211. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.mm +0 -5958
  212. package/platforms/ios/src/cpp/webgl/WebGLShaderPrecisionFormatImpl.mm +0 -40
  213. package/platforms/ios/src/cpp/webgl/extensions/ANGLE_instanced_arraysImpl.mm +0 -108
  214. package/platforms/ios/src/cpp/webgl/extensions/EXT_blend_minmaxImpl.mm +0 -28
  215. package/platforms/ios/src/cpp/webgl/extensions/EXT_color_buffer_half_floatImpl.mm +0 -42
  216. package/platforms/ios/src/cpp/webgl/extensions/EXT_disjoint_timer_queryImpl.mm +0 -295
  217. package/platforms/ios/src/cpp/webgl/extensions/EXT_sRGBImpl.mm +0 -40
  218. package/platforms/ios/src/cpp/webgl/extensions/EXT_texture_filter_anisotropicImpl.mm +0 -37
  219. package/platforms/ios/src/cpp/webgl/extensions/OES_element_index_uintImpl.mm +0 -28
  220. package/platforms/ios/src/cpp/webgl/extensions/OES_standard_derivativesImpl.mm +0 -31
  221. package/platforms/ios/src/cpp/webgl/extensions/OES_texture_half_floatImpl.mm +0 -28
  222. package/platforms/ios/src/cpp/webgl/extensions/OES_vertex_array_objectImpl.mm +0 -127
  223. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_color_buffer_floatImpl.mm +0 -45
  224. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_atcImpl.mm +0 -45
  225. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etc1Impl.mm +0 -31
  226. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_etcImpl.mm +0 -70
  227. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_pvrtcImpl.mm +0 -47
  228. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tcImpl.mm +0 -46
  229. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_compressed_texture_s3tc_srgbImpl.mm +0 -49
  230. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_depth_textureImpl.mm +0 -30
  231. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_draw_buffersImpl.mm +0 -177
  232. package/platforms/ios/src/cpp/webgl/extensions/WEBGL_lose_contextImpl.mm +0 -64
  233. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.mm +0 -4551
  234. /package/platforms/ios/src/cpp/{OnRafCallback.mm → OnRafCallback.cpp} +0 -0
@@ -0,0 +1,4517 @@
1
+ //
2
+ // Created by Osei Fortune on 22/03/2022.
3
+ //
4
+
5
+ #include "WebGL2RenderingContext.h"
6
+
7
+ WebGL2RenderingContext::WebGL2RenderingContext(WebGLState* state) : WebGLRenderingContext(
8
+ state, WebGLRenderingVersion::V2) {
9
+ }
10
+
11
+
12
+ WebGL2RenderingContext::WebGL2RenderingContext(WebGLState* state,
13
+ WebGLRenderingVersion version)
14
+ : WebGLRenderingContext(state, version) {
15
+ }
16
+
17
+
18
+ v8::Local<v8::FunctionTemplate> WebGL2RenderingContext::GetCtor(v8::Isolate *isolate) {
19
+ auto cache = Caches::Get(isolate);
20
+ auto ctor = cache->WebGL2RenderingContextTmpl.get();
21
+ if (ctor != nullptr) {
22
+ return ctor->Get(isolate);
23
+ }
24
+
25
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate);
26
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
27
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "WebGL2RenderingContext"));
28
+
29
+ auto tmpl = ctorTmpl->InstanceTemplate();
30
+ tmpl->SetInternalFieldCount(1);
31
+ WebGLRenderingContext::SetConstants(isolate, tmpl);
32
+ SetConstants(isolate, tmpl);
33
+
34
+ WebGLRenderingContext::SetMethods(isolate, tmpl);
35
+ SetMethods(isolate, tmpl);
36
+
37
+ WebGLRenderingContext::SetProps(isolate, tmpl);
38
+ SetProps(isolate, tmpl);
39
+ cache->WebGL2RenderingContextTmpl =
40
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
41
+ return ctorTmpl;
42
+ }
43
+
44
+ WebGL2RenderingContext *WebGL2RenderingContext::GetPointer(const v8::Local<v8::Object> &object) {
45
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
46
+ if (ptr == nullptr) {
47
+ return nullptr;
48
+ }
49
+ return static_cast<WebGL2RenderingContext *>(ptr);
50
+ }
51
+
52
+ void WebGL2RenderingContext::BeginQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
53
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
54
+ if (ptr == nullptr) {
55
+ return;
56
+ }
57
+
58
+ auto isolate = args.GetIsolate();
59
+ auto context = isolate->GetCurrentContext();
60
+
61
+ auto value = args[1];
62
+ auto type = GetNativeType(isolate, value);
63
+ if (type == NativeType::WebGLQuery) {
64
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
65
+ auto query = WebGLQuery::GetPointer(value.As<v8::Object>());
66
+
67
+ if (query != nullptr) {
68
+ canvas_native_webgl2_begin_query(
69
+ target,
70
+ query->GetQuery(),
71
+ ptr->GetState()
72
+ );
73
+ }
74
+ }
75
+ }
76
+
77
+ void
78
+ WebGL2RenderingContext::BeginTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
79
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
80
+ if (ptr == nullptr) {
81
+ return;
82
+ }
83
+
84
+ auto isolate = args.GetIsolate();
85
+ auto context = isolate->GetCurrentContext();
86
+
87
+ auto value = args[0];
88
+ if (value->IsNumber()) {
89
+ canvas_native_webgl2_begin_transform_feedback(
90
+ (uint32_t) args[0]->NumberValue(context).ToChecked(),
91
+ ptr->GetState()
92
+ );
93
+ }
94
+ }
95
+
96
+ void WebGL2RenderingContext::BindBufferBase(const v8::FunctionCallbackInfo<v8::Value> &args) {
97
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
98
+ if (ptr == nullptr) {
99
+ return;
100
+ }
101
+
102
+ auto isolate = args.GetIsolate();
103
+ auto context = isolate->GetCurrentContext();
104
+
105
+ auto bufferValue = args[2];
106
+ auto type = GetNativeType(isolate, bufferValue);
107
+
108
+ if (type == NativeType::WebGLBuffer) {
109
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
110
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
111
+
112
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
113
+
114
+ canvas_native_webgl2_bind_buffer_base(
115
+ target,
116
+ index,
117
+ buffer->GetBuffer(),
118
+ ptr->GetState()
119
+ );
120
+ }
121
+ }
122
+
123
+ void WebGL2RenderingContext::BindBufferRange(const v8::FunctionCallbackInfo<v8::Value> &args) {
124
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
125
+ if (ptr == nullptr) {
126
+ return;
127
+ }
128
+
129
+ auto isolate = args.GetIsolate();
130
+ auto context = isolate->GetCurrentContext();
131
+
132
+ auto bufferValue = args[2];
133
+ auto type = GetNativeType(isolate, bufferValue);
134
+ if (args.Length() > 4 && type == NativeType::WebGLBuffer) {
135
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
136
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
137
+ auto offset = args[3]->NumberValue(context).ToChecked();
138
+ auto size = args[4]->NumberValue(context).ToChecked();
139
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
140
+ canvas_native_webgl2_bind_buffer_range(
141
+ target,
142
+ index,
143
+ buffer->GetBuffer(),
144
+ static_cast<ssize_t>(offset),
145
+ static_cast<ssize_t>(size),
146
+ ptr->GetState()
147
+ );
148
+ }
149
+ }
150
+
151
+ void WebGL2RenderingContext::BindSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
152
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
153
+ if (ptr == nullptr) {
154
+ return;
155
+ }
156
+
157
+ auto isolate = args.GetIsolate();
158
+ auto context = isolate->GetCurrentContext();
159
+
160
+ auto samplerValue = args[1];
161
+ auto type = GetNativeType(isolate, samplerValue);
162
+ if (type == NativeType::WebGLSampler) {
163
+ auto unit = (uint32_t) args[0]->NumberValue(context).ToChecked();
164
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
165
+
166
+ canvas_native_webgl2_bind_sampler(
167
+ unit,
168
+ sampler->GetSampler(),
169
+ ptr->GetState()
170
+ );
171
+ }
172
+ }
173
+
174
+ void
175
+ WebGL2RenderingContext::BindTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
176
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
177
+ if (ptr == nullptr) {
178
+ return;
179
+ }
180
+
181
+ auto isolate = args.GetIsolate();
182
+ auto context = isolate->GetCurrentContext();
183
+
184
+ auto transformFeedbackValue = args[1];
185
+ auto type = GetNativeType(isolate, transformFeedbackValue);
186
+
187
+ if (type == NativeType::WebGLTransformFeedback) {
188
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
189
+ auto transformFeedback = WebGLTransformFeedback::GetPointer(
190
+ transformFeedbackValue.As<v8::Object>());
191
+
192
+ canvas_native_webgl2_bind_transform_feedback(
193
+ target,
194
+ transformFeedback->GetFeedback(),
195
+ ptr->GetState()
196
+ );
197
+ }
198
+ }
199
+
200
+ void WebGL2RenderingContext::BindVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
201
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
202
+ if (ptr == nullptr) {
203
+ return;
204
+ }
205
+
206
+ auto isolate = args.GetIsolate();
207
+
208
+ auto value = args[0];
209
+ if (value->IsNull()) {
210
+ canvas_native_webgl2_bind_vertex_array(
211
+ 0,
212
+ ptr->GetState()
213
+ );
214
+ return;
215
+ }
216
+
217
+ auto type = GetNativeType(isolate, value);
218
+ if (type == NativeType::WebGLVertexArrayObject) {
219
+ auto vertexArray = WebGLVertexArrayObject::GetPointer(value.As<v8::Object>());
220
+
221
+ if (vertexArray != nullptr) {
222
+ canvas_native_webgl2_bind_vertex_array(
223
+ vertexArray->GetVertexArrayObject(),
224
+ ptr->GetState()
225
+ );
226
+ }
227
+ }
228
+ }
229
+
230
+ void WebGL2RenderingContext::BlitFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
231
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
232
+ if (ptr == nullptr) {
233
+ return;
234
+ }
235
+
236
+ auto isolate = args.GetIsolate();
237
+ auto context = isolate->GetCurrentContext();
238
+
239
+ if (args.Length() > 9) {
240
+ auto srcX0 = (int32_t) args[0]->NumberValue(context).ToChecked();
241
+ auto srcY0 = (int32_t) args[1]->NumberValue(context).ToChecked();
242
+
243
+ auto srcX1 = (int32_t) args[2]->NumberValue(context).ToChecked();
244
+ auto srcY1 = (int32_t) args[3]->NumberValue(context).ToChecked();
245
+
246
+ auto dstX0 = (int32_t) args[4]->NumberValue(context).ToChecked();
247
+ auto dstY0 = (int32_t) args[5]->NumberValue(context).ToChecked();
248
+
249
+ auto dstX1 = (int32_t) args[6]->NumberValue(context).ToChecked();
250
+ auto dstY1 = (int32_t) args[7]->NumberValue(context).ToChecked();
251
+
252
+ auto mask = (uint32_t) args[8]->NumberValue(context).ToChecked();
253
+ auto filter = (uint32_t) args[9]->NumberValue(context).ToChecked();
254
+ canvas_native_webgl2_blit_framebuffer(
255
+ srcX0,
256
+ srcY0,
257
+ srcX1,
258
+ srcY1,
259
+ dstX0,
260
+ dstY0,
261
+ dstX1,
262
+ dstY1,
263
+ mask,
264
+ filter,
265
+ ptr->GetState()
266
+ );
267
+ }
268
+ }
269
+
270
+ void WebGL2RenderingContext::ClearBufferfv(const v8::FunctionCallbackInfo<v8::Value> &args) {
271
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
272
+ if (ptr == nullptr) {
273
+ return;
274
+ }
275
+
276
+ auto isolate = args.GetIsolate();
277
+ auto context = isolate->GetCurrentContext();
278
+
279
+ auto bufferValue = args[0];
280
+ auto type = GetNativeType(isolate, bufferValue);
281
+ auto values = args[2];
282
+ if (args.Length() > 2 && type == NativeType::WebGLBuffer &&
283
+ args[1]->IsObject()) {
284
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
285
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
286
+ if (values->IsArray()) {
287
+ auto array = values.As<v8::Array>();
288
+ auto len = array->Length();
289
+ std::vector<float> buf;
290
+ buf.reserve(len);
291
+ for (int j = 0; j < len; ++j) {
292
+ auto item = array->Get(
293
+ context, j).ToLocalChecked();
294
+ if (!item->IsNumber()) {
295
+ buf.push_back(
296
+ std::nanf(""));
297
+ } else {
298
+ buf.push_back(
299
+ static_cast<float>(item->NumberValue(context).ToChecked())
300
+ );
301
+ }
302
+ }
303
+
304
+ canvas_native_webgl2_clear_bufferfv(
305
+ buffer->GetBuffer(),
306
+ drawbuffer,
307
+ buf.data(),
308
+ buf.size(),
309
+ ptr->GetState()
310
+ );
311
+
312
+ } else if (values->IsFloat32Array()) {
313
+ auto buf = values.As<v8::Float32Array>();
314
+ auto array = buf->Buffer();
315
+ auto offset = buf->ByteOffset();
316
+ auto size = buf->Length();
317
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
318
+ auto data = static_cast<float *>((void*) data_ptr);
319
+
320
+
321
+ canvas_native_webgl2_clear_bufferfv(
322
+ buffer->GetBuffer(),
323
+ drawbuffer,
324
+ data,
325
+ size,
326
+ ptr->GetState()
327
+ );
328
+ }
329
+ }
330
+ }
331
+
332
+ void WebGL2RenderingContext::ClearBufferiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
333
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
334
+ if (ptr == nullptr) {
335
+ return;
336
+ }
337
+
338
+ auto isolate = args.GetIsolate();
339
+ auto context = isolate->GetCurrentContext();
340
+
341
+ auto bufferValue = args[0];
342
+ auto type = GetNativeType(isolate, bufferValue);
343
+ auto values = args[2];
344
+ if (args.Length() > 2 && type == NativeType::WebGLBuffer &&
345
+ args[1]->IsObject()) {
346
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
347
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
348
+ if (values->IsArray()) {
349
+ auto array = values.As<v8::Array>();
350
+ auto len = array->Length();
351
+ std::vector<int32_t> buf;
352
+ buf.reserve(len);
353
+ for (int j = 0; j < len; ++j) {
354
+ auto item = array->Get(
355
+ context, j).ToLocalChecked();
356
+ buf.push_back(
357
+ static_cast<int32_t>(item->NumberValue(context).ToChecked())
358
+ );
359
+ }
360
+
361
+
362
+ canvas_native_webgl2_clear_bufferiv(
363
+ buffer->GetBuffer(),
364
+ drawbuffer,
365
+ buf.data(),
366
+ buf.size(),
367
+ ptr->GetState()
368
+ );
369
+
370
+ } else if (values->IsInt32Array()) {
371
+ auto buf = values.As<v8::Int32Array>();
372
+
373
+ auto array = buf->Buffer();
374
+ auto offset = buf->ByteOffset();
375
+ auto size = buf->Length();
376
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
377
+ auto data = static_cast<int32_t *>((void*) data_ptr);
378
+
379
+
380
+
381
+
382
+ canvas_native_webgl2_clear_bufferiv(
383
+ buffer->GetBuffer(),
384
+ drawbuffer,
385
+ data,
386
+ size,
387
+ ptr->GetState()
388
+ );
389
+ }
390
+ }
391
+ }
392
+
393
+ void WebGL2RenderingContext::ClearBufferfi(const v8::FunctionCallbackInfo<v8::Value> &args) {
394
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
395
+ if (ptr == nullptr) {
396
+ return;
397
+ }
398
+
399
+ auto isolate = args.GetIsolate();
400
+ auto context = isolate->GetCurrentContext();
401
+
402
+ auto bufferValue = args[0];
403
+ auto type = GetNativeType(isolate, bufferValue);
404
+ if (args.Length() > 3 && type == NativeType::WebGLBuffer) {
405
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
406
+ if (buffer != nullptr) {
407
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
408
+ auto depth = args[2]->NumberValue(context).ToChecked();
409
+ auto stencil = (int32_t) args[3]->NumberValue(context).ToChecked();
410
+ canvas_native_webgl2_clear_bufferfi(
411
+ buffer->GetBuffer(),
412
+ drawbuffer,
413
+ static_cast<float>(depth),
414
+ stencil,
415
+ ptr->GetState()
416
+ );
417
+ }
418
+ }
419
+ }
420
+
421
+ void WebGL2RenderingContext::ClearBufferuiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
422
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
423
+ if (ptr == nullptr) {
424
+ return;
425
+ }
426
+
427
+ auto isolate = args.GetIsolate();
428
+ auto context = isolate->GetCurrentContext();
429
+
430
+ auto bufferValue = args[0];
431
+ auto type = GetNativeType(isolate, bufferValue);
432
+ auto values = args[2];
433
+ if (args.Length() > 2 && type == NativeType::WebGLBuffer &&
434
+ args[1]->IsObject()) {
435
+ auto drawbuffer = (int32_t) args[1]->NumberValue(context).ToChecked();
436
+ auto buffer = WebGLBuffer::GetPointer(bufferValue.As<v8::Object>());
437
+ if (values->IsArray()) {
438
+ auto array = values.As<v8::Array>();
439
+ auto len = array->Length();
440
+ std::vector<uint32_t> buf;
441
+ buf.reserve(len);
442
+ for (int j = 0; j < len; ++j) {
443
+ auto item = array->Get(
444
+ context, j).ToLocalChecked();
445
+ buf.push_back(
446
+ static_cast<uint32_t>(item->NumberValue(context).ToChecked())
447
+ );
448
+ }
449
+
450
+
451
+ canvas_native_webgl2_clear_bufferuiv(
452
+ buffer->GetBuffer(),
453
+ drawbuffer,
454
+ buf.data(),
455
+ buf.size(),
456
+ ptr->GetState()
457
+ );
458
+
459
+ } else if (values->IsUint32Array()) {
460
+ auto buf = values.As<v8::Uint32Array>();
461
+ auto array = buf->Buffer();
462
+ auto offset = buf->ByteOffset();
463
+ auto size = buf->Length();
464
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
465
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
466
+
467
+
468
+
469
+ canvas_native_webgl2_clear_bufferuiv(
470
+ buffer->GetBuffer(),
471
+ drawbuffer,
472
+ data, size,
473
+ ptr->GetState()
474
+ );
475
+ }
476
+ }
477
+ }
478
+
479
+ void WebGL2RenderingContext::ClientWaitSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
480
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
481
+ if (ptr == nullptr) {
482
+ return;
483
+ }
484
+
485
+ auto isolate = args.GetIsolate();
486
+ auto context = isolate->GetCurrentContext();
487
+
488
+ auto syncValue = args[0];
489
+ auto type = GetNativeType(isolate, syncValue);
490
+ if (args.Length() > 2 && type == NativeType::WebGLSync) {
491
+ auto sync = WebGLSyncImpl::GetPointer(syncValue.As<v8::Object>());
492
+ if (sync != nullptr) {
493
+ auto flags = (uint32_t) args[1]->NumberValue(context).ToChecked();
494
+ auto timeout = args[2]->NumberValue(context).ToChecked();
495
+ auto ret = canvas_native_webgl2_client_wait_sync(
496
+ sync->GetSync(),
497
+ flags,
498
+ static_cast<ssize_t>(timeout),
499
+ ptr->GetState()
500
+ );
501
+
502
+ args.GetReturnValue().Set((int32_t) ret);
503
+ return;
504
+ }
505
+ }
506
+ // todo decide if WAIT_FAILED should be returned here
507
+ args.GetReturnValue().SetUndefined();
508
+ }
509
+
510
+ void
511
+ WebGL2RenderingContext::CompressedTexSubImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
512
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
513
+ if (ptr == nullptr) {
514
+ return;
515
+ }
516
+
517
+ auto isolate = args.GetIsolate();
518
+ auto context = isolate->GetCurrentContext();
519
+
520
+ if (args.Length() > 8) {
521
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
522
+ auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
523
+ auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
524
+ auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
525
+ auto zoffset = (int32_t) args[4]->NumberValue(context).ToChecked();
526
+ auto width = (int32_t) args[5]->NumberValue(context).ToChecked();
527
+ auto height = (int32_t) args[6]->NumberValue(context).ToChecked();
528
+ auto depth = (int32_t) args[7]->NumberValue(context).ToChecked();
529
+ auto format = (uint32_t) args[8]->NumberValue(context).ToChecked();
530
+
531
+ auto imageSizeOrBufValue = args[0];
532
+ if (args[9]->IsObject()) {
533
+ if (imageSizeOrBufValue->IsArrayBufferView()) {
534
+ auto buf = imageSizeOrBufValue.As<v8::ArrayBufferView>();
535
+ auto array = buf->Buffer();
536
+ auto offset = buf->ByteOffset();
537
+ auto size = buf->ByteLength();
538
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
539
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
540
+
541
+ size_t srcOffset = 0;
542
+ if (args[10]->IsNumber()) {
543
+ srcOffset = static_cast<size_t>(args[10]->NumberValue(context).ToChecked());
544
+ }
545
+ size_t srcLengthOverride = 0;
546
+ if (args[11]->IsNumber()) {
547
+ srcLengthOverride = static_cast<size_t>(args[11]->NumberValue(
548
+ context).ToChecked());
549
+ }
550
+
551
+
552
+ canvas_native_webgl2_compressed_tex_sub_image3d(
553
+ target,
554
+ level,
555
+ xoffset,
556
+ yoffset,
557
+ zoffset,
558
+ width,
559
+ height,
560
+ depth,
561
+ format,
562
+ data,
563
+ size,
564
+ srcOffset,
565
+ srcLengthOverride,
566
+ ptr->GetState()
567
+ );
568
+ }
569
+ } else {
570
+ auto imageSizeOrBuf = (int32_t) imageSizeOrBufValue->NumberValue(context).ToChecked();
571
+ auto offset = 0;
572
+ if (args[10]->IsNumber()) {
573
+ offset = (int32_t) args[10]->NumberValue(context).ToChecked();
574
+ }
575
+ canvas_native_webgl2_compressed_tex_sub_image3d_none(
576
+ target,
577
+ level,
578
+ xoffset,
579
+ yoffset,
580
+ zoffset,
581
+ width,
582
+ height,
583
+ depth,
584
+ format,
585
+ imageSizeOrBuf,
586
+ offset,
587
+ ptr->GetState()
588
+ );
589
+ }
590
+ }
591
+ }
592
+
593
+ void WebGL2RenderingContext::CopyBufferSubData(const v8::FunctionCallbackInfo<v8::Value> &args) {
594
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
595
+ if (ptr == nullptr) {
596
+ return;
597
+ }
598
+
599
+ auto isolate = args.GetIsolate();
600
+ auto context = isolate->GetCurrentContext();
601
+
602
+ if (args.Length() > 4) {
603
+ auto readTarget = (uint32_t) args[0]->NumberValue(context).ToChecked();
604
+ auto writeTarget = (uint32_t) args[1]->NumberValue(context).ToChecked();
605
+ auto readOffset = args[2]->NumberValue(context).ToChecked();
606
+ auto writeOffset = args[3]->NumberValue(context).ToChecked();
607
+ auto size = args[4]->NumberValue(context).ToChecked();
608
+ canvas_native_webgl2_copy_buffer_sub_data(
609
+ readTarget,
610
+ writeTarget,
611
+ static_cast<ssize_t>(readOffset),
612
+ static_cast<ssize_t>(writeOffset),
613
+ static_cast<ssize_t>(size),
614
+ ptr->GetState()
615
+ );
616
+ }
617
+ }
618
+
619
+ void WebGL2RenderingContext::CopyTexSubImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
620
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
621
+ if (ptr == nullptr) {
622
+ return;
623
+ }
624
+
625
+ auto isolate = args.GetIsolate();
626
+ auto context = isolate->GetCurrentContext();
627
+
628
+ if (args.Length() > 8) {
629
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
630
+ auto level = (int32_t) args[1]->NumberValue(context).ToChecked();
631
+ auto xoffset = (int32_t) args[2]->NumberValue(context).ToChecked();
632
+ auto yoffset = (int32_t) args[3]->NumberValue(context).ToChecked();
633
+ auto zoffset = (int32_t) args[4]->NumberValue(context).ToChecked();
634
+ auto x = (int32_t) args[5]->NumberValue(context).ToChecked();
635
+ auto y = (int32_t) args[6]->NumberValue(context).ToChecked();
636
+ auto width = (int32_t) args[7]->NumberValue(context).ToChecked();
637
+ auto height = (int32_t) args[8]->NumberValue(context).ToChecked();
638
+ canvas_native_webgl2_copy_tex_sub_image3d(
639
+ target,
640
+ level,
641
+ xoffset,
642
+ yoffset,
643
+ zoffset,
644
+ x,
645
+ y,
646
+ width,
647
+ height,
648
+ ptr->GetState()
649
+ );
650
+ }
651
+ }
652
+
653
+ void WebGL2RenderingContext::CreateQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
654
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
655
+ if (ptr == nullptr) {
656
+ args.GetReturnValue().SetUndefined();
657
+ return;
658
+ }
659
+
660
+ auto isolate = args.GetIsolate();
661
+
662
+ auto ret = canvas_native_webgl2_create_query(
663
+ ptr->GetState());
664
+ auto query = WebGLQuery::NewInstance(isolate, new WebGLQuery(ret));
665
+
666
+ args.GetReturnValue().Set(query);
667
+ }
668
+
669
+ void WebGL2RenderingContext::CreateSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
670
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
671
+ if (ptr == nullptr) {
672
+ args.GetReturnValue().SetUndefined();
673
+ return;
674
+ }
675
+
676
+ auto isolate = args.GetIsolate();
677
+
678
+ auto ret = canvas_native_webgl2_create_sampler(
679
+ ptr->GetState());
680
+ auto sampler = WebGLSampler::NewInstance(isolate, new WebGLSampler(ret));
681
+
682
+ args.GetReturnValue().Set(sampler);
683
+ }
684
+
685
+ void
686
+ WebGL2RenderingContext::CreateTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
687
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
688
+ if (ptr == nullptr) {
689
+ args.GetReturnValue().SetUndefined();
690
+ return;
691
+ }
692
+
693
+ auto isolate = args.GetIsolate();
694
+
695
+ auto ret = canvas_native_webgl2_create_transform_feedback(
696
+ ptr->GetState());
697
+
698
+ auto feedback = WebGLTransformFeedback::NewInstance(isolate, new WebGLTransformFeedback(
699
+ ret));
700
+
701
+ args.GetReturnValue().Set(feedback);
702
+ }
703
+
704
+ void WebGL2RenderingContext::CreateVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
705
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
706
+ if (ptr == nullptr) {
707
+ args.GetReturnValue().SetUndefined();
708
+ return;
709
+ }
710
+
711
+ auto isolate = args.GetIsolate();
712
+
713
+ auto ret = canvas_native_webgl2_create_vertex_array(
714
+ ptr->GetState());
715
+
716
+ auto vertexArrayObject = WebGLVertexArrayObject::NewInstance(isolate,
717
+ new WebGLVertexArrayObject(ret));
718
+
719
+ args.GetReturnValue().Set(vertexArrayObject);
720
+ }
721
+
722
+ void WebGL2RenderingContext::DeleteQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
723
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
724
+ if (ptr == nullptr) {
725
+ return;
726
+ }
727
+
728
+ auto isolate = args.GetIsolate();
729
+
730
+ auto queryValue = args[0];
731
+ auto type = GetNativeType(isolate, queryValue);
732
+ if (type == NativeType::WebGLQuery) {
733
+ auto query = WebGLQuery::GetPointer(queryValue.As<v8::Object>());
734
+
735
+ if (query != nullptr) {
736
+ canvas_native_webgl2_delete_query_with_query(
737
+ query->GetQuery(),
738
+ ptr->GetState()
739
+ );
740
+ }
741
+ }
742
+ }
743
+
744
+ void WebGL2RenderingContext::DeleteSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
745
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
746
+ if (ptr == nullptr) {
747
+ return;
748
+ }
749
+
750
+ auto isolate = args.GetIsolate();
751
+
752
+
753
+ auto samplerValue = args[0];
754
+ auto type = GetNativeType(isolate, samplerValue);
755
+
756
+ if (type == NativeType::WebGLSampler) {
757
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
758
+
759
+ if (sampler != nullptr) {
760
+ canvas_native_webgl2_delete_sampler_with_sampler(
761
+ sampler->GetSampler(),
762
+ ptr->GetState()
763
+ );
764
+ }
765
+ }
766
+ }
767
+
768
+ void WebGL2RenderingContext::DeleteSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
769
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
770
+ if (ptr == nullptr) {
771
+ return;
772
+ }
773
+
774
+ auto isolate = args.GetIsolate();
775
+
776
+
777
+ auto syncValue = args[0];
778
+ auto type = GetNativeType(isolate, syncValue);
779
+ if (type == NativeType::WebGLSync) {
780
+ auto sync = WebGLSyncImpl::GetPointer(syncValue.As<v8::Object>());
781
+
782
+ if (sync != nullptr) {
783
+ canvas_native_webgl2_delete_sync_with_sync(
784
+ sync->GetSync(),
785
+ ptr->GetState()
786
+ );
787
+ }
788
+ }
789
+ }
790
+
791
+ void
792
+ WebGL2RenderingContext::DeleteTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
793
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
794
+ if (ptr == nullptr) {
795
+ return;
796
+ }
797
+
798
+ auto isolate = args.GetIsolate();
799
+
800
+
801
+ auto transformFeedbackValue = args[0];
802
+ auto type = GetNativeType(isolate, transformFeedbackValue);
803
+ if (type == NativeType::WebGLTransformFeedback) {
804
+ auto transformFeedback = WebGLTransformFeedback::GetPointer(
805
+ transformFeedbackValue.As<v8::Object>());
806
+
807
+ if (transformFeedback != nullptr) {
808
+ canvas_native_webgl2_delete_transform_feedback(
809
+ transformFeedback->GetFeedback(),
810
+ ptr->GetState()
811
+ );
812
+ }
813
+ }
814
+ }
815
+
816
+ void WebGL2RenderingContext::DeleteVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
817
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
818
+ if (ptr == nullptr) {
819
+ return;
820
+ }
821
+
822
+ auto isolate = args.GetIsolate();
823
+
824
+
825
+ auto vertexArrayValue = args[0];
826
+ auto type = GetNativeType(isolate, vertexArrayValue);
827
+ if (type == NativeType::WebGLVertexArrayObject) {
828
+
829
+ auto vertexArray = WebGLVertexArrayObject::GetPointer(vertexArrayValue.As<v8::Object>());
830
+ if (vertexArray != nullptr) {
831
+ canvas_native_webgl2_delete_vertex_array_with_vertex_array(
832
+ vertexArray->GetVertexArrayObject(),
833
+ ptr->GetState()
834
+ );
835
+ }
836
+ }
837
+ }
838
+
839
+ void WebGL2RenderingContext::DrawArraysInstanced(const v8::FunctionCallbackInfo<v8::Value> &args) {
840
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
841
+ if (ptr == nullptr) {
842
+ return;
843
+ }
844
+
845
+ auto isolate = args.GetIsolate();
846
+ auto context = isolate->GetCurrentContext();
847
+
848
+ if (args.Length() > 3) {
849
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
850
+ auto first = (int32_t) args[1]->NumberValue(context).ToChecked();
851
+ auto count_ = (int32_t) args[2]->NumberValue(context).ToChecked();
852
+ auto instanceCount = (int32_t) args[3]->NumberValue(context).ToChecked();
853
+ canvas_native_webgl2_draw_arrays_instanced(
854
+ mode,
855
+ first,
856
+ count_,
857
+ instanceCount,
858
+ ptr->GetState()
859
+ );
860
+
861
+ ptr->UpdateInvalidateState();
862
+ }
863
+ }
864
+
865
+ void WebGL2RenderingContext::DrawBuffers(const v8::FunctionCallbackInfo<v8::Value> &args) {
866
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
867
+ if (ptr == nullptr) {
868
+ return;
869
+ }
870
+
871
+ auto isolate = args.GetIsolate();
872
+ auto context = isolate->GetCurrentContext();
873
+
874
+ auto buffersObject = args[0];
875
+ if (buffersObject->IsArray()) {
876
+ auto array = buffersObject.As<v8::Array>();
877
+ auto len = array->Length();
878
+ std::vector<uint32_t> buf;
879
+ buf.reserve(len);
880
+ for (int j = 0; j < len; ++j) {
881
+ auto item = array->Get(
882
+ context, j).ToLocalChecked();
883
+ buf.emplace_back(
884
+ (uint32_t) item->NumberValue(context).ToChecked());
885
+ }
886
+
887
+ canvas_native_webgl2_draw_buffers(
888
+ buf.data(), buf.size(),
889
+ ptr->GetState());
890
+ }
891
+ }
892
+
893
+ void
894
+ WebGL2RenderingContext::DrawElementsInstanced(const v8::FunctionCallbackInfo<v8::Value> &args) {
895
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
896
+ if (ptr == nullptr) {
897
+ return;
898
+ }
899
+
900
+ auto isolate = args.GetIsolate();
901
+ auto context = isolate->GetCurrentContext();
902
+
903
+ if (args.Length() > 4) {
904
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
905
+ auto count_ = (int32_t) args[1]->NumberValue(context).ToChecked();
906
+ auto type = (uint32_t) args[2]->NumberValue(context).ToChecked();
907
+ auto offset = args[3]->NumberValue(context).ToChecked();
908
+ auto instanceCount = (int32_t) args[4]->NumberValue(context).ToChecked();
909
+ canvas_native_webgl2_draw_elements_instanced(
910
+ mode,
911
+ count_,
912
+ type,
913
+ static_cast<ssize_t>(offset),
914
+ instanceCount,
915
+ ptr->GetState()
916
+ );
917
+
918
+ ptr->UpdateInvalidateState();
919
+ }
920
+ }
921
+
922
+ void WebGL2RenderingContext::DrawRangeElements(const v8::FunctionCallbackInfo<v8::Value> &args) {
923
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
924
+ if (ptr == nullptr) {
925
+ return;
926
+ }
927
+
928
+ auto isolate = args.GetIsolate();
929
+ auto context = isolate->GetCurrentContext();
930
+
931
+ if (args.Length() > 5) {
932
+ auto mode = (uint32_t) args[0]->NumberValue(context).ToChecked();
933
+ auto start = (uint32_t) args[1]->NumberValue(context).ToChecked();
934
+ auto end = (uint32_t) args[2]->NumberValue(context).ToChecked();
935
+ auto count_ = (int32_t) args[3]->NumberValue(context).ToChecked();
936
+ auto type = (uint32_t) args[4]->NumberValue(context).ToChecked();
937
+ auto offset = args[5]->NumberValue(context).ToChecked();
938
+ canvas_native_webgl2_draw_range_elements(
939
+ mode,
940
+ start,
941
+ end,
942
+ count_,
943
+ type,
944
+ static_cast<ssize_t>(offset),
945
+ ptr->GetState()
946
+ );
947
+
948
+ ptr->UpdateInvalidateState();
949
+ }
950
+ }
951
+
952
+ void WebGL2RenderingContext::EndQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
953
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
954
+ if (ptr == nullptr) {
955
+ return;
956
+ }
957
+
958
+ auto isolate = args.GetIsolate();
959
+ auto context = isolate->GetCurrentContext();
960
+
961
+ if (args[0]->IsNumber()) {
962
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
963
+ canvas_native_webgl2_end_query(target,
964
+ ptr->GetState());
965
+ }
966
+ }
967
+
968
+ void WebGL2RenderingContext::EndTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
969
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
970
+ if (ptr == nullptr) {
971
+ return;
972
+ }
973
+
974
+ auto isolate = args.GetIsolate();
975
+
976
+
977
+ canvas_native_webgl2_end_transform_feedback(
978
+ ptr->GetState());
979
+ }
980
+
981
+ void WebGL2RenderingContext::FenceSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
982
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
983
+ if (ptr == nullptr) {
984
+ args.GetReturnValue().SetUndefined();
985
+ return;
986
+ }
987
+
988
+ auto isolate = args.GetIsolate();
989
+ auto context = isolate->GetCurrentContext();
990
+
991
+ if (args.Length() > 1) {
992
+ auto condition = (uint32_t) args[0]->NumberValue(context).ToChecked();
993
+ auto flags = (uint32_t) args[1]->NumberValue(context).ToChecked();
994
+ auto sync = canvas_native_webgl2_fence_sync(
995
+ condition,
996
+ flags,
997
+ ptr->GetState()
998
+ );
999
+ auto ret = WebGLSyncImpl::NewInstance(isolate, new WebGLSyncImpl(std::move(sync)));
1000
+
1001
+ args.GetReturnValue().Set(ret);
1002
+ }
1003
+ }
1004
+
1005
+ void
1006
+ WebGL2RenderingContext::FramebufferTextureLayer(const v8::FunctionCallbackInfo<v8::Value> &args) {
1007
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1008
+ if (ptr == nullptr) {
1009
+ args.GetReturnValue().SetUndefined();
1010
+ return;
1011
+ }
1012
+
1013
+ auto isolate = args.GetIsolate();
1014
+ auto context = isolate->GetCurrentContext();
1015
+
1016
+
1017
+ auto textureValue = args[2];
1018
+ auto type = GetNativeType(isolate, textureValue);
1019
+ if (args.Length() > 4 && type == NativeType::WebGLTexture) {
1020
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1021
+ auto attachment = (uint32_t) args[1]->NumberValue(context).ToChecked();
1022
+ auto texture = WebGLTexture::GetPointer(textureValue.As<v8::Object>());
1023
+ auto level = (int32_t) args[3]->NumberValue(context).ToChecked();
1024
+ auto layer = (int32_t) args[4]->NumberValue(context).ToChecked();
1025
+ if (texture != nullptr) {
1026
+ canvas_native_webgl2_framebuffer_texture_layer(
1027
+ target,
1028
+ attachment,
1029
+ texture->GetTexture(),
1030
+ level,
1031
+ layer,
1032
+ ptr->GetState()
1033
+ );
1034
+ }
1035
+
1036
+ }
1037
+ }
1038
+
1039
+ void
1040
+ WebGL2RenderingContext::GetActiveUniformBlockName(const v8::FunctionCallbackInfo<v8::Value> &args) {
1041
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1042
+ if (ptr == nullptr) {
1043
+ args.GetReturnValue().SetEmptyString();
1044
+ return;
1045
+ }
1046
+
1047
+ auto isolate = args.GetIsolate();
1048
+ auto context = isolate->GetCurrentContext();
1049
+
1050
+ auto programValue = args[0];
1051
+ auto type = GetNativeType(isolate, programValue);
1052
+ if (type == NativeType::WebGLProgram) {
1053
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1054
+ if (program != nullptr) {
1055
+ auto uniformBlockIndex = (uint32_t) args[1]->NumberValue(context).ToChecked();
1056
+ auto name = canvas_native_webgl2_get_active_uniform_block_name(
1057
+ program->GetProgram(),
1058
+ uniformBlockIndex,
1059
+ ptr->GetState()
1060
+ );
1061
+ args.GetReturnValue().Set(ConvertToV8OneByteString(isolate, (char*)name));
1062
+ return;
1063
+ }
1064
+
1065
+ }
1066
+
1067
+ args.GetReturnValue().SetEmptyString();
1068
+ }
1069
+
1070
+ void WebGL2RenderingContext::GetActiveUniformBlockParameter(
1071
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1072
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1073
+ if (ptr == nullptr) {
1074
+ args.GetReturnValue().SetNull();
1075
+ return;
1076
+ }
1077
+
1078
+ auto isolate = args.GetIsolate();
1079
+ auto context = isolate->GetCurrentContext();
1080
+
1081
+ auto programValue = args[0];
1082
+ auto type = GetNativeType(isolate, programValue);
1083
+
1084
+ if (args.Length() > 2 && type == NativeType::WebGLProgram) {
1085
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1086
+
1087
+ if (program != nullptr) {
1088
+ auto uniformBlockIndex = (uint32_t) args[1]->NumberValue(context).ToChecked();
1089
+ auto pname = (uint32_t) args[2]->NumberValue(context).ToChecked();
1090
+ auto ret = canvas_native_webgl2_get_active_uniform_block_parameter(
1091
+ program->GetProgram(),
1092
+ uniformBlockIndex,
1093
+ pname,
1094
+ ptr->GetState()
1095
+ );
1096
+
1097
+ switch (pname) {
1098
+ case GL_UNIFORM_BLOCK_BINDING:
1099
+ case GL_UNIFORM_BLOCK_DATA_SIZE:
1100
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
1101
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1102
+ ret));
1103
+ canvas_native_webgl_WebGLResult_destroy(ret);
1104
+ return;
1105
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: {
1106
+ auto value = canvas_native_webgl_result_get_u32_array(
1107
+ ret);
1108
+
1109
+ auto buf = (uint8_t*)canvas_native_u32_buffer_get_bytes(value);
1110
+ auto size = canvas_native_u32_buffer_get_length(value);
1111
+ auto bytes_size = size * sizeof(uint32_t);
1112
+
1113
+ auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
1114
+ [](void *data, size_t length,
1115
+ void *deleter_data) {
1116
+ if (deleter_data != nullptr) {
1117
+ canvas_native_u32_buffer_destroy((U32Buffer *) deleter_data);
1118
+ }
1119
+ },
1120
+ value);
1121
+
1122
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
1123
+ args.GetReturnValue().Set(v8::Uint32Array::New(arraybuffer, 0, size));
1124
+
1125
+ canvas_native_webgl_WebGLResult_destroy(ret);
1126
+
1127
+ return;
1128
+ }
1129
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
1130
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
1131
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
1132
+ ret));
1133
+
1134
+ canvas_native_webgl_WebGLResult_destroy(ret);
1135
+ return;
1136
+ default:
1137
+ args.GetReturnValue().SetNull();
1138
+ canvas_native_webgl_WebGLResult_destroy(ret);
1139
+ return;
1140
+ }
1141
+ }
1142
+ }
1143
+ }
1144
+
1145
+ void WebGL2RenderingContext::GetActiveUniforms(const v8::FunctionCallbackInfo<v8::Value> &args) {
1146
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1147
+ if (ptr == nullptr) {
1148
+ args.GetReturnValue().SetNull();
1149
+ return;
1150
+ }
1151
+
1152
+ auto isolate = args.GetIsolate();
1153
+ auto context = isolate->GetCurrentContext();
1154
+
1155
+ auto programValue = args[0];
1156
+ auto type = GetNativeType(isolate, programValue);
1157
+ if (args.Length() > 2 && type == NativeType::WebGLProgram) {
1158
+
1159
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1160
+ auto uniformIndicesObject = args[1];
1161
+ auto pname = (uint32_t) args[2]->NumberValue(context).ToChecked();
1162
+
1163
+ if (uniformIndicesObject->IsArray()) {
1164
+ auto uniformIndices = uniformIndicesObject.As<v8::Array>();
1165
+ auto size = uniformIndices->Length();
1166
+ std::vector<uint32_t> buf;
1167
+ buf.reserve(size);
1168
+ for (int j = 0; j < size; j++) {
1169
+ auto item = (uint32_t) uniformIndices->Get(
1170
+ context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1171
+ buf.emplace_back(item);
1172
+ }
1173
+
1174
+ auto ret = canvas_native_webgl2_get_active_uniforms(
1175
+ program->GetProgram(),
1176
+ buf.data(), buf.size(),
1177
+ pname,
1178
+ ptr->GetState()
1179
+ );
1180
+
1181
+ switch (pname) {
1182
+ case GL_UNIFORM_TYPE:
1183
+ case GL_UNIFORM_SIZE: {
1184
+ auto value = canvas_native_webgl_result_get_u32_array(
1185
+ ret);
1186
+ auto len = canvas_native_u32_buffer_get_length(value);
1187
+ auto buf = canvas_native_u32_buffer_get_bytes(value);
1188
+
1189
+ auto array = v8::Array::New(
1190
+ isolate, (int) len);
1191
+
1192
+ for (int j = 0;
1193
+ j < len; ++j) {
1194
+ auto item = buf[j];
1195
+ array->Set(
1196
+ context, j,
1197
+ v8::Number::New(isolate, (double) item));
1198
+ }
1199
+ args.GetReturnValue().Set(array);
1200
+ canvas_native_u32_buffer_destroy(value);
1201
+ canvas_native_webgl_WebGLResult_destroy(ret);
1202
+ return;
1203
+ }
1204
+ case GL_UNIFORM_BLOCK_INDEX:
1205
+ case GL_UNIFORM_OFFSET:
1206
+ case GL_UNIFORM_ARRAY_STRIDE:
1207
+ case GL_UNIFORM_MATRIX_STRIDE: {
1208
+ auto value = canvas_native_webgl_result_get_i32_array(
1209
+ ret);
1210
+ auto len = canvas_native_i32_buffer_get_length(value);
1211
+ auto buf = canvas_native_i32_buffer_get_bytes(value);
1212
+ auto array = v8::Array::New(
1213
+ isolate, (int) len);
1214
+ for (int j = 0;
1215
+ j < len; ++j) {
1216
+ auto item = buf[j];
1217
+ array->Set(
1218
+ context, j,
1219
+ v8::Number::New(isolate,
1220
+ (double) item));
1221
+ }
1222
+ args.GetReturnValue().Set(array);
1223
+ canvas_native_i32_buffer_destroy(value);
1224
+ canvas_native_webgl_WebGLResult_destroy(ret);
1225
+ return;
1226
+ }
1227
+ case GL_UNIFORM_IS_ROW_MAJOR: {
1228
+ auto value = canvas_native_webgl_result_get_bool_array(
1229
+ ret);
1230
+ auto len = canvas_native_u8_buffer_get_length(value);
1231
+ auto buf = canvas_native_u8_buffer_get_bytes(value);
1232
+ auto array = v8::Array::New(
1233
+ isolate,
1234
+ (int) len);
1235
+ for (int j = 0;
1236
+ j < len; ++j) {
1237
+ bool item =
1238
+ buf[j] == 1;
1239
+ array->Set(
1240
+ context, j,
1241
+ v8::Boolean::New(isolate, item));
1242
+ }
1243
+ args.GetReturnValue().Set(array);
1244
+ canvas_native_u8_buffer_destroy(value);
1245
+ canvas_native_webgl_WebGLResult_destroy(ret);
1246
+ return;
1247
+ }
1248
+ default:
1249
+ args.GetReturnValue().SetNull();
1250
+ canvas_native_webgl_WebGLResult_destroy(ret);
1251
+ return;
1252
+ }
1253
+ }
1254
+
1255
+
1256
+ }
1257
+ }
1258
+
1259
+ void WebGL2RenderingContext::GetBufferSubData(const v8::FunctionCallbackInfo<v8::Value> &args) {
1260
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1261
+ if (ptr == nullptr) {
1262
+ args.GetReturnValue().SetNull();
1263
+ return;
1264
+ }
1265
+
1266
+ auto isolate = args.GetIsolate();
1267
+ auto context = isolate->GetCurrentContext();
1268
+
1269
+ auto dstDataObject = args[2];
1270
+ if (args.Length() >= 3 &&
1271
+ dstDataObject->IsObject()) {
1272
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1273
+ auto srcByteOffset = args[1]->NumberValue(context).ToChecked();
1274
+
1275
+ if (dstDataObject->IsArrayBufferView()) {
1276
+
1277
+ auto array = dstDataObject.As<v8::ArrayBufferView>();
1278
+
1279
+ auto buf = array->Buffer();
1280
+ auto offset = array->ByteOffset();
1281
+ auto size = buf->ByteLength();
1282
+ auto data = reinterpret_cast<uint8_t *>(buf->GetBackingStore()->Data()) + offset;
1283
+
1284
+
1285
+
1286
+ auto BYTES_PER_ELEMENT = (ssize_t) array->Get(
1287
+ context,
1288
+ ConvertToV8String(isolate, "BYTES_PER_ELEMENT")).ToLocalChecked()->NumberValue(
1289
+ context).ToChecked();
1290
+
1291
+ ssize_t dstOffsetValue = 0;
1292
+ if (args[3]->IsNumber()) {
1293
+ dstOffsetValue =
1294
+ static_cast<ssize_t>(args[3]->NumberValue(context).ToChecked()) *
1295
+ BYTES_PER_ELEMENT;
1296
+ }
1297
+
1298
+ ssize_t lengthValue = 0;
1299
+ if (args[4]->IsNumber()) {
1300
+ lengthValue =
1301
+ static_cast<ssize_t>(args[4]->NumberValue(context).ToChecked()) *
1302
+ BYTES_PER_ELEMENT;
1303
+ }
1304
+
1305
+ canvas_native_webgl2_get_buffer_sub_data(
1306
+ target,
1307
+ static_cast<ssize_t>(srcByteOffset),
1308
+ data, size,
1309
+ dstOffsetValue,
1310
+ lengthValue,
1311
+ ptr->GetState()
1312
+ );
1313
+ }
1314
+ }
1315
+ }
1316
+
1317
+ void WebGL2RenderingContext::GetFragDataLocation(const v8::FunctionCallbackInfo<v8::Value> &args) {
1318
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1319
+ if (ptr == nullptr) {
1320
+ args.GetReturnValue().SetNull();
1321
+ return;
1322
+ }
1323
+
1324
+ auto isolate = args.GetIsolate();
1325
+ auto context = isolate->GetCurrentContext();
1326
+
1327
+ auto programValue = args[0];
1328
+ auto nameValue = args[1];
1329
+ auto type = GetNativeType(isolate, programValue);
1330
+ if (type == NativeType::WebGLProgram && nameValue->IsString()) {
1331
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1332
+
1333
+ if (program != nullptr) {
1334
+ auto name = ConvertFromV8String(isolate, nameValue);
1335
+
1336
+ auto ret = canvas_native_webgl2_get_frag_data_location(
1337
+ program->GetProgram(),
1338
+ name.c_str(),
1339
+ ptr->GetState()
1340
+ );
1341
+
1342
+ args.GetReturnValue().Set(ret);
1343
+
1344
+ return;
1345
+ }
1346
+ }
1347
+ args.GetReturnValue().SetNull();
1348
+ }
1349
+
1350
+ void WebGL2RenderingContext::GetIndexedParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1351
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1352
+ if (ptr == nullptr) {
1353
+ args.GetReturnValue().SetNull();
1354
+ return;
1355
+ }
1356
+
1357
+ auto isolate = args.GetIsolate();
1358
+ auto context = isolate->GetCurrentContext();
1359
+
1360
+ if (args.Length() > 1) {
1361
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1362
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
1363
+ auto ret = canvas_native_webgl2_get_indexed_parameter(
1364
+ target,
1365
+ index,
1366
+ ptr->GetState()
1367
+ );
1368
+
1369
+ switch (target) {
1370
+ case GL_UNIFORM_BUFFER_BINDING:
1371
+ case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: {
1372
+ auto buffer = canvas_native_webgl2_indexed_parameter_get_buffer_value(
1373
+ ret);
1374
+
1375
+ args.GetReturnValue().Set(
1376
+ WebGLBuffer::NewInstance(isolate, new WebGLBuffer(buffer)));
1377
+ }
1378
+ return;
1379
+ case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
1380
+ case GL_TRANSFORM_FEEDBACK_BUFFER_START:
1381
+ case GL_UNIFORM_BUFFER_SIZE:
1382
+ case GL_UNIFORM_BUFFER_START: {
1383
+ auto value = canvas_native_webgl2_indexed_parameter_get_value(
1384
+ ret);
1385
+ args.GetReturnValue().Set(static_cast<double>(value));
1386
+ return;
1387
+ }
1388
+ break;
1389
+ default:
1390
+ args.GetReturnValue().SetNull();
1391
+ return;
1392
+ }
1393
+ }
1394
+ args.GetReturnValue().SetNull();
1395
+ }
1396
+
1397
+ void WebGL2RenderingContext::GetInternalformatParameter(
1398
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1399
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1400
+ if (ptr == nullptr) {
1401
+ args.GetReturnValue().SetNull();
1402
+ return;
1403
+ }
1404
+
1405
+ auto isolate = args.GetIsolate();
1406
+ auto context = isolate->GetCurrentContext();
1407
+
1408
+ if (args.Length() > 2) {
1409
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1410
+ auto internalformat = (uint32_t) args[1]->NumberValue(context).ToChecked();
1411
+ auto pname = (uint32_t) args[2]->NumberValue(context).ToChecked();
1412
+ switch (internalformat) {
1413
+ case GL_RGB:
1414
+ case GL_RGBA:
1415
+ case GL_R8UI:
1416
+ case GL_R8I:
1417
+ case GL_R16UI:
1418
+ case GL_R16I:
1419
+ case GL_R32UI:
1420
+ case GL_R32I:
1421
+ case GL_RG8UI:
1422
+ case GL_RG8I:
1423
+ case GL_RG16UI:
1424
+ case GL_RG16I:
1425
+ case GL_RG32UI:
1426
+ case GL_RG32I:
1427
+ case GL_RGBA8UI:
1428
+ case GL_RGBA8I:
1429
+ case GL_RGB10_A2UI:
1430
+ case GL_RGBA16UI:
1431
+ case GL_RGBA16I:
1432
+ case GL_RGBA32UI:
1433
+ case GL_RGBA32I: {
1434
+ // empty
1435
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, 0);
1436
+
1437
+ args.GetReturnValue().Set(v8::Int32Array::New(arraybuffer, 0, 0));
1438
+ return;
1439
+ }
1440
+ case GL_R8:
1441
+ case GL_RG8:
1442
+ case GL_RGB565:
1443
+ case GL_RGBA8:
1444
+ case GL_SRGB8_ALPHA8:
1445
+ case GL_RGB5_A1:
1446
+ case GL_RGBA4:
1447
+ case GL_RGB10_A2:
1448
+ case GL_DEPTH_COMPONENT16:
1449
+ case GL_DEPTH_COMPONENT24:
1450
+ case GL_DEPTH_COMPONENT32F:
1451
+ case GL_DEPTH24_STENCIL8:
1452
+ case GL_DEPTH32F_STENCIL8:
1453
+ case GL_STENCIL_INDEX8:
1454
+ // noop
1455
+ break;
1456
+ case GL_R16F:
1457
+ case GL_RG16F:
1458
+ case GL_R32F:
1459
+ case GL_RG32F:
1460
+ case GL_RGBA32F:
1461
+ case GL_R11F_G11F_B10F:
1462
+ // noop
1463
+ break;
1464
+ default:
1465
+ args.GetReturnValue().SetNull();
1466
+ return;
1467
+ }
1468
+
1469
+
1470
+ auto ret = canvas_native_webgl2_get_internalformat_parameter(
1471
+ target,
1472
+ internalformat,
1473
+ pname,
1474
+ ptr->GetState()
1475
+ );
1476
+
1477
+ if (pname == GL_SAMPLES) {
1478
+ auto value = canvas_native_webgl_result_get_i32_array(ret);
1479
+
1480
+ auto buf = (uint8_t*)canvas_native_i32_buffer_get_bytes(value);
1481
+ auto size = canvas_native_i32_buffer_get_length(value);
1482
+ auto bytes_size = size * sizeof(int32_t);
1483
+
1484
+ auto store = v8::ArrayBuffer::NewBackingStore(buf, bytes_size,
1485
+ [](void *data, size_t length,
1486
+ void *deleter_data) {
1487
+ if (deleter_data != nullptr) {
1488
+ canvas_native_i32_buffer_destroy((I32Buffer *) deleter_data);
1489
+ }
1490
+ },
1491
+ value);
1492
+
1493
+ auto arraybuffer = v8::ArrayBuffer::New(isolate, std::move(store));
1494
+ args.GetReturnValue().Set(v8::Int32Array::New(arraybuffer, 0, size));
1495
+ canvas_native_webgl_WebGLResult_destroy(ret);
1496
+ return;
1497
+ } else {
1498
+ args.GetReturnValue().SetNull();
1499
+ canvas_native_webgl_WebGLResult_destroy(ret);
1500
+ return;
1501
+ }
1502
+ }
1503
+ args.GetReturnValue().SetNull();
1504
+ }
1505
+
1506
+ void WebGL2RenderingContext::GetParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1507
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1508
+ if (ptr == nullptr) {
1509
+ args.GetReturnValue().SetNull();
1510
+ return;
1511
+ }
1512
+
1513
+ auto isolate = args.GetIsolate();
1514
+ auto context = isolate->GetCurrentContext();
1515
+
1516
+ if (args.Length() > 0) {
1517
+ auto pname = (uint32_t) args[0]->NumberValue(context).ToChecked();
1518
+ auto result = canvas_native_webgl2_get_parameter(
1519
+ pname,
1520
+ ptr->GetState());
1521
+ switch (pname) {
1522
+ case GL_COPY_READ_BUFFER_BINDING:
1523
+ case GL_COPY_WRITE_BUFFER_BINDING:
1524
+ case GL_DRAW_FRAMEBUFFER_BINDING:
1525
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1526
+ result));
1527
+
1528
+ canvas_native_webgl_WebGLResult_destroy(result);
1529
+ return;
1530
+ default: {
1531
+ auto ret = ptr->GetParameterInternal(
1532
+ isolate, pname,result);
1533
+
1534
+ canvas_native_webgl_WebGLResult_destroy(result);
1535
+
1536
+ args.GetReturnValue().Set(ret);
1537
+ return;
1538
+ }
1539
+ }
1540
+ }
1541
+
1542
+ args.GetReturnValue().SetNull();
1543
+ }
1544
+
1545
+ void WebGL2RenderingContext::GetQueryParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1546
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1547
+ if (ptr == nullptr) {
1548
+ args.GetReturnValue().SetNull();
1549
+ return;
1550
+ }
1551
+
1552
+ auto isolate = args.GetIsolate();
1553
+ auto context = isolate->GetCurrentContext();
1554
+
1555
+ if (args.Length() > 1) {
1556
+ auto queryValue = args[0];
1557
+ auto type = GetNativeType(isolate, queryValue);
1558
+ if (type == NativeType::WebGLQuery) {
1559
+ auto query = WebGLQuery::GetPointer(queryValue.As<v8::Object>());
1560
+ if (query != nullptr) {
1561
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1562
+
1563
+
1564
+ auto ret = canvas_native_webgl2_get_query_parameter(
1565
+ query->GetQuery(),
1566
+ pname,
1567
+ ptr->GetState());
1568
+ if (pname == GL_QUERY_RESULT) {
1569
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_bool(
1570
+ ret));
1571
+ canvas_native_webgl_WebGLResult_destroy(ret);
1572
+ return;
1573
+ } else if (pname ==
1574
+ GL_QUERY_RESULT_AVAILABLE) {
1575
+ args.GetReturnValue().Set((int32_t) canvas_native_webgl_result_get_u32(
1576
+ ret));
1577
+ canvas_native_webgl_WebGLResult_destroy(ret);
1578
+ return;
1579
+ }
1580
+ //clean up
1581
+ canvas_native_webgl_WebGLResult_destroy(ret);
1582
+
1583
+ }
1584
+ }
1585
+
1586
+ }
1587
+
1588
+ args.GetReturnValue().SetNull();
1589
+ }
1590
+
1591
+ void WebGL2RenderingContext::GetQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
1592
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1593
+ if (ptr == nullptr) {
1594
+ args.GetReturnValue().SetNull();
1595
+ return;
1596
+ }
1597
+
1598
+ auto isolate = args.GetIsolate();
1599
+ auto context = isolate->GetCurrentContext();
1600
+
1601
+ if (args.Length() > 1) {
1602
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1603
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1604
+ auto ret = canvas_native_webgl2_get_query(
1605
+ target,
1606
+ pname,
1607
+ ptr->GetState());
1608
+ if (pname == GL_CURRENT_QUERY) {
1609
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1610
+ ret));
1611
+ canvas_native_webgl_WebGLResult_destroy(ret);
1612
+ return;
1613
+ }
1614
+ // clean up
1615
+ canvas_native_webgl_WebGLResult_destroy(ret);
1616
+ }
1617
+
1618
+ args.GetReturnValue().SetNull();
1619
+ }
1620
+
1621
+ void WebGL2RenderingContext::GetSamplerParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1622
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1623
+ if (ptr == nullptr) {
1624
+ args.GetReturnValue().SetNull();
1625
+ return;
1626
+ }
1627
+
1628
+ auto isolate = args.GetIsolate();
1629
+ auto context = isolate->GetCurrentContext();
1630
+
1631
+ if (args.Length() > 1) {
1632
+ auto samplerValue = args[0];
1633
+ auto type = GetNativeType(isolate, samplerValue);
1634
+ if (type == NativeType::WebGLSampler) {
1635
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
1636
+ if (sampler != nullptr) {
1637
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1638
+ auto ret = canvas_native_webgl2_get_sampler_parameter(
1639
+ sampler->GetSampler(),
1640
+ pname,
1641
+ ptr->GetState());
1642
+
1643
+ switch (pname) {
1644
+ case GL_TEXTURE_MAX_LOD:
1645
+ case GL_TEXTURE_MIN_LOD:
1646
+ args.GetReturnValue().Set(
1647
+ static_cast<double>(canvas_native_webgl_result_get_f32(
1648
+ ret)));
1649
+ canvas_native_webgl_WebGLResult_destroy(ret);
1650
+ return;
1651
+ case GL_TEXTURE_COMPARE_FUNC:
1652
+ case GL_TEXTURE_COMPARE_MODE:
1653
+ case GL_TEXTURE_MAG_FILTER:
1654
+ case GL_TEXTURE_MIN_FILTER:
1655
+ case GL_TEXTURE_WRAP_R:
1656
+ case GL_TEXTURE_WRAP_S:
1657
+ case GL_TEXTURE_WRAP_T:
1658
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1659
+ ret));
1660
+ canvas_native_webgl_WebGLResult_destroy(ret);
1661
+ return;
1662
+ default:
1663
+ args.GetReturnValue().SetNull();
1664
+ canvas_native_webgl_WebGLResult_destroy(ret);
1665
+ return;
1666
+ }
1667
+ }
1668
+ }
1669
+
1670
+ }
1671
+
1672
+ args.GetReturnValue().SetNull();
1673
+ }
1674
+
1675
+ void WebGL2RenderingContext::GetSyncParameter(const v8::FunctionCallbackInfo<v8::Value> &args) {
1676
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1677
+ if (ptr == nullptr) {
1678
+ args.GetReturnValue().SetNull();
1679
+ return;
1680
+ }
1681
+
1682
+ auto isolate = args.GetIsolate();
1683
+ auto context = isolate->GetCurrentContext();
1684
+
1685
+ if (args.Length() > 1) {
1686
+ auto syncValue = args[0];
1687
+ auto sync = WebGLSyncImpl::GetPointer(syncValue.As<v8::Object>());
1688
+ if (sync != nullptr) {
1689
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
1690
+ auto ret = canvas_native_webgl2_get_sync_parameter(
1691
+ sync->GetSync(),
1692
+ pname,
1693
+ ptr->GetState());
1694
+
1695
+ switch (pname) {
1696
+ case GL_OBJECT_TYPE:
1697
+ case GL_SYNC_STATUS:
1698
+ case GL_SYNC_CONDITION:
1699
+ case GL_SYNC_FLAGS:
1700
+ args.GetReturnValue().Set(canvas_native_webgl_result_get_i32(
1701
+ ret));
1702
+
1703
+ canvas_native_webgl_WebGLResult_destroy(ret);
1704
+ return;
1705
+ default:
1706
+ args.GetReturnValue().SetNull();
1707
+ canvas_native_webgl_WebGLResult_destroy(ret);
1708
+ return;
1709
+ }
1710
+ }
1711
+ }
1712
+
1713
+ args.GetReturnValue().SetNull();
1714
+ }
1715
+
1716
+ void WebGL2RenderingContext::GetTransformFeedbackVarying(
1717
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
1718
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1719
+ if (ptr == nullptr) {
1720
+ args.GetReturnValue().SetNull();
1721
+ return;
1722
+ }
1723
+
1724
+ auto isolate = args.GetIsolate();
1725
+ auto context = isolate->GetCurrentContext();
1726
+
1727
+ if (args.Length() > 1) {
1728
+ auto programValue = args[0];
1729
+ auto type = GetNativeType(isolate, programValue);
1730
+ if (type == NativeType::WebGLProgram) {
1731
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1732
+ auto index = (uint32_t) args[1]->NumberValue(context).ToChecked();
1733
+ if (program != nullptr) {
1734
+ auto ret = canvas_native_webgl2_get_transform_feedback_varying(
1735
+ program->GetProgram(),
1736
+ index,
1737
+ ptr->GetState()
1738
+ );
1739
+
1740
+ if (canvas_native_webgl_active_info_get_is_empty(
1741
+ ret)) {
1742
+ canvas_native_webgl_active_info_destroy(ret);
1743
+ args.GetReturnValue().SetNull();
1744
+ return;
1745
+ }
1746
+
1747
+ auto info = WebGLActiveInfoImpl::NewInstance(isolate, new WebGLActiveInfoImpl(ret));
1748
+ args.GetReturnValue().Set(info);
1749
+ return;
1750
+ }
1751
+ }
1752
+ }
1753
+
1754
+ args.GetReturnValue().SetNull();
1755
+ }
1756
+
1757
+ void WebGL2RenderingContext::GetUniformBlockIndex(const v8::FunctionCallbackInfo<v8::Value> &args) {
1758
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1759
+ if (ptr == nullptr) {
1760
+ args.GetReturnValue().SetNull();
1761
+ return;
1762
+ }
1763
+
1764
+ auto isolate = args.GetIsolate();
1765
+ auto context = isolate->GetCurrentContext();
1766
+
1767
+ if (args.Length() > 1) {
1768
+ auto programValue = args[0];
1769
+ auto type = GetNativeType(isolate, programValue);
1770
+ if (type == NativeType::WebGLProgram) {
1771
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1772
+ auto index = ConvertFromV8String(isolate, args[1]);
1773
+ if (program != nullptr) {
1774
+ auto ret = canvas_native_webgl2_get_uniform_block_index(
1775
+ program->GetProgram(),
1776
+ index.c_str(),
1777
+ ptr->GetState());
1778
+ args.GetReturnValue().Set((int) ret);
1779
+ return;
1780
+ }
1781
+ }
1782
+
1783
+ }
1784
+
1785
+ args.GetReturnValue().SetNull();
1786
+ }
1787
+
1788
+ void WebGL2RenderingContext::GetUniformIndices(const v8::FunctionCallbackInfo<v8::Value> &args) {
1789
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1790
+ if (ptr == nullptr) {
1791
+ args.GetReturnValue().SetNull();
1792
+ return;
1793
+ }
1794
+
1795
+ auto isolate = args.GetIsolate();
1796
+ auto context = isolate->GetCurrentContext();
1797
+
1798
+ if (args.Length() > 1 && args[1]->IsObject()) {
1799
+ auto programValue = args[0];
1800
+ auto type = GetNativeType(isolate, programValue);
1801
+ if (type == NativeType::WebGLProgram) {
1802
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
1803
+ auto uniformNamesObject = args[1];
1804
+ if (program != nullptr &&
1805
+ uniformNamesObject->IsArray()) {
1806
+ auto uniformNames = uniformNamesObject.As<v8::Array>();
1807
+ auto len = uniformNames->Length();
1808
+
1809
+ std::vector<std::string> store;
1810
+ store.reserve(len);
1811
+
1812
+ for (int j = 0; j < len; ++j) {
1813
+ auto name = ConvertFromV8String(isolate, uniformNames->Get(
1814
+ context, j).ToLocalChecked());
1815
+
1816
+ store.push_back(name);
1817
+ }
1818
+
1819
+
1820
+ const char* cStrings[store.size()];
1821
+ for (size_t i = 0; i < store.size(); ++i) {
1822
+ cStrings[i] = store[i].c_str();
1823
+ }
1824
+
1825
+
1826
+ auto ret = canvas_native_webgl2_get_uniform_indices(
1827
+ program->GetProgram(),
1828
+ cStrings,
1829
+ store.size(),
1830
+ ptr->GetState());
1831
+
1832
+
1833
+ auto retSize = canvas_native_u32_buffer_get_length(ret);
1834
+ auto buf = canvas_native_u32_buffer_get_bytes(ret);
1835
+ auto result = v8::Array::New(isolate, (int) retSize);
1836
+ for (int j = 0; j < retSize; ++j) {
1837
+ auto item = buf[j];
1838
+ result->Set(context,
1839
+ j,
1840
+ v8::Number::New(isolate,
1841
+ (int32_t) item));
1842
+ }
1843
+
1844
+ args.GetReturnValue().Set(result);
1845
+ canvas_native_u32_buffer_destroy(ret);
1846
+ return;
1847
+ }
1848
+ }
1849
+
1850
+ }
1851
+
1852
+ args.GetReturnValue().SetNull();
1853
+ }
1854
+
1855
+ void
1856
+ WebGL2RenderingContext::InvalidateFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
1857
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1858
+ if (ptr == nullptr) {
1859
+ return;
1860
+ }
1861
+
1862
+ auto isolate = args.GetIsolate();
1863
+ auto context = isolate->GetCurrentContext();
1864
+
1865
+ auto attachments = args[1];
1866
+ if (args.Length() > 1 && attachments->IsObject()) {
1867
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1868
+
1869
+ if (attachments->IsArray()) {
1870
+ auto array = attachments.As<v8::Array>();
1871
+ auto len = array->Length();
1872
+ std::vector<uint32_t> buf;
1873
+ buf.reserve(len);
1874
+ for (int j = 0; j < len; ++j) {
1875
+ auto item = (uint32_t) array->Get(
1876
+ context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1877
+ buf.push_back(item);
1878
+ }
1879
+
1880
+ canvas_native_webgl2_invalidate_framebuffer(
1881
+ target, buf.data(), buf.size(),
1882
+ ptr->GetState());
1883
+ }
1884
+ }
1885
+ }
1886
+
1887
+ void
1888
+ WebGL2RenderingContext::InvalidateSubFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
1889
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1890
+ if (ptr == nullptr) {
1891
+ return;
1892
+ }
1893
+
1894
+ auto isolate = args.GetIsolate();
1895
+ auto context = isolate->GetCurrentContext();
1896
+
1897
+ if (args.Length() > 5 && args[1]->IsObject()) {
1898
+ auto attachments = args[1];
1899
+ if (attachments->IsArray()) {
1900
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
1901
+ auto x = (int32_t) args[2]->NumberValue(context).ToChecked();
1902
+ auto y = (int32_t) args[3]->NumberValue(context).ToChecked();
1903
+ auto width = (int32_t) args[4]->NumberValue(context).ToChecked();
1904
+ auto height = (int32_t) args[5]->NumberValue(context).ToChecked();
1905
+
1906
+ auto array = attachments.As<v8::Array>();
1907
+ auto len = array->Length();
1908
+ std::vector<uint32_t> buf;
1909
+ buf.reserve(len);
1910
+ for (int j = 0; j < len; ++j) {
1911
+ auto item = (uint32_t) array->Get(
1912
+ context, j).ToLocalChecked()->NumberValue(context).ToChecked();
1913
+ buf.push_back(item);
1914
+ }
1915
+
1916
+ canvas_native_webgl2_invalidate_sub_framebuffer(
1917
+ target,
1918
+ buf.data(), buf.size(),
1919
+ x,
1920
+ y,
1921
+ width,
1922
+ height,
1923
+ ptr->GetState());
1924
+ }
1925
+
1926
+
1927
+ }
1928
+ }
1929
+
1930
+ void WebGL2RenderingContext::IsQuery(const v8::FunctionCallbackInfo<v8::Value> &args) {
1931
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1932
+ if (ptr == nullptr) {
1933
+ return;
1934
+ }
1935
+
1936
+ auto isolate = args.GetIsolate();
1937
+ auto context = isolate->GetCurrentContext();
1938
+
1939
+ auto value = args[0];
1940
+ auto type = GetNativeType(isolate, value);
1941
+ if (type == NativeType::WebGLQuery) {
1942
+ auto query = WebGLQuery::GetPointer(value.As<v8::Object>());
1943
+ if (query != nullptr) {
1944
+ auto ret = canvas_native_webgl2_is_query(
1945
+ query->GetQuery(),
1946
+ ptr->GetState());
1947
+ args.GetReturnValue().Set(ret);
1948
+ return;
1949
+ }
1950
+ }
1951
+ // todo check return
1952
+ args.GetReturnValue().Set(false);
1953
+ }
1954
+
1955
+ void WebGL2RenderingContext::IsSampler(const v8::FunctionCallbackInfo<v8::Value> &args) {
1956
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1957
+ if (ptr == nullptr) {
1958
+ return;
1959
+ }
1960
+
1961
+ auto isolate = args.GetIsolate();
1962
+ auto context = isolate->GetCurrentContext();
1963
+
1964
+ auto value = args[0];
1965
+ auto type = GetNativeType(isolate, value);
1966
+ if (type == NativeType::WebGLSampler) {
1967
+ auto query = WebGLSampler::GetPointer(value.As<v8::Object>());
1968
+ if (query != nullptr) {
1969
+ auto ret = canvas_native_webgl2_is_sampler(
1970
+ query->GetSampler(),
1971
+ ptr->GetState());
1972
+ args.GetReturnValue().Set(ret);
1973
+ return;
1974
+ }
1975
+ }
1976
+ // todo check return
1977
+ args.GetReturnValue().Set(false);
1978
+ }
1979
+
1980
+ void WebGL2RenderingContext::IsSync(const v8::FunctionCallbackInfo<v8::Value> &args) {
1981
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
1982
+ if (ptr == nullptr) {
1983
+ return;
1984
+ }
1985
+
1986
+ auto isolate = args.GetIsolate();
1987
+ auto context = isolate->GetCurrentContext();
1988
+
1989
+ auto value = args[0];
1990
+ auto type = GetNativeType(isolate, value);
1991
+ if (type == NativeType::WebGLSync) {
1992
+ auto query = WebGLSyncImpl::GetPointer(value.As<v8::Object>());
1993
+ if (query != nullptr) {
1994
+ auto ret = canvas_native_webgl2_is_sync(
1995
+ query->GetSync(),
1996
+ ptr->GetState());
1997
+ args.GetReturnValue().Set(ret);
1998
+ return;
1999
+ }
2000
+ }
2001
+ // todo check return
2002
+ args.GetReturnValue().Set(false);
2003
+ }
2004
+
2005
+ void WebGL2RenderingContext::IsTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
2006
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2007
+ if (ptr == nullptr) {
2008
+ return;
2009
+ }
2010
+
2011
+ auto isolate = args.GetIsolate();
2012
+ auto context = isolate->GetCurrentContext();
2013
+
2014
+ auto value = args[0];
2015
+ auto type = GetNativeType(isolate, value);
2016
+ if (type == NativeType::WebGLTransformFeedback) {
2017
+ auto query = WebGLTransformFeedback::GetPointer(value.As<v8::Object>());
2018
+ if (query != nullptr) {
2019
+ auto ret = canvas_native_webgl2_is_transform_feedback(
2020
+ query->GetFeedback(),
2021
+ ptr->GetState());
2022
+ args.GetReturnValue().Set(ret);
2023
+ return;
2024
+ }
2025
+ }
2026
+ // todo check return
2027
+ args.GetReturnValue().Set(false);
2028
+ }
2029
+
2030
+ void WebGL2RenderingContext::IsVertexArray(const v8::FunctionCallbackInfo<v8::Value> &args) {
2031
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2032
+ if (ptr == nullptr) {
2033
+ return;
2034
+ }
2035
+
2036
+ auto isolate = args.GetIsolate();
2037
+ auto context = isolate->GetCurrentContext();
2038
+
2039
+ auto value = args[0];
2040
+ auto type = GetNativeType(isolate, value);
2041
+ if (type == NativeType::WebGLVertexArrayObject) {
2042
+ auto query = WebGLVertexArrayObject::GetPointer(value.As<v8::Object>());
2043
+ if (query != nullptr) {
2044
+ auto ret = canvas_native_webgl2_is_vertex_array(
2045
+ query->GetVertexArrayObject(),
2046
+ ptr->GetState());
2047
+ args.GetReturnValue().Set(ret);
2048
+ return;
2049
+ }
2050
+ }
2051
+ // todo check return
2052
+ args.GetReturnValue().Set(false);
2053
+ }
2054
+
2055
+ void
2056
+ WebGL2RenderingContext::PauseTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
2057
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2058
+ if (ptr == nullptr) {
2059
+ return;
2060
+ }
2061
+ canvas_native_webgl2_pause_transform_feedback(
2062
+ ptr->GetState());
2063
+ }
2064
+
2065
+ void WebGL2RenderingContext::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value> &args) {
2066
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2067
+ if (ptr == nullptr) {
2068
+ return;
2069
+ }
2070
+
2071
+ auto isolate = args.GetIsolate();
2072
+ auto context = isolate->GetCurrentContext();
2073
+
2074
+ if (args.Length() > 0) {
2075
+ auto src = (uint32_t) args[0]->NumberValue(context).ToChecked();
2076
+ canvas_native_webgl2_read_buffer(
2077
+ src,
2078
+ ptr->GetState()
2079
+ );
2080
+ }
2081
+ }
2082
+
2083
+ void WebGL2RenderingContext::RenderbufferStorageMultisample(
2084
+ const v8::FunctionCallbackInfo<v8::Value> &args) {
2085
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2086
+ if (ptr == nullptr) {
2087
+ return;
2088
+ }
2089
+
2090
+ auto isolate = args.GetIsolate();
2091
+ auto context = isolate->GetCurrentContext();
2092
+
2093
+ if (args.Length() > 4) {
2094
+ auto target = (uint32_t) args[0]->NumberValue(context).ToChecked();
2095
+ auto samples = (int32_t) args[1]->NumberValue(context).ToChecked();
2096
+ auto internalFormat = (uint32_t) args[2]->NumberValue(context).ToChecked();
2097
+ auto width = (int32_t) args[3]->NumberValue(context).ToChecked();
2098
+ auto height = (int32_t) args[4]->NumberValue(context).ToChecked();
2099
+ canvas_native_webgl2_renderbuffer_storage_multisample(
2100
+ target,
2101
+ samples,
2102
+ internalFormat,
2103
+ width,
2104
+ height,
2105
+ ptr->GetState()
2106
+ );
2107
+ }
2108
+ }
2109
+
2110
+ void
2111
+ WebGL2RenderingContext::ResumeTransformFeedback(const v8::FunctionCallbackInfo<v8::Value> &args) {
2112
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2113
+ if (ptr == nullptr) {
2114
+ return;
2115
+ }
2116
+
2117
+ canvas_native_webgl2_resume_transform_feedback(
2118
+ ptr->GetState());
2119
+ }
2120
+
2121
+ void WebGL2RenderingContext::SamplerParameterf(const v8::FunctionCallbackInfo<v8::Value> &args) {
2122
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2123
+ if (ptr == nullptr) {
2124
+ return;
2125
+ }
2126
+
2127
+ auto isolate = args.GetIsolate();
2128
+ auto context = isolate->GetCurrentContext();
2129
+
2130
+ if (args.Length() > 2) {
2131
+ auto samplerValue = args[0];
2132
+ auto type = GetNativeType(isolate, samplerValue);
2133
+ if (type == NativeType::WebGLSampler) {
2134
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
2135
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
2136
+ auto param = args[2]->NumberValue(context).ToChecked();
2137
+ if (sampler != nullptr) {
2138
+ canvas_native_webgl2_sampler_parameterf(
2139
+ sampler->GetSampler(),
2140
+ pname,
2141
+ static_cast<float>(param),
2142
+ ptr->GetState());
2143
+ }
2144
+ }
2145
+
2146
+ }
2147
+
2148
+ }
2149
+
2150
+ void WebGL2RenderingContext::SamplerParameteri(const v8::FunctionCallbackInfo<v8::Value> &args) {
2151
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2152
+ if (ptr == nullptr) {
2153
+ return;
2154
+ }
2155
+
2156
+ auto isolate = args.GetIsolate();
2157
+ auto context = isolate->GetCurrentContext();
2158
+
2159
+ if (args.Length() > 2) {
2160
+ auto samplerValue = args[0];
2161
+ auto type = GetNativeType(isolate, samplerValue);
2162
+ if (type == NativeType::WebGLSampler) {
2163
+ auto sampler = WebGLSampler::GetPointer(samplerValue.As<v8::Object>());
2164
+ auto pname = (uint32_t) args[1]->NumberValue(context).ToChecked();
2165
+ auto param = (int32_t) args[2]->NumberValue(context).ToChecked();
2166
+ if (sampler != nullptr) {
2167
+ canvas_native_webgl2_sampler_parameteri(
2168
+ sampler->GetSampler(),
2169
+ pname,
2170
+ param,
2171
+ ptr->GetState());
2172
+ }
2173
+ }
2174
+
2175
+ }
2176
+
2177
+ }
2178
+
2179
+ void WebGL2RenderingContext::TexImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2180
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2181
+ if (ptr == nullptr) {
2182
+ return;
2183
+ }
2184
+
2185
+ auto isolate = args.GetIsolate();
2186
+ auto context = isolate->GetCurrentContext();
2187
+
2188
+ auto count = args.Length();
2189
+
2190
+
2191
+ if (count == 10) {
2192
+ auto target = (int32_t) args[0]->NumberValue(
2193
+ context).ToChecked();
2194
+ auto level = (int32_t) args[1]->NumberValue(
2195
+ context).ToChecked();
2196
+ auto internalformat = (int32_t) args[2]->NumberValue(
2197
+ context).ToChecked();
2198
+ auto width = (int32_t) args[3]->NumberValue(
2199
+ context).ToChecked();
2200
+ auto height = (int32_t) args[4]->NumberValue(
2201
+ context).ToChecked();
2202
+ auto depth = (int32_t) args[5]->NumberValue(
2203
+ context).ToChecked();
2204
+ auto border = (int32_t) args[6]->NumberValue(
2205
+ context).ToChecked();
2206
+ auto format = (int32_t) args[7]->NumberValue(
2207
+ context).ToChecked();
2208
+ auto type = (uint32_t) args[8]->NumberValue(
2209
+ context).ToChecked();
2210
+
2211
+ auto imageOrPixelsOrOffset = args[9];
2212
+
2213
+ if (imageOrPixelsOrOffset->IsNumber()) {
2214
+ auto offset = imageOrPixelsOrOffset->NumberValue(
2215
+ context).ToChecked();
2216
+ canvas_native_webgl2_tex_image3d_none(
2217
+ target,
2218
+ level,
2219
+ internalformat,
2220
+ width,
2221
+ height,
2222
+ depth,
2223
+ border,
2224
+ format,
2225
+ type,
2226
+ static_cast<ssize_t>(offset),
2227
+ ptr->GetState()
2228
+ );
2229
+ return;
2230
+ }
2231
+
2232
+
2233
+ if (imageOrPixelsOrOffset->IsArrayBufferView()) {
2234
+ auto buf = imageOrPixelsOrOffset.As<v8::ArrayBufferView>();
2235
+
2236
+ auto array = buf->Buffer();
2237
+ auto offset = buf->ByteOffset();
2238
+ auto size = buf->ByteLength();
2239
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2240
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2241
+
2242
+
2243
+ canvas_native_webgl2_tex_image3d(
2244
+ target,
2245
+ level,
2246
+ internalformat,
2247
+ width,
2248
+ height,
2249
+ depth,
2250
+ border,
2251
+ format,
2252
+ type,
2253
+ data,
2254
+ size,
2255
+ ptr->GetState()
2256
+ );
2257
+ return;
2258
+ }
2259
+
2260
+ auto imageType = GetNativeType(isolate, imageOrPixelsOrOffset);
2261
+
2262
+ switch (imageType) {
2263
+ case NativeType::ImageAsset: {
2264
+ auto image_asset = ImageAssetImpl::GetPointer(
2265
+ imageOrPixelsOrOffset.As<v8::Object>());
2266
+ if (image_asset != nullptr) {
2267
+ canvas_native_webgl2_tex_image3d_asset(
2268
+ target,
2269
+ level,
2270
+ internalformat,
2271
+ width,
2272
+ height,
2273
+ depth,
2274
+ border,
2275
+ format,
2276
+ type,
2277
+ image_asset->GetImageAsset(),
2278
+ ptr->GetState()
2279
+ );
2280
+
2281
+ return;
2282
+ }
2283
+ return;
2284
+ }
2285
+ case NativeType::ImageBitmap: {
2286
+ auto image_bitmap = ImageBitmapImpl::GetPointer(
2287
+ imageOrPixelsOrOffset.As<v8::Object>());
2288
+ if (image_bitmap != nullptr) {
2289
+ canvas_native_webgl2_tex_image3d_asset(
2290
+ target,
2291
+ level,
2292
+ internalformat,
2293
+ width,
2294
+ height,
2295
+ depth,
2296
+ border,
2297
+ format,
2298
+ type,
2299
+ image_bitmap->GetImageAsset(),
2300
+ ptr->GetState()
2301
+ );
2302
+
2303
+ return;
2304
+ }
2305
+ return;
2306
+ }
2307
+ default:
2308
+ return;
2309
+ }
2310
+ } else if (args.Length() > 10) {
2311
+
2312
+ auto target = (int32_t) args[0]->NumberValue(
2313
+ context).ToChecked();
2314
+ auto level = (int32_t) args[1]->NumberValue(
2315
+ context).ToChecked();
2316
+ auto internalformat = (int32_t) args[2]->NumberValue(
2317
+ context).ToChecked();
2318
+ auto width = (int32_t) args[3]->NumberValue(
2319
+ context).ToChecked();
2320
+ auto height = (int32_t) args[4]->NumberValue(
2321
+ context).ToChecked();
2322
+ auto depth = (int32_t) args[5]->NumberValue(
2323
+ context).ToChecked();
2324
+ auto border = (int32_t) args[6]->NumberValue(
2325
+ context).ToChecked();
2326
+ auto format = (int32_t) args[7]->NumberValue(
2327
+ context).ToChecked();
2328
+ auto type = (uint32_t) args[8]->NumberValue(
2329
+ context).ToChecked();
2330
+
2331
+ auto imageOrPixelsOrOffset = args[9];
2332
+
2333
+ size_t srcOffsetValue = 0;
2334
+ if (args[9]->IsNumber()) {
2335
+ srcOffsetValue = static_cast<size_t>(args[9]->NumberValue(
2336
+ context).ToChecked());
2337
+ }
2338
+
2339
+ if (imageOrPixelsOrOffset->IsArrayBufferView()) {
2340
+ auto buf = imageOrPixelsOrOffset.As<v8::ArrayBufferView>();
2341
+
2342
+ auto array = buf->Buffer();
2343
+ auto offset = buf->ByteOffset();
2344
+ auto size = buf->ByteLength();
2345
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2346
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2347
+
2348
+ srcOffsetValue =
2349
+ srcOffsetValue * size;
2350
+ if (srcOffsetValue >
2351
+ size) {
2352
+ return;
2353
+ }
2354
+
2355
+ canvas_native_webgl2_tex_image3d_offset(
2356
+ target,
2357
+ level,
2358
+ internalformat,
2359
+ width,
2360
+ height,
2361
+ depth,
2362
+ border,
2363
+ format,
2364
+ type,
2365
+ data, size,
2366
+ srcOffsetValue,
2367
+ ptr->GetState()
2368
+ );
2369
+ return;
2370
+ }
2371
+
2372
+ }
2373
+ }
2374
+
2375
+ void WebGL2RenderingContext::TexStorage2D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2376
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2377
+ if (ptr == nullptr) {
2378
+ return;
2379
+ }
2380
+
2381
+ auto isolate = args.GetIsolate();
2382
+ auto context = isolate->GetCurrentContext();
2383
+
2384
+ if (args.Length() > 4) {
2385
+ auto target = (uint32_t) args[0]->NumberValue(
2386
+ context).ToChecked();
2387
+ auto levels = (int32_t) args[1]->NumberValue(
2388
+ context).ToChecked();
2389
+ auto internalFormat = (uint32_t) args[2]->NumberValue(
2390
+ context).ToChecked();
2391
+ auto width = (int32_t) args[3]->NumberValue(
2392
+ context).ToChecked();
2393
+ auto height = (int32_t) args[4]->NumberValue(
2394
+ context).ToChecked();
2395
+ canvas_native_webgl2_tex_storage2d(
2396
+ target,
2397
+ levels,
2398
+ internalFormat,
2399
+ width,
2400
+ height,
2401
+ ptr->GetState()
2402
+ );
2403
+ }
2404
+ }
2405
+
2406
+ void WebGL2RenderingContext::TexStorage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2407
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2408
+ if (ptr == nullptr) {
2409
+ return;
2410
+ }
2411
+
2412
+ auto isolate = args.GetIsolate();
2413
+ auto context = isolate->GetCurrentContext();
2414
+
2415
+ if (args.Length() > 5) {
2416
+ auto target = (uint32_t) args[0]->NumberValue(
2417
+ context).ToChecked();
2418
+ auto levels = (int32_t) args[1]->NumberValue(
2419
+ context).ToChecked();
2420
+ auto internalFormat = (uint32_t) args[2]->NumberValue(
2421
+ context).ToChecked();
2422
+ auto width = (int32_t) args[3]->NumberValue(
2423
+ context).ToChecked();
2424
+ auto height = (int32_t) args[4]->NumberValue(
2425
+ context).ToChecked();
2426
+ auto depth = (int32_t) args[5]->NumberValue(
2427
+ context).ToChecked();
2428
+ canvas_native_webgl2_tex_storage3d(
2429
+ target,
2430
+ levels,
2431
+ internalFormat,
2432
+ width,
2433
+ height,
2434
+ depth,
2435
+ ptr->GetState()
2436
+ );
2437
+ }
2438
+ }
2439
+
2440
+ void WebGL2RenderingContext::TexSubImage3D(const v8::FunctionCallbackInfo<v8::Value> &args) {
2441
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2442
+ if (ptr == nullptr) {
2443
+ return;
2444
+ }
2445
+
2446
+ auto isolate = args.GetIsolate();
2447
+ auto context = isolate->GetCurrentContext();
2448
+
2449
+ auto count = args.Length();
2450
+ if (count == 11) {
2451
+ auto target = (uint32_t) args[0]->NumberValue(
2452
+ context).ToChecked();
2453
+ auto level = (int32_t) args[1]->NumberValue(
2454
+ context).ToChecked();
2455
+ auto xoffset = (int32_t) args[2]->NumberValue(
2456
+ context).ToChecked();
2457
+ auto yoffset = (int32_t) args[3]->NumberValue(
2458
+ context).ToChecked();
2459
+ auto zoffset = (int32_t) args[4]->NumberValue(
2460
+ context).ToChecked();
2461
+ auto width = (int32_t) args[5]->NumberValue(
2462
+ context).ToChecked();
2463
+ auto height = (int32_t) args[6]->NumberValue(
2464
+ context).ToChecked();
2465
+ auto depth = (int32_t) args[7]->NumberValue(
2466
+ context).ToChecked();
2467
+ auto format = (uint32_t) args[8]->NumberValue(
2468
+ context).ToChecked();
2469
+ auto type = (int32_t) args[9]->NumberValue(
2470
+ context).ToChecked();
2471
+
2472
+ if (args[10]->IsNumber()) {
2473
+ auto imageOrPixelsOrOffset = args[10]->NumberValue(
2474
+ context).ToChecked();
2475
+ canvas_native_webgl2_tex_sub_image3d_none(
2476
+ target,
2477
+ level,
2478
+ xoffset,
2479
+ yoffset,
2480
+ zoffset,
2481
+ width,
2482
+ height,
2483
+ depth,
2484
+ format,
2485
+ type,
2486
+ static_cast<ssize_t>(imageOrPixelsOrOffset),
2487
+ ptr->GetState()
2488
+ );
2489
+ return;
2490
+ }
2491
+
2492
+ auto imageOrPixelsOrOffsetObject = args[10];
2493
+
2494
+ if (imageOrPixelsOrOffsetObject->IsArrayBufferView()) {
2495
+ auto buf = imageOrPixelsOrOffsetObject.As<v8::ArrayBufferView>();
2496
+
2497
+ auto array = buf->Buffer();
2498
+ auto offset = buf->ByteOffset();
2499
+ auto size = buf->ByteLength();
2500
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2501
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2502
+
2503
+
2504
+
2505
+ canvas_native_webgl2_tex_sub_image3d(
2506
+ target,
2507
+ level,
2508
+ xoffset,
2509
+ yoffset,
2510
+ zoffset,
2511
+ width,
2512
+ height,
2513
+ depth,
2514
+ format,
2515
+ type,
2516
+ data, size,
2517
+ ptr->GetState()
2518
+ );
2519
+
2520
+ return;
2521
+ }
2522
+
2523
+
2524
+ auto imageType = GetNativeType(isolate, imageOrPixelsOrOffsetObject);
2525
+
2526
+ if (imageType == NativeType::ImageAsset) {
2527
+ auto asset = ImageAssetImpl::GetPointer(imageOrPixelsOrOffsetObject.As<v8::Object>());
2528
+ if (asset != nullptr) {
2529
+
2530
+ canvas_native_webgl2_tex_sub_image3d_asset(
2531
+ target,
2532
+ level,
2533
+ xoffset,
2534
+ yoffset,
2535
+ zoffset,
2536
+ width,
2537
+ height,
2538
+ depth,
2539
+ format,
2540
+ type,
2541
+ asset->GetImageAsset(),
2542
+ ptr->GetState()
2543
+ );
2544
+ }
2545
+ }
2546
+
2547
+ } else if (count > 11) {
2548
+ auto target = (uint32_t) args[0]->NumberValue(
2549
+ context).ToChecked();
2550
+ auto level = (int32_t) args[1]->NumberValue(
2551
+ context).ToChecked();
2552
+ auto xoffset = (int32_t) args[2]->NumberValue(
2553
+ context).ToChecked();
2554
+ auto yoffset = (int32_t) args[3]->NumberValue(
2555
+ context).ToChecked();
2556
+ auto zoffset = (int32_t) args[4]->NumberValue(
2557
+ context).ToChecked();
2558
+ auto width = (int32_t) args[5]->NumberValue(
2559
+ context).ToChecked();
2560
+ auto height = (int32_t) args[6]->NumberValue(
2561
+ context).ToChecked();
2562
+ auto depth = (int32_t) args[7]->NumberValue(
2563
+ context).ToChecked();
2564
+ auto format = (uint32_t) args[8]->NumberValue(
2565
+ context).ToChecked();
2566
+ auto type = (uint32_t) args[9]->NumberValue(
2567
+ context).ToChecked();
2568
+
2569
+ size_t srcOffsetValue = 0;
2570
+
2571
+ if (args[11]->IsNumber()) {
2572
+ srcOffsetValue = static_cast<size_t>(args[11]->NumberValue(
2573
+ context).ToChecked());
2574
+ }
2575
+
2576
+ auto imageOrPixelsOrOffsetObject = args[10];
2577
+
2578
+
2579
+ if (imageOrPixelsOrOffsetObject->IsArrayBufferView()) {
2580
+ auto buf = imageOrPixelsOrOffsetObject.As<v8::ArrayBufferView>();
2581
+
2582
+ auto array = buf->Buffer();
2583
+ auto offset = buf->ByteOffset();
2584
+ auto size = buf->ByteLength();
2585
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2586
+ auto data = static_cast<uint8_t *>((void*) data_ptr);
2587
+
2588
+
2589
+ srcOffsetValue =
2590
+ srcOffsetValue * size;
2591
+ if (srcOffsetValue > size) {
2592
+ return;
2593
+ }
2594
+
2595
+
2596
+ canvas_native_webgl2_tex_sub_image3d_offset(
2597
+ target,
2598
+ level,
2599
+ xoffset,
2600
+ yoffset,
2601
+ zoffset,
2602
+ width,
2603
+ height,
2604
+ depth,
2605
+ format,
2606
+ type,
2607
+ data, size,
2608
+ srcOffsetValue,
2609
+ ptr->GetState()
2610
+ );
2611
+ }
2612
+ }
2613
+ }
2614
+
2615
+ void
2616
+ WebGL2RenderingContext::TransformFeedbackVaryings(const v8::FunctionCallbackInfo<v8::Value> &args) {
2617
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2618
+ if (ptr == nullptr) {
2619
+ return;
2620
+ }
2621
+
2622
+ auto isolate = args.GetIsolate();
2623
+ auto context = isolate->GetCurrentContext();
2624
+
2625
+ auto programValue = args[0];
2626
+ auto type = GetNativeType(isolate, programValue);
2627
+ if (args.Length() > 2 && type == NativeType::WebGLProgram) {
2628
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
2629
+ auto varyingsObject = args[1];
2630
+ auto bufferMode = (uint32_t) args[2]->NumberValue(
2631
+ context).ToChecked();
2632
+
2633
+ if (program != nullptr &&
2634
+ varyingsObject->IsArray()) {
2635
+ auto varyings = varyingsObject.As<v8::Array>();
2636
+ auto len = varyings->Length();
2637
+
2638
+
2639
+ std::vector<std::string> store;
2640
+ store.reserve(len);
2641
+
2642
+ for (int j = 0; j < len; ++j) {
2643
+ auto name = ConvertFromV8String(isolate, varyings->Get(
2644
+ context, j).ToLocalChecked());
2645
+
2646
+ store.push_back(name);
2647
+ }
2648
+
2649
+
2650
+ const char* cStrings[store.size()];
2651
+ for (size_t i = 0; i < store.size(); ++i) {
2652
+ cStrings[i] = store[i].c_str();
2653
+ }
2654
+
2655
+ canvas_native_webgl2_transform_feedback_varyings(
2656
+ program->GetProgram(),
2657
+ cStrings, store.size(),
2658
+ bufferMode,
2659
+ ptr->GetState()
2660
+ );
2661
+ }
2662
+ }
2663
+
2664
+ }
2665
+
2666
+ void WebGL2RenderingContext::Uniform1ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2667
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2668
+ if (ptr == nullptr) {
2669
+ return;
2670
+ }
2671
+
2672
+ auto isolate = args.GetIsolate();
2673
+ auto context = isolate->GetCurrentContext();
2674
+
2675
+ auto locationValue = args[0];
2676
+ auto type = GetNativeType(isolate, locationValue);
2677
+
2678
+ if (args.Length() > 1 &&
2679
+ args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2680
+
2681
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2682
+ auto v0 = (uint32_t) args[1]->NumberValue(
2683
+ context).ToChecked();
2684
+
2685
+ if (location != nullptr) {
2686
+ canvas_native_webgl2_uniform1ui(
2687
+ location->GetUniformLocation(),
2688
+ v0,
2689
+ ptr->GetState()
2690
+ );
2691
+ }
2692
+ }
2693
+
2694
+ }
2695
+
2696
+ void WebGL2RenderingContext::Uniform2ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2697
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2698
+ if (ptr == nullptr) {
2699
+ return;
2700
+ }
2701
+
2702
+ auto isolate = args.GetIsolate();
2703
+ auto context = isolate->GetCurrentContext();
2704
+
2705
+ auto locationValue = args[0];
2706
+ auto type = GetNativeType(isolate, locationValue);
2707
+
2708
+ if (args.Length() > 2 &&
2709
+ args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2710
+
2711
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2712
+ auto v0 = (uint32_t) args[1]->NumberValue(
2713
+ context).ToChecked();
2714
+ auto v1 = (uint32_t) args[2]->NumberValue(
2715
+ context).ToChecked();
2716
+
2717
+ if (location != nullptr) {
2718
+ canvas_native_webgl2_uniform2ui(
2719
+ location->GetUniformLocation(),
2720
+ v0,
2721
+ v1,
2722
+ ptr->GetState()
2723
+ );
2724
+ }
2725
+ }
2726
+
2727
+ }
2728
+
2729
+ void WebGL2RenderingContext::Uniform3ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2730
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2731
+ if (ptr == nullptr) {
2732
+ return;
2733
+ }
2734
+
2735
+ auto isolate = args.GetIsolate();
2736
+ auto context = isolate->GetCurrentContext();
2737
+
2738
+ auto locationValue = args[0];
2739
+ auto type = GetNativeType(isolate, locationValue);
2740
+
2741
+ if (args.Length() > 3 &&
2742
+ args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2743
+
2744
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2745
+ auto v0 = (uint32_t) args[1]->NumberValue(
2746
+ context).ToChecked();
2747
+
2748
+ auto v1 = (uint32_t) args[2]->NumberValue(
2749
+ context).ToChecked();
2750
+
2751
+ auto v2 = (uint32_t) args[3]->NumberValue(
2752
+ context).ToChecked();
2753
+
2754
+ if (location != nullptr) {
2755
+ canvas_native_webgl2_uniform3ui(
2756
+ location->GetUniformLocation(),
2757
+ v0,
2758
+ v1,
2759
+ v2,
2760
+ ptr->GetState()
2761
+ );
2762
+ }
2763
+ }
2764
+
2765
+ }
2766
+
2767
+ void WebGL2RenderingContext::Uniform4ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
2768
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2769
+ if (ptr == nullptr) {
2770
+ return;
2771
+ }
2772
+
2773
+ auto isolate = args.GetIsolate();
2774
+ auto context = isolate->GetCurrentContext();
2775
+
2776
+ auto locationValue = args[0];
2777
+ auto type = GetNativeType(isolate, locationValue);
2778
+
2779
+ if (args.Length() > 1 &&
2780
+ args[1]->IsNumber() && type == NativeType::WebGLUniformLocation) {
2781
+
2782
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2783
+ auto v0 = (uint32_t) args[1]->NumberValue(
2784
+ context).ToChecked();
2785
+
2786
+ auto v1 = (uint32_t) args[2]->NumberValue(
2787
+ context).ToChecked();
2788
+
2789
+ auto v2 = (uint32_t) args[3]->NumberValue(
2790
+ context).ToChecked();
2791
+ auto v3 = (uint32_t) args[4]->NumberValue(
2792
+ context).ToChecked();
2793
+
2794
+
2795
+ if (location != nullptr) {
2796
+ canvas_native_webgl2_uniform4ui(
2797
+ location->GetUniformLocation(),
2798
+ v0,
2799
+ v1,
2800
+ v2,
2801
+ v3,
2802
+ ptr->GetState()
2803
+ );
2804
+ }
2805
+ }
2806
+
2807
+ }
2808
+
2809
+ void WebGL2RenderingContext::Uniform1uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2810
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2811
+ if (ptr == nullptr) {
2812
+ return;
2813
+ }
2814
+
2815
+ auto isolate = args.GetIsolate();
2816
+ auto context = isolate->GetCurrentContext();
2817
+
2818
+
2819
+ auto locationValue = args[0];
2820
+ auto type = GetNativeType(isolate, locationValue);
2821
+
2822
+
2823
+ if (args.Length() > 1 &&
2824
+ args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2825
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2826
+ auto data = args[1];
2827
+ if (location != nullptr &&
2828
+ data->IsUint32Array()) {
2829
+ auto buf = data.As<v8::Uint32Array>();
2830
+ auto array = buf->Buffer();
2831
+ auto offset = buf->ByteOffset();
2832
+ auto size = buf->Length();
2833
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2834
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
2835
+
2836
+
2837
+ canvas_native_webgl2_uniform1uiv(
2838
+ location->GetUniformLocation(),
2839
+ data, size,
2840
+ ptr->GetState()
2841
+ );
2842
+ } else {
2843
+ std::vector<uint32_t> buf;
2844
+ auto array = data.As<v8::Array>();
2845
+ auto len = array->Length();
2846
+ buf.reserve(len);
2847
+ for (int i = 0; i < len; i++) {
2848
+ auto item = (uint32_t) array->Get(
2849
+ context,
2850
+ i).ToLocalChecked()->NumberValue(
2851
+ context).ToChecked();
2852
+ buf.push_back(item);
2853
+ }
2854
+
2855
+ canvas_native_webgl2_uniform1uiv(
2856
+ location->GetUniformLocation(),
2857
+ buf.data(), buf.size(),
2858
+ ptr->GetState()
2859
+ );
2860
+ }
2861
+
2862
+
2863
+ }
2864
+
2865
+ }
2866
+
2867
+ void WebGL2RenderingContext::Uniform2uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2868
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2869
+ if (ptr == nullptr) {
2870
+ return;
2871
+ }
2872
+
2873
+ auto isolate = args.GetIsolate();
2874
+ auto context = isolate->GetCurrentContext();
2875
+
2876
+
2877
+ auto locationValue = args[0];
2878
+ auto type = GetNativeType(isolate, locationValue);
2879
+
2880
+
2881
+ if (args.Length() > 1 &&
2882
+ args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2883
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2884
+ auto data = args[1];
2885
+ if (location != nullptr &&
2886
+ data->IsUint32Array()) {
2887
+ auto buf = data.As<v8::Uint32Array>();
2888
+ auto array = buf->Buffer();
2889
+ auto offset = buf->ByteOffset();
2890
+ auto size = buf->Length();
2891
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2892
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
2893
+
2894
+
2895
+
2896
+ canvas_native_webgl2_uniform2uiv(
2897
+ location->GetUniformLocation(),
2898
+ data, size,
2899
+ ptr->GetState()
2900
+ );
2901
+ } else {
2902
+ std::vector<uint32_t> buf;
2903
+ auto array = data.As<v8::Array>();
2904
+ auto len = array->Length();
2905
+ buf.reserve(len);
2906
+ for (int i = 0; i < len; i++) {
2907
+ auto item = (uint32_t) array->Get(
2908
+ context,
2909
+ i).ToLocalChecked()->NumberValue(
2910
+ context).ToChecked();
2911
+ buf.push_back(item);
2912
+ }
2913
+ canvas_native_webgl2_uniform2uiv(
2914
+ location->GetUniformLocation(),
2915
+ buf.data(), buf.size(),
2916
+ ptr->GetState()
2917
+ );
2918
+ }
2919
+
2920
+
2921
+ }
2922
+
2923
+ }
2924
+
2925
+ void WebGL2RenderingContext::Uniform3uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2926
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2927
+ if (ptr == nullptr) {
2928
+ return;
2929
+ }
2930
+
2931
+ auto isolate = args.GetIsolate();
2932
+ auto context = isolate->GetCurrentContext();
2933
+
2934
+
2935
+ auto locationValue = args[0];
2936
+ auto type = GetNativeType(isolate, locationValue);
2937
+
2938
+
2939
+ if (args.Length() > 1 &&
2940
+ args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2941
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
2942
+ auto data = args[1];
2943
+ if (location != nullptr &&
2944
+ data->IsUint32Array()) {
2945
+ auto buf = data.As<v8::Uint32Array>();
2946
+
2947
+ auto array = buf->Buffer();
2948
+ auto offset = buf->ByteOffset();
2949
+ auto size = buf->Length();
2950
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
2951
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
2952
+
2953
+
2954
+ canvas_native_webgl2_uniform3uiv(
2955
+ location->GetUniformLocation(),
2956
+ data, size,
2957
+ ptr->GetState()
2958
+ );
2959
+ } else {
2960
+ std::vector<uint32_t> buf;
2961
+ auto array = data.As<v8::Array>();
2962
+ auto len = array->Length();
2963
+ buf.reserve(len);
2964
+ for (int i = 0; i < len; i++) {
2965
+ auto item = (uint32_t) array->Get(
2966
+ context,
2967
+ i).ToLocalChecked()->NumberValue(
2968
+ context).ToChecked();
2969
+ buf.push_back(item);
2970
+ }
2971
+ canvas_native_webgl2_uniform3uiv(
2972
+ location->GetUniformLocation(),
2973
+ buf.data(), buf.size(),
2974
+ ptr->GetState()
2975
+ );
2976
+ }
2977
+
2978
+
2979
+ }
2980
+
2981
+ }
2982
+
2983
+ void WebGL2RenderingContext::Uniform4uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
2984
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
2985
+ if (ptr == nullptr) {
2986
+ return;
2987
+ }
2988
+
2989
+ auto isolate = args.GetIsolate();
2990
+ auto context = isolate->GetCurrentContext();
2991
+
2992
+
2993
+ auto locationValue = args[0];
2994
+ auto type = GetNativeType(isolate, locationValue);
2995
+
2996
+
2997
+ if (args.Length() > 1 &&
2998
+ args[1]->IsObject() && type == NativeType::WebGLUniformLocation) {
2999
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3000
+ auto data = args[1];
3001
+ if (location != nullptr &&
3002
+ data->IsUint32Array()) {
3003
+ auto buf = data.As<v8::Uint32Array>();
3004
+
3005
+ auto array = buf->Buffer();
3006
+ auto offset = buf->ByteOffset();
3007
+ auto size = buf->Length();
3008
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3009
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
3010
+
3011
+
3012
+ canvas_native_webgl2_uniform4uiv(
3013
+ location->GetUniformLocation(),
3014
+ data, size,
3015
+ ptr->GetState()
3016
+ );
3017
+ } else {
3018
+ std::vector<uint32_t> buf;
3019
+ auto array = data.As<v8::Array>();
3020
+ auto len = array->Length();
3021
+ buf.reserve(len);
3022
+ for (int i = 0; i < len; i++) {
3023
+ auto item = (uint32_t) array->Get(
3024
+ context,
3025
+ i).ToLocalChecked()->NumberValue(
3026
+ context).ToChecked();
3027
+ buf.push_back(item);
3028
+ }
3029
+
3030
+ canvas_native_webgl2_uniform4uiv(
3031
+ location->GetUniformLocation(),
3032
+ buf.data(), buf.size(),
3033
+ ptr->GetState()
3034
+ );
3035
+ }
3036
+
3037
+ }
3038
+
3039
+ }
3040
+
3041
+ void WebGL2RenderingContext::UniformBlockBinding(const v8::FunctionCallbackInfo<v8::Value> &args) {
3042
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3043
+ if (ptr == nullptr) {
3044
+ return;
3045
+ }
3046
+
3047
+ auto isolate = args.GetIsolate();
3048
+ auto context = isolate->GetCurrentContext();
3049
+
3050
+
3051
+ auto programValue = args[0];
3052
+ auto type = GetNativeType(isolate, programValue);
3053
+ if (args.Length() > 2 && type == NativeType::WebGLProgram) {
3054
+
3055
+ auto program = WebGLProgram::GetPointer(programValue.As<v8::Object>());
3056
+ auto uniformBlockIndex = args[1]->NumberValue(
3057
+ context).ToChecked();
3058
+ auto uniformBlockBinding = args[2]->NumberValue(
3059
+ context).ToChecked();
3060
+
3061
+ if (program != nullptr) {
3062
+ canvas_native_webgl2_uniform_block_binding(
3063
+ program->GetProgram(),
3064
+ (uint32_t) uniformBlockIndex,
3065
+ (uint32_t) uniformBlockBinding,
3066
+ ptr->GetState()
3067
+ );
3068
+ }
3069
+
3070
+ }
3071
+
3072
+ }
3073
+
3074
+ void WebGL2RenderingContext::UniformMatrix2x3fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3075
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3076
+ if (ptr == nullptr) {
3077
+ return;
3078
+ }
3079
+
3080
+ auto isolate = args.GetIsolate();
3081
+ auto context = isolate->GetCurrentContext();
3082
+
3083
+
3084
+ if (args.Length() > 2 &&
3085
+ args[2]->IsObject()) {
3086
+ auto locationValue = args[0];
3087
+ auto type = GetNativeType(isolate, locationValue);
3088
+ if (type == NativeType::WebGLUniformLocation) {
3089
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3090
+ auto transpose = args[1]->BooleanValue(isolate);
3091
+ auto data = args[2];
3092
+
3093
+ if (data->IsFloat32Array()) {
3094
+ auto buf = data.As<v8::Float32Array>();
3095
+ auto array = buf->Buffer();
3096
+ auto offset = buf->ByteOffset();
3097
+ auto size = buf->Length();
3098
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3099
+ auto data = static_cast<float *>((void*) data_ptr);
3100
+
3101
+
3102
+ canvas_native_webgl2_uniform_matrix2x3fv(
3103
+ location->GetUniformLocation(),
3104
+ transpose,
3105
+ data, size,
3106
+ ptr->GetState()
3107
+ );
3108
+ } else if (data->IsArray()) {
3109
+ std::vector<float> buf;
3110
+ auto array = data.As<v8::Array>();
3111
+ auto len = array->Length();
3112
+ for (int i = 0; i < len; i++) {
3113
+ auto item = array->Get(
3114
+ context, i).ToLocalChecked();
3115
+ if (item->IsNumber()) {
3116
+ buf.push_back(
3117
+ static_cast<float>(item->NumberValue(
3118
+ context).ToChecked()));
3119
+ } else {
3120
+ buf.push_back(
3121
+ std::nanf(""));
3122
+ }
3123
+ }
3124
+
3125
+
3126
+ canvas_native_webgl2_uniform_matrix2x3fv(
3127
+ location->GetUniformLocation(),
3128
+ transpose,
3129
+ buf.data(), buf.size(),
3130
+ ptr->GetState()
3131
+ );
3132
+ }
3133
+ }
3134
+
3135
+ }
3136
+
3137
+ }
3138
+
3139
+ void WebGL2RenderingContext::UniformMatrix2x4fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3140
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3141
+ if (ptr == nullptr) {
3142
+ return;
3143
+ }
3144
+
3145
+ auto isolate = args.GetIsolate();
3146
+ auto context = isolate->GetCurrentContext();
3147
+
3148
+
3149
+ if (args.Length() > 2 &&
3150
+ args[2]->IsObject()) {
3151
+ auto locationValue = args[0];
3152
+ auto type = GetNativeType(isolate, locationValue);
3153
+ if (type == NativeType::WebGLUniformLocation) {
3154
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3155
+ auto transpose = args[1]->BooleanValue(isolate);
3156
+ auto data = args[2];
3157
+
3158
+ if (data->IsFloat32Array()) {
3159
+ auto buf = data.As<v8::Float32Array>();
3160
+
3161
+ auto array = buf->Buffer();
3162
+ auto offset = buf->ByteOffset();
3163
+ auto size = buf->Length();
3164
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3165
+ auto data = static_cast<float *>((void*) data_ptr);
3166
+
3167
+
3168
+ canvas_native_webgl2_uniform_matrix2x4fv(
3169
+ location->GetUniformLocation(),
3170
+ transpose,
3171
+ data, size,
3172
+ ptr->GetState()
3173
+ );
3174
+ } else if (data->IsArray()) {
3175
+ std::vector<float> buf;
3176
+ auto array = data.As<v8::Array>();
3177
+ auto len = array->Length();
3178
+ for (int i = 0; i < len; i++) {
3179
+ auto item = array->Get(
3180
+ context, i).ToLocalChecked();
3181
+ if (item->IsNumber()) {
3182
+ buf.push_back(
3183
+ static_cast<float>(item->NumberValue(
3184
+ context).ToChecked()));
3185
+ } else {
3186
+ buf.push_back(
3187
+ std::nanf(""));
3188
+ }
3189
+ }
3190
+
3191
+
3192
+
3193
+ canvas_native_webgl2_uniform_matrix2x4fv(
3194
+ location->GetUniformLocation(),
3195
+ transpose,
3196
+ buf.data(), buf.size(),
3197
+ ptr->GetState()
3198
+ );
3199
+ }
3200
+ }
3201
+
3202
+ }
3203
+
3204
+ }
3205
+
3206
+ void WebGL2RenderingContext::UniformMatrix3x2fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3207
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3208
+ if (ptr == nullptr) {
3209
+ return;
3210
+ }
3211
+
3212
+ auto isolate = args.GetIsolate();
3213
+ auto context = isolate->GetCurrentContext();
3214
+
3215
+
3216
+ if (args.Length() > 2 &&
3217
+ args[2]->IsObject()) {
3218
+ auto locationValue = args[0];
3219
+ auto type = GetNativeType(isolate, locationValue);
3220
+ if (type == NativeType::WebGLUniformLocation) {
3221
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3222
+ auto transpose = args[1]->BooleanValue(isolate);
3223
+ auto data = args[2];
3224
+
3225
+ if (data->IsFloat32Array()) {
3226
+ auto buf = data.As<v8::Float32Array>();
3227
+
3228
+
3229
+ auto array = buf->Buffer();
3230
+ auto offset = buf->ByteOffset();
3231
+ auto size = buf->Length();
3232
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3233
+ auto data = static_cast<float *>((void*) data_ptr);
3234
+
3235
+
3236
+ canvas_native_webgl2_uniform_matrix3x2fv(
3237
+ location->GetUniformLocation(),
3238
+ transpose,
3239
+ data, size,
3240
+ ptr->GetState()
3241
+ );
3242
+ } else if (data->IsArray()) {
3243
+ std::vector<float> buf;
3244
+ auto array = data.As<v8::Array>();
3245
+ auto len = array->Length();
3246
+ for (int i = 0; i < len; i++) {
3247
+ auto item = array->Get(
3248
+ context, i).ToLocalChecked();
3249
+ if (item->IsNumber()) {
3250
+ buf.push_back(
3251
+ static_cast<float>(item->NumberValue(
3252
+ context).ToChecked()));
3253
+ } else {
3254
+ buf.push_back(
3255
+ std::nanf(""));
3256
+ }
3257
+ }
3258
+
3259
+
3260
+
3261
+ canvas_native_webgl2_uniform_matrix3x2fv(
3262
+ location->GetUniformLocation(),
3263
+ transpose,
3264
+ buf.data(), buf.size(),
3265
+ ptr->GetState()
3266
+ );
3267
+ }
3268
+ }
3269
+
3270
+ }
3271
+
3272
+ }
3273
+
3274
+ void WebGL2RenderingContext::UniformMatrix3x4fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3275
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3276
+ if (ptr == nullptr) {
3277
+ return;
3278
+ }
3279
+
3280
+ auto isolate = args.GetIsolate();
3281
+ auto context = isolate->GetCurrentContext();
3282
+
3283
+
3284
+ if (args.Length() > 2 &&
3285
+ args[2]->IsObject()) {
3286
+ auto locationValue = args[0];
3287
+ auto type = GetNativeType(isolate, locationValue);
3288
+ if (type == NativeType::WebGLUniformLocation) {
3289
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3290
+ auto transpose = args[1]->BooleanValue(isolate);
3291
+ auto data = args[2];
3292
+
3293
+ if (data->IsFloat32Array()) {
3294
+ auto buf = data.As<v8::Float32Array>();
3295
+ auto array = buf->Buffer();
3296
+ auto offset = buf->ByteOffset();
3297
+ auto size = buf->Length();
3298
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3299
+ auto data = static_cast<float *>((void*) data_ptr);
3300
+
3301
+
3302
+ canvas_native_webgl2_uniform_matrix3x4fv(
3303
+ location->GetUniformLocation(),
3304
+ transpose,
3305
+ data, size,
3306
+ ptr->GetState()
3307
+ );
3308
+ } else if (data->IsArray()) {
3309
+ std::vector<float> buf;
3310
+ auto array = data.As<v8::Array>();
3311
+ auto len = array->Length();
3312
+ for (int i = 0; i < len; i++) {
3313
+ auto item = array->Get(
3314
+ context, i).ToLocalChecked();
3315
+ if (item->IsNumber()) {
3316
+ buf.push_back(
3317
+ static_cast<float>(item->NumberValue(
3318
+ context).ToChecked()));
3319
+ } else {
3320
+ buf.push_back(
3321
+ std::nanf(""));
3322
+ }
3323
+ }
3324
+
3325
+
3326
+
3327
+ canvas_native_webgl2_uniform_matrix3x4fv(
3328
+ location->GetUniformLocation(),
3329
+ transpose,
3330
+ buf.data(), buf.size(),
3331
+ ptr->GetState()
3332
+ );
3333
+ }
3334
+ }
3335
+
3336
+ }
3337
+
3338
+ }
3339
+
3340
+ void WebGL2RenderingContext::UniformMatrix4x2fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3341
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3342
+ if (ptr == nullptr) {
3343
+ return;
3344
+ }
3345
+
3346
+ auto isolate = args.GetIsolate();
3347
+ auto context = isolate->GetCurrentContext();
3348
+
3349
+
3350
+ if (args.Length() > 2 &&
3351
+ args[2]->IsObject()) {
3352
+ auto locationValue = args[0];
3353
+ auto type = GetNativeType(isolate, locationValue);
3354
+ if (type == NativeType::WebGLUniformLocation) {
3355
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3356
+ auto transpose = args[1]->BooleanValue(isolate);
3357
+ auto data = args[2];
3358
+
3359
+ if (data->IsFloat32Array()) {
3360
+ auto buf = data.As<v8::Float32Array>();
3361
+
3362
+ auto array = buf->Buffer();
3363
+ auto offset = buf->ByteOffset();
3364
+ auto size = buf->Length();
3365
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3366
+ auto data = static_cast<float *>((void*) data_ptr);
3367
+
3368
+ canvas_native_webgl2_uniform_matrix4x2fv(
3369
+ location->GetUniformLocation(),
3370
+ transpose,
3371
+ data, size,
3372
+ ptr->GetState()
3373
+ );
3374
+ } else if (data->IsArray()) {
3375
+ std::vector<float> buf;
3376
+ auto array = data.As<v8::Array>();
3377
+ auto len = array->Length();
3378
+ for (int i = 0; i < len; i++) {
3379
+ auto item = array->Get(
3380
+ context, i).ToLocalChecked();
3381
+ if (item->IsNumber()) {
3382
+ buf.push_back(
3383
+ static_cast<float>(item->NumberValue(
3384
+ context).ToChecked()));
3385
+ } else {
3386
+ buf.push_back(
3387
+ std::nanf(""));
3388
+ }
3389
+ }
3390
+
3391
+
3392
+
3393
+ canvas_native_webgl2_uniform_matrix4x2fv(
3394
+ location->GetUniformLocation(),
3395
+ transpose,
3396
+ buf.data(), buf.size(),
3397
+ ptr->GetState()
3398
+ );
3399
+ }
3400
+ }
3401
+
3402
+ }
3403
+
3404
+ }
3405
+
3406
+ void WebGL2RenderingContext::UniformMatrix4x3fv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3407
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3408
+ if (ptr == nullptr) {
3409
+ return;
3410
+ }
3411
+
3412
+ auto isolate = args.GetIsolate();
3413
+ auto context = isolate->GetCurrentContext();
3414
+
3415
+
3416
+ if (args.Length() > 2 &&
3417
+ args[2]->IsObject()) {
3418
+ auto locationValue = args[0];
3419
+ auto type = GetNativeType(isolate, locationValue);
3420
+ if (type == NativeType::WebGLUniformLocation) {
3421
+ auto location = WebGLUniformLocation::GetPointer(locationValue.As<v8::Object>());
3422
+ auto transpose = args[1]->BooleanValue(isolate);
3423
+ auto data = args[2];
3424
+
3425
+ if (data->IsFloat32Array()) {
3426
+ auto buf = data.As<v8::Float32Array>();
3427
+ auto array = buf->Buffer();
3428
+ auto offset = buf->ByteOffset();
3429
+ auto size = buf->Length();
3430
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3431
+ auto data = static_cast<float *>((void*) data_ptr);
3432
+
3433
+ canvas_native_webgl2_uniform_matrix4x3fv(
3434
+ location->GetUniformLocation(),
3435
+ transpose,
3436
+ data, size,
3437
+ ptr->GetState()
3438
+ );
3439
+ } else if (data->IsArray()) {
3440
+ std::vector<float> buf;
3441
+ auto array = data.As<v8::Array>();
3442
+ auto len = array->Length();
3443
+ for (int i = 0; i < len; i++) {
3444
+ auto item = array->Get(
3445
+ context, i).ToLocalChecked();
3446
+ if (item->IsNumber()) {
3447
+ buf.push_back(
3448
+ static_cast<float>(item->NumberValue(
3449
+ context).ToChecked()));
3450
+ } else {
3451
+ buf.push_back(
3452
+ std::nanf(""));
3453
+ }
3454
+ }
3455
+
3456
+
3457
+ canvas_native_webgl2_uniform_matrix4x3fv(
3458
+ location->GetUniformLocation(),
3459
+ transpose,
3460
+ buf.data(), buf.size(),
3461
+ ptr->GetState()
3462
+ );
3463
+ }
3464
+ }
3465
+
3466
+ }
3467
+
3468
+ }
3469
+
3470
+ void WebGL2RenderingContext::VertexAttribDivisor(const v8::FunctionCallbackInfo<v8::Value> &args) {
3471
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3472
+ if (ptr == nullptr) {
3473
+ return;
3474
+ }
3475
+
3476
+ auto isolate = args.GetIsolate();
3477
+ auto context = isolate->GetCurrentContext();
3478
+
3479
+
3480
+ if (args.Length() > 1) {
3481
+ auto index = args[0]->NumberValue(
3482
+ context).ToChecked();
3483
+ auto divisor = args[1]->NumberValue(
3484
+ context).ToChecked();
3485
+ canvas_native_webgl2_vertex_attrib_divisor(
3486
+ (uint32_t) index,
3487
+ (uint32_t) divisor,
3488
+ ptr->GetState()
3489
+ );
3490
+ }
3491
+
3492
+ }
3493
+
3494
+ void WebGL2RenderingContext::VertexAttribI4i(const v8::FunctionCallbackInfo<v8::Value> &args) {
3495
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3496
+ if (ptr == nullptr) {
3497
+ return;
3498
+ }
3499
+
3500
+ auto isolate = args.GetIsolate();
3501
+ auto context = isolate->GetCurrentContext();
3502
+
3503
+
3504
+ if (args.Length() > 4) {
3505
+ auto index = args[0]->NumberValue(
3506
+ context).ToChecked();
3507
+ auto v0 = args[1]->NumberValue(
3508
+ context).ToChecked();
3509
+ auto v1 = args[2]->NumberValue(
3510
+ context).ToChecked();
3511
+ auto v2 = args[3]->NumberValue(
3512
+ context).ToChecked();
3513
+ auto v3 = args[4]->NumberValue(
3514
+ context).ToChecked();
3515
+ canvas_native_webgl2_vertex_attrib_i4i(
3516
+ (uint32_t) index,
3517
+ (int32_t) v0,
3518
+ (int32_t) v1,
3519
+ (int32_t) v2,
3520
+ (int32_t) v3,
3521
+ ptr->GetState()
3522
+ );
3523
+ }
3524
+
3525
+ }
3526
+
3527
+ void WebGL2RenderingContext::VertexAttribI4iv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3528
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3529
+ if (ptr == nullptr) {
3530
+ return;
3531
+ }
3532
+
3533
+ auto isolate = args.GetIsolate();
3534
+ auto context = isolate->GetCurrentContext();
3535
+
3536
+
3537
+ if (args.Length() > 1 &&
3538
+ args[1]->IsObject()) {
3539
+ auto index = (uint32_t) args[0]->NumberValue(
3540
+ context).ToChecked();
3541
+ auto value = args[1];
3542
+ if (value->IsInt32Array()) {
3543
+ auto buf = value.As<v8::Int32Array>();
3544
+
3545
+ auto array = buf->Buffer();
3546
+ auto offset = buf->ByteOffset();
3547
+ auto size = buf->Length();
3548
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3549
+ auto data = static_cast<int32_t *>((void*) data_ptr);
3550
+
3551
+
3552
+ canvas_native_webgl2_vertex_attrib_i4iv(
3553
+ index,
3554
+ data, size,
3555
+ ptr->GetState()
3556
+ );
3557
+ } else if (value->IsArray()) {
3558
+ auto array = value.As<v8::Array>();
3559
+ auto len = array->Length();
3560
+ std::vector<int32_t> buf;
3561
+ buf.reserve(len);
3562
+ for (int i = 0; i < len; i++) {
3563
+ auto item = (int32_t) array->Get(
3564
+ context,
3565
+ i).ToLocalChecked()->NumberValue(
3566
+ context).ToChecked();
3567
+ buf.push_back(item);
3568
+ }
3569
+
3570
+
3571
+ canvas_native_webgl2_vertex_attrib_i4iv(
3572
+ index,
3573
+ buf.data(), buf.size(),
3574
+ ptr->GetState()
3575
+ );
3576
+ }
3577
+ }
3578
+
3579
+ }
3580
+
3581
+ void WebGL2RenderingContext::VertexAttribI4ui(const v8::FunctionCallbackInfo<v8::Value> &args) {
3582
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3583
+ if (ptr == nullptr) {
3584
+ return;
3585
+ }
3586
+
3587
+ auto isolate = args.GetIsolate();
3588
+ auto context = isolate->GetCurrentContext();
3589
+
3590
+
3591
+ if (args.Length() > 4) {
3592
+ auto index = (uint32_t) args[0]->NumberValue(
3593
+ context).ToChecked();
3594
+ auto v0 = (uint32_t) args[1]->NumberValue(
3595
+ context).ToChecked();
3596
+ auto v1 = (uint32_t) args[2]->NumberValue(
3597
+ context).ToChecked();
3598
+ auto v2 = (uint32_t) args[3]->NumberValue(
3599
+ context).ToChecked();
3600
+ auto v3 = (uint32_t) args[4]->NumberValue(
3601
+ context).ToChecked();
3602
+
3603
+ canvas_native_webgl2_vertex_attrib_i4ui(
3604
+ index,
3605
+ v0,
3606
+ v1,
3607
+ v2,
3608
+ v3,
3609
+ ptr->GetState()
3610
+ );
3611
+ }
3612
+
3613
+ }
3614
+
3615
+ void WebGL2RenderingContext::VertexAttribI4uiv(const v8::FunctionCallbackInfo<v8::Value> &args) {
3616
+ WebGL2RenderingContext *ptr = GetPointer(args.This());
3617
+ if (ptr == nullptr) {
3618
+ return;
3619
+ }
3620
+
3621
+ auto isolate = args.GetIsolate();
3622
+ auto context = isolate->GetCurrentContext();
3623
+
3624
+
3625
+ if (args.Length() > 1 &&
3626
+ args[1]->IsObject()) {
3627
+ auto index = (uint32_t) args[0]->NumberValue(
3628
+ context).ToChecked();
3629
+ auto value = args[1];
3630
+ if (value->IsUint32Array()) {
3631
+ auto buf = value.As<v8::Uint32Array>();
3632
+ auto array = buf->Buffer();
3633
+ auto offset = buf->ByteOffset();
3634
+ auto size = buf->Length();
3635
+ auto data_ptr = static_cast<uint8_t*>(array->GetBackingStore()->Data()) + offset;
3636
+ auto data = static_cast<uint32_t *>((void*) data_ptr);
3637
+
3638
+
3639
+ canvas_native_webgl2_vertex_attrib_i4uiv(
3640
+ index,
3641
+ data, size,
3642
+ ptr->GetState()
3643
+ );
3644
+ } else if (value->IsArray()) {
3645
+ auto array = value.As<v8::Array>();
3646
+ auto len = array->Length();
3647
+ std::vector<uint32_t> buf;
3648
+ buf.reserve(len);
3649
+ for (int i = 0; i < len; i++) {
3650
+ auto item = (uint32_t) array->Get(
3651
+ context,
3652
+ i).ToLocalChecked()->NumberValue(
3653
+ context).ToChecked();
3654
+ buf.push_back(item);
3655
+ }
3656
+
3657
+
3658
+ canvas_native_webgl2_vertex_attrib_i4uiv(
3659
+ index,
3660
+ buf.data(), buf.size(),
3661
+ ptr->GetState()
3662
+ );
3663
+ }
3664
+ }
3665
+
3666
+ }
3667
+
3668
+ void WebGL2RenderingContext::SetConstants(v8::Isolate *isolate,
3669
+ const v8::Local<v8::ObjectTemplate> &tmpl) {
3670
+ /* Getting GL parameter information */
3671
+
3672
+ tmpl->Set(isolate, "READ_BUFFER", v8::Uint32::New(isolate, 0x0C02));
3673
+
3674
+ tmpl->Set(isolate, "UNPACK_ROW_LENGTH", v8::Uint32::New(isolate, 0x0CF2));
3675
+
3676
+ tmpl->Set(isolate, "UNPACK_SKIP_ROWS", v8::Uint32::New(isolate, 0x0CF3));
3677
+
3678
+ tmpl->Set(isolate, "UNPACK_SKIP_PIXELS", v8::Uint32::New(isolate, 0x0CF4));
3679
+
3680
+ tmpl->Set(isolate, "PACK_ROW_LENGTH", v8::Uint32::New(isolate, 0x0D02));
3681
+
3682
+ tmpl->Set(isolate, "PACK_SKIP_ROWS", v8::Uint32::New(isolate, 0x0D03));
3683
+
3684
+ tmpl->Set(isolate, "PACK_SKIP_PIXELS", v8::Uint32::New(isolate, 0x0D04));
3685
+
3686
+ tmpl->Set(isolate, "TEXTURE_BINDING_3D", v8::Uint32::New(isolate, 0x806A));
3687
+
3688
+ tmpl->Set(isolate, "UNPACK_SKIP_IMAGES", v8::Uint32::New(isolate, 0x806D));
3689
+
3690
+ tmpl->Set(isolate, "UNPACK_IMAGE_HEIGHT", v8::Uint32::New(isolate, 0x806E));
3691
+
3692
+ tmpl->Set(isolate, "MAX_3D_TEXTURE_SIZE", v8::Uint32::New(isolate, 0x8073));
3693
+
3694
+ tmpl->Set(isolate, "MAX_ELEMENTS_VERTICES", v8::Uint32::New(isolate, 0x80E8));
3695
+
3696
+ tmpl->Set(isolate, "MAX_ELEMENTS_INDICES", v8::Uint32::New(isolate, 0x80E9));
3697
+
3698
+ tmpl->Set(isolate, "MAX_TEXTURE_LOD_BIAS", v8::Uint32::New(isolate, 0x84FD));
3699
+
3700
+ tmpl->Set(isolate, "MAX_FRAGMENT_UNIFORM_COMPONENTS", v8::Uint32::New(isolate, 0x8B49));
3701
+
3702
+ tmpl->Set(isolate, "MAX_VERTEX_UNIFORM_COMPONENTS", v8::Uint32::New(isolate, 0x8B4A));
3703
+
3704
+ tmpl->Set(isolate, "MAX_ARRAY_TEXTURE_LAYERS", v8::Uint32::New(isolate, 0x88FF));
3705
+
3706
+ tmpl->Set(isolate, "MIN_PROGRAM_TEXEL_OFFSET", v8::Uint32::New(isolate, 0x8904));
3707
+
3708
+ tmpl->Set(isolate, "MAX_PROGRAM_TEXEL_OFFSET", v8::Uint32::New(isolate, 0x8905));
3709
+
3710
+ tmpl->Set(isolate, "MAX_VARYING_COMPONENTS", v8::Uint32::New(isolate, 0x8B4B));
3711
+
3712
+ tmpl->Set(isolate, "FRAGMENT_SHADER_DERIVATIVE_HINT", v8::Uint32::New(isolate, 0x8B8B));
3713
+
3714
+ tmpl->Set(isolate, "RASTERIZER_DISCARD", v8::Uint32::New(isolate, 0x8C89));
3715
+
3716
+ tmpl->Set(isolate, "VERTEX_ARRAY_BINDING", v8::Uint32::New(isolate, 0x85B5));
3717
+ tmpl->Set(isolate, "MAX_VERTEX_OUTPUT_COMPONENTS", v8::Uint32::New(isolate, 0x9122));
3718
+ tmpl->Set(isolate, "MAX_FRAGMENT_INPUT_COMPONENTS", v8::Uint32::New(isolate, 0x9125));
3719
+ tmpl->Set(isolate, "MAX_SERVER_WAIT_TIMEOUT", v8::Uint32::New(isolate, 0x9111));
3720
+ tmpl->Set(isolate, "MAX_ELEMENT_INDEX", v8::Uint32::New(isolate, 0x8D6B));
3721
+
3722
+ tmpl->Set(isolate, "RED", v8::Uint32::New(isolate, 0x1903));
3723
+ tmpl->Set(isolate, "RGB8", v8::Uint32::New(isolate, 0x8051));
3724
+ tmpl->Set(isolate, "RGBA8", v8::Uint32::New(isolate, 0x8058));
3725
+ tmpl->Set(isolate, "RGB10_A2", v8::Uint32::New(isolate, 0x8059));
3726
+ tmpl->Set(isolate, "TEXTURE_3D", v8::Uint32::New(isolate, 0x806F));
3727
+
3728
+ tmpl->Set(isolate, "TEXTURE_WRAP_R", v8::Uint32::New(isolate, 0x8072));
3729
+ tmpl->Set(isolate, "TEXTURE_MIN_LOD", v8::Uint32::New(isolate, 0x813A));
3730
+ tmpl->Set(isolate, "TEXTURE_MAX_LOD", v8::Uint32::New(isolate, 0x813B));
3731
+ tmpl->Set(isolate, "TEXTURE_BASE_LEVEL", v8::Uint32::New(isolate, 0x813C));
3732
+ tmpl->Set(isolate, "TEXTURE_MAX_LEVEL", v8::Uint32::New(isolate, 0x813D));
3733
+
3734
+
3735
+ tmpl->Set(isolate, "TEXTURE_COMPARE_MODE", v8::Uint32::New(isolate, 0x884C));
3736
+ tmpl->Set(isolate, "TEXTURE_COMPARE_FUNC", v8::Uint32::New(isolate, 0x884D));
3737
+ tmpl->Set(isolate, "SRGB", v8::Uint32::New(isolate, 0x8C40));
3738
+ tmpl->Set(isolate, "SRGB8", v8::Uint32::New(isolate, 0x8C41));
3739
+ tmpl->Set(isolate, "SRGB8_ALPHA8", v8::Uint32::New(isolate, 0x8C43));
3740
+
3741
+ tmpl->Set(isolate, "COMPARE_REF_TO_TEXTURE", v8::Uint32::New(isolate, 0x884E));
3742
+ tmpl->Set(isolate, "RGBA32F", v8::Uint32::New(isolate, 0x8814));
3743
+ tmpl->Set(isolate, "RGB32F", v8::Uint32::New(isolate, 0x8815));
3744
+ tmpl->Set(isolate, "RGBA16F", v8::Uint32::New(isolate, 0x881A));
3745
+ tmpl->Set(isolate, "RGB16F", v8::Uint32::New(isolate, 0x881B));
3746
+
3747
+ tmpl->Set(isolate, "TEXTURE_2D_ARRAY", v8::Uint32::New(isolate, 0x8C1A));
3748
+ tmpl->Set(isolate, "TEXTURE_BINDING_2D_ARRAY", v8::Uint32::New(isolate, 0x8C1D));
3749
+ tmpl->Set(isolate, "R11F_G11F_B10F", v8::Uint32::New(isolate, 0x8C3A));
3750
+ tmpl->Set(isolate, "RGB9_E5", v8::Uint32::New(isolate, 0x8C3D));
3751
+ tmpl->Set(isolate, "RGBA32UI", v8::Uint32::New(isolate, 0x8D70));
3752
+
3753
+
3754
+ tmpl->Set(isolate, "RGB32UI", v8::Uint32::New(isolate, 0x8D71));
3755
+ tmpl->Set(isolate, "RGBA16UI", v8::Uint32::New(isolate, 0x8D76));
3756
+ tmpl->Set(isolate, "RGB16UI", v8::Uint32::New(isolate, 0x8D77));
3757
+ tmpl->Set(isolate, "RGBA8UI", v8::Uint32::New(isolate, 0x8D7C));
3758
+ tmpl->Set(isolate, "RGB8UI", v8::Uint32::New(isolate, 0x8D7D));
3759
+
3760
+
3761
+ tmpl->Set(isolate, "RGBA32I", v8::Uint32::New(isolate, 0x8D82));
3762
+ tmpl->Set(isolate, "RGB32I", v8::Uint32::New(isolate, 0x8D83));
3763
+ tmpl->Set(isolate, "RGBA16I", v8::Uint32::New(isolate, 0x8D88));
3764
+ tmpl->Set(isolate, "RGB16I", v8::Uint32::New(isolate, 0x8D89));
3765
+ tmpl->Set(isolate, "RGBA8I", v8::Uint32::New(isolate, 0x8D8E));
3766
+
3767
+
3768
+ tmpl->Set(isolate, "RGB8I", v8::Uint32::New(isolate, 0x8D8F));
3769
+ tmpl->Set(isolate, "RED_INTEGER", v8::Uint32::New(isolate, 0x8D94));
3770
+ tmpl->Set(isolate, "RGB_INTEGER", v8::Uint32::New(isolate, 0x8D98));
3771
+ tmpl->Set(isolate, "RGBA_INTEGER", v8::Uint32::New(isolate, 0x8D99));
3772
+ tmpl->Set(isolate, "R8", v8::Uint32::New(isolate, 0x8229));
3773
+
3774
+
3775
+ tmpl->Set(isolate, "RG8", v8::Uint32::New(isolate, 0x822B));
3776
+ tmpl->Set(isolate, "R16F", v8::Uint32::New(isolate, 0x822D));
3777
+ tmpl->Set(isolate, "R32F", v8::Uint32::New(isolate, 0x822E));
3778
+ tmpl->Set(isolate, "RG16F", v8::Uint32::New(isolate, 0x822F));
3779
+ tmpl->Set(isolate, "RG32F", v8::Uint32::New(isolate, 0x8230));
3780
+
3781
+
3782
+ tmpl->Set(isolate, "R8I", v8::Uint32::New(isolate, 0x8231));
3783
+ tmpl->Set(isolate, "R8UI", v8::Uint32::New(isolate, 0x8232));
3784
+ tmpl->Set(isolate, "R16I", v8::Uint32::New(isolate, 0x8233));
3785
+ tmpl->Set(isolate, "R16UI", v8::Uint32::New(isolate, 0x8234));
3786
+ tmpl->Set(isolate, "R32I", v8::Uint32::New(isolate, 0x8235));
3787
+
3788
+
3789
+ tmpl->Set(isolate, "R32UI", v8::Uint32::New(isolate, 0x8236));
3790
+ tmpl->Set(isolate, "RG8I", v8::Uint32::New(isolate, 0x8237));
3791
+ tmpl->Set(isolate, "RG8UI", v8::Uint32::New(isolate, 0x8238));
3792
+ tmpl->Set(isolate, "RG16I", v8::Uint32::New(isolate, 0x8239));
3793
+ tmpl->Set(isolate, "RG16UI", v8::Uint32::New(isolate, 0x823A));
3794
+
3795
+ tmpl->Set(isolate, "RG32I", v8::Uint32::New(isolate, 0x823B));
3796
+ tmpl->Set(isolate, "RG32UI", v8::Uint32::New(isolate, 0x823C));
3797
+ tmpl->Set(isolate, "R8_SNORM", v8::Uint32::New(isolate, 0x8F94));
3798
+ tmpl->Set(isolate, "RG8_SNORM", v8::Uint32::New(isolate, 0x8F95));
3799
+ tmpl->Set(isolate, "RGB8_SNORM", v8::Uint32::New(isolate, 0x8F96));
3800
+
3801
+
3802
+ tmpl->Set(isolate, "RGBA8_SNORM", v8::Uint32::New(isolate, 0x8F97));
3803
+ tmpl->Set(isolate, "RGB10_A2UI", v8::Uint32::New(isolate, 0x906F));
3804
+ tmpl->Set(isolate, "TEXTURE_IMMUTABLE_FORMAT", v8::Uint32::New(isolate, 0x912F));
3805
+ tmpl->Set(isolate, "TEXTURE_IMMUTABLE_LEVELS", v8::Uint32::New(isolate, 0x82DF));
3806
+ tmpl->Set(isolate, "UNSIGNED_INT_2_10_10_10_REV", v8::Uint32::New(isolate, 0x8368));
3807
+
3808
+
3809
+ tmpl->Set(isolate, "UNSIGNED_INT_10F_11F_11F_REV", v8::Uint32::New(isolate, 0x8C3B));
3810
+ tmpl->Set(isolate, "UNSIGNED_INT_5_9_9_9_REV", v8::Uint32::New(isolate, 0x8C3E));
3811
+ tmpl->Set(isolate, "FLOAT_32_UNSIGNED_INT_24_8_REV", v8::Uint32::New(isolate, 0x8DAD));
3812
+ tmpl->Set(isolate, "UNSIGNED_INT_24_8", v8::Uint32::New(isolate, 0x84FA));
3813
+ tmpl->Set(isolate, "HALF_FLOAT", v8::Uint32::New(isolate, 0x140B));
3814
+
3815
+
3816
+ tmpl->Set(isolate, "RG", v8::Uint32::New(isolate, 0x8227));
3817
+ tmpl->Set(isolate, "RG_INTEGER", v8::Uint32::New(isolate, 0x8228));
3818
+ tmpl->Set(isolate, "INT_2_10_10_10_REV", v8::Uint32::New(isolate, 0x8D9F));
3819
+ tmpl->Set(isolate, "QUERY_RESULT_AVAILABLE", v8::Uint32::New(isolate, 0x8865));
3820
+ tmpl->Set(isolate, "QUERY_RESULT", v8::Uint32::New(isolate, 0x8866));
3821
+
3822
+
3823
+ tmpl->Set(isolate, "CURRENT_QUERY", v8::Uint32::New(isolate, 0x8867));
3824
+ tmpl->Set(isolate, "ANY_SAMPLES_PASSED", v8::Uint32::New(isolate, 0x8C2F));
3825
+ tmpl->Set(isolate, "ANY_SAMPLES_PASSED_CONSERVATIVE", v8::Uint32::New(isolate, 0x8D6A));
3826
+ tmpl->Set(isolate, "MAX_DRAW_BUFFERS", v8::Uint32::New(isolate, 0x8824));
3827
+
3828
+ tmpl->Set(isolate, "DRAW_BUFFER0", v8::Uint32::New(isolate, 0x8825));
3829
+ tmpl->Set(isolate, "DRAW_BUFFER1", v8::Uint32::New(isolate, 0x8826));
3830
+ tmpl->Set(isolate, "DRAW_BUFFER2", v8::Uint32::New(isolate, 0x8827));
3831
+ tmpl->Set(isolate, "DRAW_BUFFER3", v8::Uint32::New(isolate, 0x8828));
3832
+ tmpl->Set(isolate, "DRAW_BUFFER4", v8::Uint32::New(isolate, 0x8829));
3833
+ tmpl->Set(isolate, "DRAW_BUFFER5", v8::Uint32::New(isolate, 0x882A));
3834
+ tmpl->Set(isolate, "DRAW_BUFFER6", v8::Uint32::New(isolate, 0x882B));
3835
+ tmpl->Set(isolate, "DRAW_BUFFER7", v8::Uint32::New(isolate, 0x882C));
3836
+ tmpl->Set(isolate, "DRAW_BUFFER8", v8::Uint32::New(isolate, 0x882D));
3837
+ tmpl->Set(isolate, "DRAW_BUFFER9", v8::Uint32::New(isolate, 0x882E));
3838
+ tmpl->Set(isolate, "DRAW_BUFFER10", v8::Uint32::New(isolate, 0x882F));
3839
+
3840
+ /* Getting GL parameter information */
3841
+
3842
+ /* Textures */
3843
+
3844
+ tmpl->Set(isolate, "DRAW_BUFFER11", v8::Uint32::New(isolate, 0x8830));
3845
+ tmpl->Set(isolate, "DRAW_BUFFER12", v8::Uint32::New(isolate, 0x8831));
3846
+ tmpl->Set(isolate, "DRAW_BUFFER13", v8::Uint32::New(isolate, 0x8832));
3847
+ tmpl->Set(isolate, "DRAW_BUFFER14", v8::Uint32::New(isolate, 0x8833));
3848
+ tmpl->Set(isolate, "DRAW_BUFFER15", v8::Uint32::New(isolate, 0x8834));
3849
+
3850
+ tmpl->Set(isolate, "MAX_COLOR_ATTACHMENTS", v8::Uint32::New(isolate, 0x8CDF));
3851
+ tmpl->Set(isolate, "COLOR_ATTACHMENT1", v8::Uint32::New(isolate, 0x8CE1));
3852
+ tmpl->Set(isolate, "COLOR_ATTACHMENT2", v8::Uint32::New(isolate, 0x8CE2));
3853
+ tmpl->Set(isolate, "COLOR_ATTACHMENT3", v8::Uint32::New(isolate, 0x8CE3));
3854
+ tmpl->Set(isolate, "COLOR_ATTACHMENT4", v8::Uint32::New(isolate, 0x8CE4));
3855
+ tmpl->Set(isolate, "COLOR_ATTACHMENT5", v8::Uint32::New(isolate, 0x8CE5));
3856
+ tmpl->Set(isolate, "COLOR_ATTACHMENT6", v8::Uint32::New(isolate, 0x8CE6));
3857
+ tmpl->Set(isolate, "COLOR_ATTACHMENT7", v8::Uint32::New(isolate, 0x8CE7));
3858
+ tmpl->Set(isolate, "COLOR_ATTACHMENT8", v8::Uint32::New(isolate, 0x8CE8));
3859
+ tmpl->Set(isolate, "COLOR_ATTACHMENT9", v8::Uint32::New(isolate, 0x8CE9));
3860
+ tmpl->Set(isolate, "COLOR_ATTACHMENT10", v8::Uint32::New(isolate, 0x8CEA));
3861
+ tmpl->Set(isolate, "COLOR_ATTACHMENT11", v8::Uint32::New(isolate, 0x8CEB));
3862
+ tmpl->Set(isolate, "COLOR_ATTACHMENT12", v8::Uint32::New(isolate, 0x8CEC));
3863
+ tmpl->Set(isolate, "COLOR_ATTACHMENT13", v8::Uint32::New(isolate, 0x8CED));
3864
+ tmpl->Set(isolate, "COLOR_ATTACHMENT14", v8::Uint32::New(isolate, 0x8CEE));
3865
+ tmpl->Set(isolate, "COLOR_ATTACHMENT15", v8::Uint32::New(isolate, 0x8CEF));
3866
+
3867
+ tmpl->Set(isolate, "SAMPLER_3D", v8::Uint32::New(isolate, 0x8B5F));
3868
+ tmpl->Set(isolate, "SAMPLER_2D_SHADOW", v8::Uint32::New(isolate, 0x8B62));
3869
+ tmpl->Set(isolate, "SAMPLER_2D_ARRAY", v8::Uint32::New(isolate, 0x8DC1));
3870
+ tmpl->Set(isolate, "SAMPLER_2D_ARRAY_SHADOW", v8::Uint32::New(isolate, 0x8DC4));
3871
+ tmpl->Set(isolate, "SAMPLER_CUBE_SHADOW", v8::Uint32::New(isolate, 0x8DC5));
3872
+
3873
+ tmpl->Set(isolate, "INT_SAMPLER_2D", v8::Uint32::New(isolate, 0x8DCA));
3874
+ tmpl->Set(isolate, "INT_SAMPLER_3D", v8::Uint32::New(isolate, 0x8DCB));
3875
+ tmpl->Set(isolate, "INT_SAMPLER_CUBE", v8::Uint32::New(isolate, 0x8DCC));
3876
+ tmpl->Set(isolate, "INT_SAMPLER_2D_ARRAY", v8::Uint32::New(isolate, 0x8DCF));
3877
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_2D", v8::Uint32::New(isolate, 0x8DD2));
3878
+
3879
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_3D", v8::Uint32::New(isolate, 0x8DD3));
3880
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_CUBE", v8::Uint32::New(isolate, 0x8DD4));
3881
+ tmpl->Set(isolate, "UNSIGNED_INT_SAMPLER_2D_ARRAY", v8::Uint32::New(isolate, 0x8DD7));
3882
+ tmpl->Set(isolate, "MAX_SAMPLES", v8::Uint32::New(isolate, 0x8D57));
3883
+ tmpl->Set(isolate, "SAMPLER_BINDING", v8::Uint32::New(isolate, 0x8919));
3884
+
3885
+ tmpl->Set(isolate, "PIXEL_PACK_BUFFER", v8::Uint32::New(isolate, 0x88EB));
3886
+ tmpl->Set(isolate, "PIXEL_UNPACK_BUFFER", v8::Uint32::New(isolate, 0x88EC));
3887
+ tmpl->Set(isolate, "PIXEL_PACK_BUFFER_BINDING", v8::Uint32::New(isolate, 0x88ED));
3888
+ tmpl->Set(isolate, "PIXEL_UNPACK_BUFFER_BINDING", v8::Uint32::New(isolate, 0x88EF));
3889
+ tmpl->Set(isolate, "COPY_READ_BUFFER", v8::Uint32::New(isolate, 0x8F36));
3890
+
3891
+ tmpl->Set(isolate, "COPY_WRITE_BUFFER", v8::Uint32::New(isolate, 0x8F37));
3892
+ tmpl->Set(isolate, "COPY_READ_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8F36));
3893
+ tmpl->Set(isolate, "COPY_WRITE_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8F37));
3894
+ tmpl->Set(isolate, "FLOAT_MAT2x3", v8::Uint32::New(isolate, 0x8B65));
3895
+ tmpl->Set(isolate, "FLOAT_MAT2x4", v8::Uint32::New(isolate, 0x8B66));
3896
+
3897
+ tmpl->Set(isolate, "FLOAT_MAT3x2", v8::Uint32::New(isolate, 0x8B67));
3898
+ tmpl->Set(isolate, "FLOAT_MAT3x4", v8::Uint32::New(isolate, 0x8B68));
3899
+ tmpl->Set(isolate, "FLOAT_MAT4x2", v8::Uint32::New(isolate, 0x8B69));
3900
+ tmpl->Set(isolate, "FLOAT_MAT4x3", v8::Uint32::New(isolate, 0x8B6A));
3901
+ tmpl->Set(isolate, "UNSIGNED_INT_VEC2", v8::Uint32::New(isolate, 0x8DC6));
3902
+
3903
+ tmpl->Set(isolate, "UNSIGNED_INT_VEC3", v8::Uint32::New(isolate, 0x8DC7));
3904
+ tmpl->Set(isolate, "UNSIGNED_INT_VEC4", v8::Uint32::New(isolate, 0x8DC8));
3905
+ tmpl->Set(isolate, "UNSIGNED_NORMALIZED", v8::Uint32::New(isolate, 0x8C17));
3906
+ tmpl->Set(isolate, "SIGNED_NORMALIZED", v8::Uint32::New(isolate, 0x8F9C));
3907
+
3908
+ /* Vertex attributes */
3909
+
3910
+ tmpl->Set(isolate, "VERTEX_ATTRIB_ARRAY_INTEGER", v8::Uint32::New(isolate, 0x88FD));
3911
+ tmpl->Set(isolate, "VERTEX_ATTRIB_ARRAY_DIVISOR", v8::Uint32::New(isolate, 0x88FE));
3912
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_MODE", v8::Uint32::New(isolate, 0x8C7F));
3913
+ tmpl->Set(isolate, "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
3914
+ v8::Uint32::New(isolate, 0x8C80));
3915
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_VARYINGS", v8::Uint32::New(isolate, 0x8C83));
3916
+
3917
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_START", v8::Uint32::New(isolate, 0x8C84));
3918
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_SIZE", v8::Uint32::New(isolate, 0x8C85));
3919
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN", v8::Uint32::New(isolate, 0x8C88));
3920
+ tmpl->Set(isolate, "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
3921
+ v8::Uint32::New(isolate, 0x8C8A));
3922
+
3923
+ /* Textures */
3924
+
3925
+ /* Pixel types */
3926
+
3927
+ tmpl->Set(isolate, "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", v8::Uint32::New(isolate, 0x8C8B));
3928
+ tmpl->Set(isolate, "INTERLEAVED_ATTRIBS", v8::Uint32::New(isolate, 0x8C8C));
3929
+ tmpl->Set(isolate, "SEPARATE_ATTRIBS", v8::Uint32::New(isolate, 0x8C8D));
3930
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER", v8::Uint32::New(isolate, 0x8C8E));
3931
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8C8F));
3932
+
3933
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK", v8::Uint32::New(isolate, 0x8E22));
3934
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_PAUSED", v8::Uint32::New(isolate, 0x8E23));
3935
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_ACTIVE", v8::Uint32::New(isolate, 0x8E24));
3936
+ tmpl->Set(isolate, "TRANSFORM_FEEDBACK_BINDING", v8::Uint32::New(isolate, 0x8E25));
3937
+
3938
+ /* Pixel types */
3939
+
3940
+ /* Queries */
3941
+
3942
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING", v8::Uint32::New(isolate, 0x8210));
3943
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE", v8::Uint32::New(isolate, 0x8211));
3944
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_RED_SIZE", v8::Uint32::New(isolate, 0x8212));
3945
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE", v8::Uint32::New(isolate, 0x8213));
3946
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE", v8::Uint32::New(isolate, 0x8214));
3947
+
3948
+ /* Queries */
3949
+
3950
+ /* Draw buffers */
3951
+
3952
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE", v8::Uint32::New(isolate, 0x8215));
3953
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE", v8::Uint32::New(isolate, 0x8216));
3954
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE", v8::Uint32::New(isolate, 0x8217));
3955
+ tmpl->Set(isolate, "FRAMEBUFFER_DEFAULT", v8::Uint32::New(isolate, 0x8218));
3956
+ tmpl->Set(isolate, "DEPTH_STENCIL_ATTACHMENT", v8::Uint32::New(isolate, 0x821A));
3957
+
3958
+ tmpl->Set(isolate, "DEPTH_STENCIL", v8::Uint32::New(isolate, 0x84F9));
3959
+ tmpl->Set(isolate, "DEPTH24_STENCIL8", v8::Uint32::New(isolate, 0x88F0));
3960
+ tmpl->Set(isolate, "DRAW_FRAMEBUFFER_BINDING", v8::Uint32::New(isolate, 0x8CA6));
3961
+ tmpl->Set(isolate, "READ_FRAMEBUFFER", v8::Uint32::New(isolate, 0x8CA8));
3962
+ tmpl->Set(isolate, "DRAW_FRAMEBUFFER", v8::Uint32::New(isolate, 0x8CA9));
3963
+
3964
+ tmpl->Set(isolate, "READ_FRAMEBUFFER_BINDING", v8::Uint32::New(isolate, 0x8CAA));
3965
+ tmpl->Set(isolate, "RENDERBUFFER_SAMPLES", v8::Uint32::New(isolate, 0x8CAB));
3966
+ tmpl->Set(isolate, "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER", v8::Uint32::New(isolate, 0x8CD4));
3967
+ tmpl->Set(isolate, "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE", v8::Uint32::New(isolate, 0x8D56));
3968
+ tmpl->Set(isolate, "UNIFORM_BUFFER", v8::Uint32::New(isolate, 0x8A11));
3969
+
3970
+ tmpl->Set(isolate, "UNIFORM_BUFFER_BINDING", v8::Uint32::New(isolate, 0x8A28));
3971
+ tmpl->Set(isolate, "UNIFORM_BUFFER_START", v8::Uint32::New(isolate, 0x8A29));
3972
+ tmpl->Set(isolate, "UNIFORM_BUFFER_SIZE", v8::Uint32::New(isolate, 0x8A2A));
3973
+ tmpl->Set(isolate, "MAX_VERTEX_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A2B));
3974
+ tmpl->Set(isolate, "MAX_FRAGMENT_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A2D));
3975
+
3976
+ tmpl->Set(isolate, "MAX_COMBINED_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A2E));
3977
+ tmpl->Set(isolate, "MAX_UNIFORM_BUFFER_BINDINGS", v8::Uint32::New(isolate, 0x8A2F));
3978
+ tmpl->Set(isolate, "MAX_UNIFORM_BLOCK_SIZE", v8::Uint32::New(isolate, 0x8A30));
3979
+ tmpl->Set(isolate, "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", v8::Uint32::New(isolate, 0x8A31));
3980
+ tmpl->Set(isolate, "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
3981
+ v8::Uint32::New(isolate, 0x8A33));
3982
+
3983
+ tmpl->Set(isolate, "UNIFORM_BUFFER_OFFSET_ALIGNMENT", v8::Uint32::New(isolate, 0x8A34));
3984
+ tmpl->Set(isolate, "ACTIVE_UNIFORM_BLOCKS", v8::Uint32::New(isolate, 0x8A36));
3985
+ tmpl->Set(isolate, "UNIFORM_TYPE", v8::Uint32::New(isolate, 0x8A37));
3986
+ tmpl->Set(isolate, "UNIFORM_SIZE", v8::Uint32::New(isolate, 0x8A38));
3987
+ tmpl->Set(isolate, "UNIFORM_BLOCK_INDEX", v8::Uint32::New(isolate, 0x8A3A));
3988
+
3989
+ tmpl->Set(isolate, "UNIFORM_OFFSET", v8::Uint32::New(isolate, 0x8A3B));
3990
+ tmpl->Set(isolate, "UNIFORM_ARRAY_STRIDE", v8::Uint32::New(isolate, 0x8A3C));
3991
+ tmpl->Set(isolate, "UNIFORM_MATRIX_STRIDE", v8::Uint32::New(isolate, 0x8A3D));
3992
+
3993
+ /* Draw buffers */
3994
+
3995
+ /* Samplers */
3996
+
3997
+ tmpl->Set(isolate, "UNIFORM_IS_ROW_MAJOR", v8::Uint32::New(isolate, 0x8A3E));
3998
+ tmpl->Set(isolate, "UNIFORM_BLOCK_BINDING", v8::Uint32::New(isolate, 0x8A3F));
3999
+ tmpl->Set(isolate, "UNIFORM_BLOCK_DATA_SIZE", v8::Uint32::New(isolate, 0x8A40));
4000
+ tmpl->Set(isolate, "UNIFORM_BLOCK_ACTIVE_UNIFORMS", v8::Uint32::New(isolate, 0x8A42));
4001
+ tmpl->Set(isolate, "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES", v8::Uint32::New(isolate, 0x8A43));
4002
+
4003
+ tmpl->Set(isolate, "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
4004
+ v8::Uint32::New(isolate, 0x8A44));
4005
+ tmpl->Set(isolate, "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
4006
+ v8::Uint32::New(isolate, 0x8A46));
4007
+ tmpl->Set(isolate, "OBJECT_TYPE", v8::Uint32::New(isolate, 0x9112));
4008
+ tmpl->Set(isolate, "SYNC_CONDITION", v8::Uint32::New(isolate, 0x9113));
4009
+ tmpl->Set(isolate, "SYNC_STATUS", v8::Uint32::New(isolate, 0x9114));
4010
+
4011
+ tmpl->Set(isolate, "SYNC_FLAGS", v8::Uint32::New(isolate, 0x9115));
4012
+ tmpl->Set(isolate, "SYNC_FENCE", v8::Uint32::New(isolate, 0x9116));
4013
+ tmpl->Set(isolate, "SYNC_GPU_COMMANDS_COMPLETE", v8::Uint32::New(isolate, 0x9117));
4014
+ tmpl->Set(isolate, "UNSIGNALED", v8::Uint32::New(isolate, 0x9118));
4015
+ tmpl->Set(isolate, "SIGNALED", v8::Uint32::New(isolate, 0x9119));
4016
+
4017
+ /* Samplers */
4018
+
4019
+ /* Buffers */
4020
+
4021
+ tmpl->Set(isolate, "ALREADY_SIGNALED", v8::Uint32::New(isolate, 0x911A));
4022
+ tmpl->Set(isolate, "TIMEOUT_EXPIRED", v8::Uint32::New(isolate, 0x911B));
4023
+ tmpl->Set(isolate, "CONDITION_SATISFIED", v8::Uint32::New(isolate, 0x911C));
4024
+ tmpl->Set(isolate, "WAIT_FAILED", v8::Uint32::New(isolate, 0x911D));
4025
+ tmpl->Set(isolate, "SYNC_FLUSH_COMMANDS_BIT", v8::Uint32::New(isolate, 0x00000001));
4026
+
4027
+ tmpl->Set(isolate, "COLOR", v8::Uint32::New(isolate, 0x1800));
4028
+ tmpl->Set(isolate, "DEPTH", v8::Uint32::New(isolate, 0x1801));
4029
+ tmpl->Set(isolate, "STENCIL", v8::Uint32::New(isolate, 0x1802));
4030
+
4031
+ /* Buffers */
4032
+
4033
+ /* Data types */
4034
+
4035
+ tmpl->Set(isolate, "MIN", v8::Uint32::New(isolate, 0x8007));
4036
+ tmpl->Set(isolate, "MAX", v8::Uint32::New(isolate, 0x8008));
4037
+ tmpl->Set(isolate, "DEPTH_COMPONENT24", v8::Uint32::New(isolate, 0x81A6));
4038
+ tmpl->Set(isolate, "STREAM_READ", v8::Uint32::New(isolate, 0x88E1));
4039
+ tmpl->Set(isolate, "STREAM_COPY", v8::Uint32::New(isolate, 0x88E2));
4040
+
4041
+ tmpl->Set(isolate, "STATIC_READ", v8::Uint32::New(isolate, 0x88E5));
4042
+ tmpl->Set(isolate, "STATIC_COPY", v8::Uint32::New(isolate, 0x88E6));
4043
+ tmpl->Set(isolate, "DYNAMIC_READ", v8::Uint32::New(isolate, 0x88E9));
4044
+ tmpl->Set(isolate, "DYNAMIC_COPY", v8::Uint32::New(isolate, 0x88EA));
4045
+ tmpl->Set(isolate, "DEPTH_COMPONENT32F", v8::Uint32::New(isolate, 0x8CAC));
4046
+ tmpl->Set(isolate, "DEPTH32F_STENCIL8", v8::Uint32::New(isolate, 0x8CAD));
4047
+
4048
+ /* Data types */
4049
+
4050
+ tmpl->Set(isolate, "INVALID_INDEX", v8::Number::New(isolate, (double) 0xFFFFFFFF));
4051
+ tmpl->Set(isolate, "TIMEOUT_IGNORED", v8::Int32::New(isolate, -1));
4052
+
4053
+ /* Vertex attributes */
4054
+
4055
+ /* Transform feedback */
4056
+
4057
+ tmpl->Set(isolate, "MAX_CLIENT_WAIT_TIMEOUT_WEBGL", v8::Uint32::New(isolate, 0x9247));
4058
+
4059
+ /* Transform feedback */
4060
+
4061
+ }
4062
+
4063
+
4064
+ void WebGL2RenderingContext::SetMethods(v8::Isolate *isolate,
4065
+ const v8::Local<v8::ObjectTemplate> &tmpl) {
4066
+
4067
+ tmpl->Set(
4068
+ ConvertToV8String(isolate, "beginQuery"),
4069
+ v8::FunctionTemplate::New(isolate, &BeginQuery)
4070
+ );
4071
+
4072
+ tmpl->Set(
4073
+ ConvertToV8String(isolate, "beginTransformFeedback"),
4074
+ v8::FunctionTemplate::New(isolate, &BeginTransformFeedback)
4075
+ );
4076
+
4077
+ tmpl->Set(
4078
+ ConvertToV8String(isolate, "bindBufferBase"),
4079
+ v8::FunctionTemplate::New(isolate, &BindBufferBase)
4080
+ );
4081
+
4082
+ tmpl->Set(
4083
+ ConvertToV8String(isolate, "bindBufferRange"),
4084
+ v8::FunctionTemplate::New(isolate, &BindBufferRange)
4085
+ );
4086
+
4087
+ tmpl->Set(
4088
+ ConvertToV8String(isolate, "bindSampler"),
4089
+ v8::FunctionTemplate::New(isolate, &BindSampler)
4090
+ );
4091
+
4092
+ tmpl->Set(
4093
+ ConvertToV8String(isolate, "bindTransformFeedback"),
4094
+ v8::FunctionTemplate::New(isolate, &BindTransformFeedback)
4095
+ );
4096
+
4097
+ tmpl->Set(
4098
+ ConvertToV8String(isolate, "bindVertexArray"),
4099
+ v8::FunctionTemplate::New(isolate, &BindVertexArray)
4100
+ );
4101
+
4102
+ tmpl->Set(
4103
+ ConvertToV8String(isolate, "blitFramebuffer"),
4104
+ v8::FunctionTemplate::New(isolate, &BlitFramebuffer)
4105
+ );
4106
+
4107
+ tmpl->Set(
4108
+ ConvertToV8String(isolate, "clearBufferfi"),
4109
+ v8::FunctionTemplate::New(isolate, &ClearBufferfi)
4110
+ );
4111
+
4112
+ tmpl->Set(
4113
+ ConvertToV8String(isolate, "clearBufferfv"),
4114
+ v8::FunctionTemplate::New(isolate, &ClearBufferfv)
4115
+ );
4116
+
4117
+ tmpl->Set(
4118
+ ConvertToV8String(isolate, "clearBufferiv"),
4119
+ v8::FunctionTemplate::New(isolate, &ClearBufferiv)
4120
+ );
4121
+
4122
+ tmpl->Set(
4123
+ ConvertToV8String(isolate, "clearBufferuiv"),
4124
+ v8::FunctionTemplate::New(isolate, &ClearBufferuiv)
4125
+ );
4126
+
4127
+ tmpl->Set(
4128
+ ConvertToV8String(isolate, "clientWaitSync"),
4129
+ v8::FunctionTemplate::New(isolate, &ClientWaitSync)
4130
+ );
4131
+
4132
+ tmpl->Set(
4133
+ ConvertToV8String(isolate, "compressedTexSubImage3D"),
4134
+ v8::FunctionTemplate::New(isolate, &CompressedTexSubImage3D)
4135
+ );
4136
+
4137
+ tmpl->Set(
4138
+ ConvertToV8String(isolate, "copyBufferSubData"),
4139
+ v8::FunctionTemplate::New(isolate, &CopyBufferSubData)
4140
+ );
4141
+
4142
+ tmpl->Set(
4143
+ ConvertToV8String(isolate, "copyTexSubImage3D"),
4144
+ v8::FunctionTemplate::New(isolate, &CopyTexSubImage3D)
4145
+ );
4146
+
4147
+ tmpl->Set(
4148
+ ConvertToV8String(isolate, "createQuery"),
4149
+ v8::FunctionTemplate::New(isolate, &CreateQuery)
4150
+ );
4151
+
4152
+ tmpl->Set(
4153
+ ConvertToV8String(isolate, "createSampler"),
4154
+ v8::FunctionTemplate::New(isolate, &CreateSampler)
4155
+ );
4156
+
4157
+ tmpl->Set(
4158
+ ConvertToV8String(isolate, "createTransformFeedback"),
4159
+ v8::FunctionTemplate::New(isolate, &CreateTransformFeedback)
4160
+ );
4161
+
4162
+ tmpl->Set(
4163
+ ConvertToV8String(isolate, "createVertexArray"),
4164
+ v8::FunctionTemplate::New(isolate, &CreateVertexArray)
4165
+ );
4166
+
4167
+ tmpl->Set(
4168
+ ConvertToV8String(isolate, "deleteQuery"),
4169
+ v8::FunctionTemplate::New(isolate, &DeleteQuery)
4170
+ );
4171
+
4172
+
4173
+ tmpl->Set(
4174
+ ConvertToV8String(isolate, "deleteSampler"),
4175
+ v8::FunctionTemplate::New(isolate, &DeleteSampler)
4176
+ );
4177
+
4178
+ tmpl->Set(
4179
+ ConvertToV8String(isolate, "deleteSync"),
4180
+ v8::FunctionTemplate::New(isolate, &DeleteSync)
4181
+ );
4182
+
4183
+ tmpl->Set(
4184
+ ConvertToV8String(isolate, "deleteTransformFeedback"),
4185
+ v8::FunctionTemplate::New(isolate, &DeleteTransformFeedback)
4186
+ );
4187
+
4188
+ tmpl->Set(
4189
+ ConvertToV8String(isolate, "deleteVertexArray"),
4190
+ v8::FunctionTemplate::New(isolate, &DeleteVertexArray)
4191
+ );
4192
+
4193
+ tmpl->Set(
4194
+ ConvertToV8String(isolate, "drawArraysInstanced"),
4195
+ v8::FunctionTemplate::New(isolate, &DrawArraysInstanced)
4196
+ );
4197
+
4198
+ tmpl->Set(
4199
+ ConvertToV8String(isolate, "drawBuffers"),
4200
+ v8::FunctionTemplate::New(isolate, &DrawBuffers)
4201
+ );
4202
+
4203
+ tmpl->Set(
4204
+ ConvertToV8String(isolate, "drawElementsInstanced"),
4205
+ v8::FunctionTemplate::New(isolate, &DrawElementsInstanced)
4206
+ );
4207
+
4208
+ tmpl->Set(
4209
+ ConvertToV8String(isolate, "drawRangeElements"),
4210
+ v8::FunctionTemplate::New(isolate, &DrawRangeElements)
4211
+ );
4212
+
4213
+ tmpl->Set(
4214
+ ConvertToV8String(isolate, "endQuery"),
4215
+ v8::FunctionTemplate::New(isolate, &EndQuery)
4216
+ );
4217
+
4218
+ tmpl->Set(
4219
+ ConvertToV8String(isolate, "endTransformFeedback"),
4220
+ v8::FunctionTemplate::New(isolate, &EndTransformFeedback)
4221
+ );
4222
+
4223
+ tmpl->Set(
4224
+ ConvertToV8String(isolate, "fenceSync"),
4225
+ v8::FunctionTemplate::New(isolate, &FenceSync)
4226
+ );
4227
+
4228
+ tmpl->Set(
4229
+ ConvertToV8String(isolate, "framebufferTextureLayer"),
4230
+ v8::FunctionTemplate::New(isolate, &FramebufferTextureLayer)
4231
+ );
4232
+
4233
+ tmpl->Set(
4234
+ ConvertToV8String(isolate, "uniform1ui"),
4235
+ v8::FunctionTemplate::New(isolate, &Uniform1ui)
4236
+ );
4237
+
4238
+ tmpl->Set(
4239
+ ConvertToV8String(isolate, "uniform1uiv"),
4240
+ v8::FunctionTemplate::New(isolate, &Uniform1uiv)
4241
+ );
4242
+
4243
+ tmpl->Set(
4244
+ ConvertToV8String(isolate, "uniform2ui"),
4245
+ v8::FunctionTemplate::New(isolate, &Uniform2ui)
4246
+ );
4247
+
4248
+ tmpl->Set(
4249
+ ConvertToV8String(isolate, "uniform2uiv"),
4250
+ v8::FunctionTemplate::New(isolate, &Uniform2uiv)
4251
+ );
4252
+
4253
+ tmpl->Set(
4254
+ ConvertToV8String(isolate, "uniform3ui"),
4255
+ v8::FunctionTemplate::New(isolate, &Uniform3ui)
4256
+ );
4257
+
4258
+ tmpl->Set(
4259
+ ConvertToV8String(isolate, "uniform3uiv"),
4260
+ v8::FunctionTemplate::New(isolate, &Uniform3uiv)
4261
+ );
4262
+
4263
+ tmpl->Set(
4264
+ ConvertToV8String(isolate, "uniform4ui"),
4265
+ v8::FunctionTemplate::New(isolate, &Uniform4ui)
4266
+ );
4267
+
4268
+ tmpl->Set(
4269
+ ConvertToV8String(isolate, "uniform4uiv"),
4270
+ v8::FunctionTemplate::New(isolate, &Uniform4uiv)
4271
+ );
4272
+
4273
+
4274
+ tmpl->Set(
4275
+ ConvertToV8String(isolate, "uniformBlockBinding"),
4276
+ v8::FunctionTemplate::New(isolate, &UniformBlockBinding)
4277
+ );
4278
+
4279
+
4280
+ tmpl->Set(
4281
+ ConvertToV8String(isolate, "uniformMatrix2x3fv"),
4282
+ v8::FunctionTemplate::New(isolate, &UniformMatrix2x3fv)
4283
+ );
4284
+
4285
+ tmpl->Set(
4286
+ ConvertToV8String(isolate, "uniformMatrix2x4fv"),
4287
+ v8::FunctionTemplate::New(isolate, &UniformMatrix2x4fv)
4288
+ );
4289
+
4290
+ tmpl->Set(
4291
+ ConvertToV8String(isolate, "uniformMatrix3x2fv"),
4292
+ v8::FunctionTemplate::New(isolate, &UniformMatrix3x2fv)
4293
+ );
4294
+
4295
+
4296
+ tmpl->Set(
4297
+ ConvertToV8String(isolate, "uniformMatrix3x4fv"),
4298
+ v8::FunctionTemplate::New(isolate, &UniformMatrix3x4fv)
4299
+ );
4300
+
4301
+ tmpl->Set(
4302
+ ConvertToV8String(isolate, "uniformMatrix4x2fv"),
4303
+ v8::FunctionTemplate::New(isolate, &UniformMatrix4x2fv)
4304
+ );
4305
+
4306
+ tmpl->Set(
4307
+ ConvertToV8String(isolate, "uniformMatrix4x3fv"),
4308
+ v8::FunctionTemplate::New(isolate, &UniformMatrix4x3fv)
4309
+ );
4310
+
4311
+ tmpl->Set(
4312
+ ConvertToV8String(isolate, "uniformMatrix4x3fv"),
4313
+ v8::FunctionTemplate::New(isolate, &UniformMatrix4x3fv)
4314
+ );
4315
+
4316
+ tmpl->Set(
4317
+ ConvertToV8String(isolate, "vertexAttribDivisor"),
4318
+ v8::FunctionTemplate::New(isolate, &VertexAttribDivisor)
4319
+ );
4320
+
4321
+ tmpl->Set(
4322
+ ConvertToV8String(isolate, "vertexAttribI4i"),
4323
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4i)
4324
+ );
4325
+
4326
+ tmpl->Set(
4327
+ ConvertToV8String(isolate, "vertexAttribI4iv"),
4328
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4iv)
4329
+ );
4330
+
4331
+ tmpl->Set(
4332
+ ConvertToV8String(isolate, "vertexAttribI4ui"),
4333
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4ui)
4334
+ );
4335
+
4336
+ tmpl->Set(
4337
+ ConvertToV8String(isolate, "vertexAttribI4uiv"),
4338
+ v8::FunctionTemplate::New(isolate, &VertexAttribI4uiv)
4339
+ );
4340
+
4341
+ tmpl->Set(
4342
+ ConvertToV8String(isolate, "getActiveUniformBlockName"),
4343
+ v8::FunctionTemplate::New(isolate, &GetActiveUniformBlockName)
4344
+ );
4345
+
4346
+ tmpl->Set(
4347
+ ConvertToV8String(isolate, "getActiveUniformBlockParameter"),
4348
+ v8::FunctionTemplate::New(isolate, &GetActiveUniformBlockParameter)
4349
+ );
4350
+
4351
+ tmpl->Set(
4352
+ ConvertToV8String(isolate, "getActiveUniforms"),
4353
+ v8::FunctionTemplate::New(isolate, &GetActiveUniforms)
4354
+ );
4355
+
4356
+ tmpl->Set(
4357
+ ConvertToV8String(isolate, "getBufferSubData"),
4358
+ v8::FunctionTemplate::New(isolate, &GetBufferSubData)
4359
+ );
4360
+
4361
+
4362
+ tmpl->Set(
4363
+ ConvertToV8String(isolate, "getFragDataLocation"),
4364
+ v8::FunctionTemplate::New(isolate, &GetFragDataLocation)
4365
+ );
4366
+
4367
+
4368
+ tmpl->Set(
4369
+ ConvertToV8String(isolate, "getIndexedParameter"),
4370
+ v8::FunctionTemplate::New(isolate, &GetIndexedParameter)
4371
+ );
4372
+
4373
+ tmpl->Set(
4374
+ ConvertToV8String(isolate, "getInternalformatParameter"),
4375
+ v8::FunctionTemplate::New(isolate, &GetInternalformatParameter)
4376
+ );
4377
+
4378
+ tmpl->Set(
4379
+ ConvertToV8String(isolate, "getParameter"),
4380
+ v8::FunctionTemplate::New(isolate, &GetParameter)
4381
+ );
4382
+
4383
+ tmpl->Set(
4384
+ ConvertToV8String(isolate, "getQueryParameter"),
4385
+ v8::FunctionTemplate::New(isolate, &GetQueryParameter)
4386
+ );
4387
+
4388
+
4389
+ tmpl->Set(
4390
+ ConvertToV8String(isolate, "getQuery"),
4391
+ v8::FunctionTemplate::New(isolate, &GetQuery)
4392
+ );
4393
+
4394
+ tmpl->Set(
4395
+ ConvertToV8String(isolate, "getSamplerParameter"),
4396
+ v8::FunctionTemplate::New(isolate, &GetSamplerParameter)
4397
+ );
4398
+
4399
+ tmpl->Set(
4400
+ ConvertToV8String(isolate, "getSyncParameter"),
4401
+ v8::FunctionTemplate::New(isolate, &GetSyncParameter)
4402
+ );
4403
+
4404
+ tmpl->Set(
4405
+ ConvertToV8String(isolate, "getTransformFeedbackVarying"),
4406
+ v8::FunctionTemplate::New(isolate, &GetTransformFeedbackVarying)
4407
+ );
4408
+
4409
+ tmpl->Set(
4410
+ ConvertToV8String(isolate, "getUniformBlockIndex"),
4411
+ v8::FunctionTemplate::New(isolate, &GetUniformBlockIndex)
4412
+ );
4413
+
4414
+ tmpl->Set(
4415
+ ConvertToV8String(isolate, "getUniformIndices"),
4416
+ v8::FunctionTemplate::New(isolate, &GetUniformIndices)
4417
+ );
4418
+
4419
+ tmpl->Set(
4420
+ ConvertToV8String(isolate, "invalidateFramebuffer"),
4421
+ v8::FunctionTemplate::New(isolate, &InvalidateFramebuffer)
4422
+ );
4423
+
4424
+ tmpl->Set(
4425
+ ConvertToV8String(isolate, "invalidateSubFramebuffer"),
4426
+ v8::FunctionTemplate::New(isolate, &InvalidateSubFramebuffer)
4427
+ );
4428
+
4429
+
4430
+ tmpl->Set(
4431
+ ConvertToV8String(isolate, "isQuery"),
4432
+ v8::FunctionTemplate::New(isolate, &IsQuery)
4433
+ );
4434
+
4435
+ tmpl->Set(
4436
+ ConvertToV8String(isolate, "isSampler"),
4437
+ v8::FunctionTemplate::New(isolate, &IsSampler)
4438
+ );
4439
+
4440
+ tmpl->Set(
4441
+ ConvertToV8String(isolate, "isSync"),
4442
+ v8::FunctionTemplate::New(isolate, &IsSync)
4443
+ );
4444
+
4445
+ tmpl->Set(
4446
+ ConvertToV8String(isolate, "isTransformFeedback"),
4447
+ v8::FunctionTemplate::New(isolate, &IsTransformFeedback)
4448
+ );
4449
+
4450
+ tmpl->Set(
4451
+ ConvertToV8String(isolate, "isVertexArray"),
4452
+ v8::FunctionTemplate::New(isolate, &IsVertexArray)
4453
+ );
4454
+
4455
+
4456
+ tmpl->Set(
4457
+ ConvertToV8String(isolate, "pauseTransformFeedback"),
4458
+ v8::FunctionTemplate::New(isolate, &PauseTransformFeedback)
4459
+ );
4460
+
4461
+ tmpl->Set(
4462
+ ConvertToV8String(isolate, "readBuffer"),
4463
+ v8::FunctionTemplate::New(isolate, &ReadBuffer)
4464
+ );
4465
+
4466
+ tmpl->Set(
4467
+ ConvertToV8String(isolate, "renderbufferStorageMultisample"),
4468
+ v8::FunctionTemplate::New(isolate, &RenderbufferStorageMultisample)
4469
+ );
4470
+
4471
+
4472
+ tmpl->Set(
4473
+ ConvertToV8String(isolate, "resumeTransformFeedback"),
4474
+ v8::FunctionTemplate::New(isolate, &ResumeTransformFeedback)
4475
+ );
4476
+
4477
+ tmpl->Set(
4478
+ ConvertToV8String(isolate, "samplerParameterf"),
4479
+ v8::FunctionTemplate::New(isolate, &SamplerParameterf)
4480
+ );
4481
+
4482
+ tmpl->Set(
4483
+ ConvertToV8String(isolate, "samplerParameteri"),
4484
+ v8::FunctionTemplate::New(isolate, &SamplerParameteri)
4485
+ );
4486
+
4487
+ tmpl->Set(
4488
+ ConvertToV8String(isolate, "texImage3D"),
4489
+ v8::FunctionTemplate::New(isolate, &TexImage3D)
4490
+ );
4491
+
4492
+
4493
+ tmpl->Set(
4494
+ ConvertToV8String(isolate, "texStorage2D"),
4495
+ v8::FunctionTemplate::New(isolate, &TexStorage2D)
4496
+ );
4497
+
4498
+ tmpl->Set(
4499
+ ConvertToV8String(isolate, "texStorage3D"),
4500
+ v8::FunctionTemplate::New(isolate, &TexStorage3D)
4501
+ );
4502
+
4503
+ tmpl->Set(
4504
+ ConvertToV8String(isolate, "texSubImage3D"),
4505
+ v8::FunctionTemplate::New(isolate, &TexSubImage3D)
4506
+ );
4507
+
4508
+ tmpl->Set(
4509
+ ConvertToV8String(isolate, "transformFeedbackVaryings"),
4510
+ v8::FunctionTemplate::New(isolate, &TransformFeedbackVaryings)
4511
+ );
4512
+ }
4513
+
4514
+ void WebGL2RenderingContext::SetProps(v8::Isolate *isolate,
4515
+ const v8::Local<v8::ObjectTemplate> &webgl2RenderingContextTpl) {
4516
+
4517
+ }