expo-gl 10.4.2 → 11.0.3
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.
- package/CHANGELOG.md +21 -2
- package/android/build.gradle +4 -13
- package/android/src/main/java/expo/modules/gl/GLContext.java +5 -5
- package/android/src/main/java/expo/modules/gl/GLObjectManagerModule.java +5 -5
- package/android/src/main/java/expo/modules/gl/GLPackage.java +3 -3
- package/android/src/main/java/expo/modules/gl/GLView.java +2 -2
- package/android/src/main/java/expo/modules/gl/GLViewManager.java +2 -2
- package/build/Canvas.js +2 -2
- package/build/Canvas.js.map +1 -1
- package/build/GLUtils.js +1 -1
- package/build/GLUtils.js.map +1 -1
- package/build/GLView.js +117 -109
- package/build/GLView.js.map +1 -1
- package/build/GLView.web.d.ts +1 -0
- package/build/GLView.web.js +31 -32
- package/build/GLView.web.js.map +1 -1
- package/build/WebGL2RenderingContext.d.ts +1 -0
- package/build/WebGL2RenderingContext.js.map +1 -1
- package/build/types.d.ts +2 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/ios/EXGL/{EXGLCameraObject.m → EXGLCameraObject.mm} +0 -0
- package/ios/EXGL/EXGLContext.h +3 -3
- package/ios/EXGL/{EXGLContext.m → EXGLContext.mm} +16 -16
- package/ios/EXGL/{EXGLObject.m → EXGLObject.mm} +0 -0
- package/ios/EXGL/EXGLObjectManager.h +5 -5
- package/ios/EXGL/{EXGLObjectManager.m → EXGLObjectManager.mm} +25 -25
- package/ios/EXGL/EXGLView.h +3 -3
- package/ios/EXGL/{EXGLView.m → EXGLView.mm} +4 -4
- package/ios/EXGL/EXGLViewManager.h +3 -3
- package/ios/EXGL/{EXGLViewManager.m → EXGLViewManager.mm} +5 -5
- package/ios/EXGL.podspec +3 -3
- package/ios/EXGL.xcframework/Info.plist +5 -5
- package/ios/EXGL.xcframework/ios-arm64/EXGL.framework/EXGL +0 -0
- package/ios/EXGL.xcframework/ios-arm64/EXGL.framework/Info.plist +0 -0
- package/ios/EXGL.xcframework/ios-arm64_x86_64-simulator/EXGL.framework/EXGL +0 -0
- package/ios/EXGL.xcframework/ios-arm64_x86_64-simulator/EXGL.framework/Info.plist +0 -0
- package/package.json +6 -6
- package/src/Canvas.tsx +6 -4
- package/src/GLUtils.ts +1 -1
- package/src/GLView.tsx +179 -125
- package/src/GLView.web.tsx +3 -2
- package/src/WebGL2RenderingContext.ts +1 -0
- package/src/types.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,14 +10,33 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 11.0.3 — 2021-10-21
|
|
14
14
|
|
|
15
15
|
_This version does not introduce any user-facing changes._
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## 11.0.2 — 2021-10-15
|
|
18
18
|
|
|
19
19
|
_This version does not introduce any user-facing changes._
|
|
20
20
|
|
|
21
|
+
## 11.0.1 — 2021-10-01
|
|
22
|
+
|
|
23
|
+
_This version does not introduce any user-facing changes._
|
|
24
|
+
|
|
25
|
+
## 11.0.0 — 2021-09-28
|
|
26
|
+
|
|
27
|
+
### 🛠 Breaking changes
|
|
28
|
+
|
|
29
|
+
- Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
|
|
30
|
+
|
|
31
|
+
### 🐛 Bug fixes
|
|
32
|
+
|
|
33
|
+
- Remove `OES_vertex_array_object` from list of supported extensions. ([#14299](https://github.com/expo/expo/pull/14299) by [@wkozyra95](https://github.com/wkozyra95))
|
|
34
|
+
- Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
|
|
35
|
+
|
|
36
|
+
### 💡 Others
|
|
37
|
+
|
|
38
|
+
- Migrated from `@unimodules/core` to `expo-modules-core`. ([#13757](https://github.com/expo/expo/pull/13757) by [@tsapeta](https://github.com/tsapeta))
|
|
39
|
+
|
|
21
40
|
## 10.4.0 — 2021-06-16
|
|
22
41
|
|
|
23
42
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '
|
|
6
|
+
version = '11.0.3'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
// Simple helper that allows the root project to override versions declared by this library.
|
|
@@ -57,7 +57,7 @@ android {
|
|
|
57
57
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
58
58
|
targetSdkVersion safeExtGet("targetSdkVersion", 30)
|
|
59
59
|
versionCode 31
|
|
60
|
-
versionName "
|
|
60
|
+
versionName "11.0.3"
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
sourceSets.main {
|
|
@@ -69,18 +69,9 @@ android {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
|
|
73
|
-
apply from: project(":unimodules-core").file("../unimodules-core.gradle")
|
|
74
|
-
} else {
|
|
75
|
-
throw new GradleException(
|
|
76
|
-
"'unimodules-core.gradle' was not found in the usual React Native dependency location. " +
|
|
77
|
-
"This package can only be used in such projects. Are you sure you've installed the dependencies properly?")
|
|
78
|
-
}
|
|
79
|
-
|
|
80
72
|
dependencies {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
unimodule 'expo-modules-core'
|
|
73
|
+
implementation project(':expo-gl-cpp')
|
|
74
|
+
implementation project(':expo-modules-core')
|
|
84
75
|
|
|
85
76
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
|
|
86
77
|
}
|
|
@@ -27,11 +27,11 @@ import javax.microedition.khronos.egl.EGLContext;
|
|
|
27
27
|
import javax.microedition.khronos.egl.EGLDisplay;
|
|
28
28
|
import javax.microedition.khronos.egl.EGLSurface;
|
|
29
29
|
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
30
|
+
import expo.modules.core.ModuleRegistry;
|
|
31
|
+
import expo.modules.core.Promise;
|
|
32
|
+
import expo.modules.core.interfaces.JavaScriptContextProvider;
|
|
33
|
+
import expo.modules.core.interfaces.RuntimeEnvironmentInterface;
|
|
34
|
+
import expo.modules.core.interfaces.services.UIManager;
|
|
35
35
|
import expo.modules.gl.utils.FileSystemUtils;
|
|
36
36
|
|
|
37
37
|
import static android.opengl.GLES30.*;
|
|
@@ -8,11 +8,11 @@ import android.util.SparseArray;
|
|
|
8
8
|
|
|
9
9
|
import java.util.Map;
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
11
|
+
import expo.modules.core.ExportedModule;
|
|
12
|
+
import expo.modules.core.ModuleRegistry;
|
|
13
|
+
import expo.modules.core.Promise;
|
|
14
|
+
import expo.modules.core.interfaces.ExpoMethod;
|
|
15
|
+
import expo.modules.core.interfaces.services.UIManager;
|
|
16
16
|
|
|
17
17
|
import expo.modules.interfaces.camera.CameraViewInterface;
|
|
18
18
|
|
|
@@ -5,9 +5,9 @@ import android.content.Context;
|
|
|
5
5
|
import java.util.Collections;
|
|
6
6
|
import java.util.List;
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import expo.modules.core.ExportedModule;
|
|
9
|
+
import expo.modules.core.BasePackage;
|
|
10
|
+
import expo.modules.core.ViewManager;
|
|
11
11
|
|
|
12
12
|
public class GLPackage extends BasePackage {
|
|
13
13
|
@Override
|
|
@@ -5,8 +5,8 @@ import android.graphics.SurfaceTexture;
|
|
|
5
5
|
import android.os.Bundle;
|
|
6
6
|
import android.view.TextureView;
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import expo.modules.core.ModuleRegistry;
|
|
9
|
+
import expo.modules.core.interfaces.services.EventEmitter;
|
|
10
10
|
|
|
11
11
|
public class GLView extends TextureView implements TextureView.SurfaceTextureListener {
|
|
12
12
|
private boolean mOnSurfaceCreateCalled = false;
|
|
@@ -5,8 +5,8 @@ import android.content.Context;
|
|
|
5
5
|
import java.util.Arrays;
|
|
6
6
|
import java.util.List;
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import expo.modules.core.ModuleRegistry;
|
|
9
|
+
import expo.modules.core.ViewManager;
|
|
10
10
|
|
|
11
11
|
public class GLViewManager extends ViewManager<GLView> {
|
|
12
12
|
private ModuleRegistry mModuleRegistry;
|
package/build/Canvas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Platform } from '
|
|
1
|
+
import { Platform } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { findDOMNode } from 'react-dom';
|
|
4
4
|
import { PixelRatio, StyleSheet, View } from 'react-native';
|
|
@@ -74,7 +74,7 @@ const CanvasWrapper = ({ pointerEvents, children, ...props }) => {
|
|
|
74
74
|
}
|
|
75
75
|
setRef(props.canvasRef, canvas);
|
|
76
76
|
}, [_canvasRef]);
|
|
77
|
-
return (React.createElement(View,
|
|
77
|
+
return (React.createElement(View, { ...props, pointerEvents: "box-none", ref: ref, onLayout: onLayout },
|
|
78
78
|
React.createElement(Canvas, { ref: _canvasRef, pointerEvents: pointerEvents, style: StyleSheet.absoluteFill }),
|
|
79
79
|
children));
|
|
80
80
|
};
|
package/build/Canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE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AI,KAAK,CAAC,QAAQ,EAAE;gBAClB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;aACvB;SACF;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,EAAE;YACvB,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACpB;IACH,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,gBAAgB,EAAE,CAAC;IACrB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,MAAM,EAAE;YACV,gBAAgB,EAAE,CAAC;SACpB;QACD,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK,EAAE,aAAa,EAAC,UAAU,EAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ;QACpE,oBAAC,MAAM,IAAC,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,CAAC,YAAY,GAAI;QACxF,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\nimport * as React from 'react';\nimport { findDOMNode } from 'react-dom';\nimport { LayoutChangeEvent, PixelRatio, StyleSheet, View, ViewProps } from 'react-native';\nimport createElement from 'react-native-web/dist/exports/createElement';\n\nfunction getElement(component) {\n try {\n return findDOMNode(component);\n } catch (e) {\n return component;\n }\n}\n\nfunction setRef<T>(refProp: React.Ref<T>, ref: T | null) {\n if (!refProp) return;\n\n if (typeof refProp === 'function') {\n refProp(ref);\n } else if ('current' in refProp) {\n // @ts-ignore\n refProp.current = ref;\n }\n}\n\nconst Canvas = React.forwardRef(\n (props: React.ComponentProps<typeof View>, ref: React.Ref<HTMLCanvasElement>) =>\n createElement('canvas', { ...props, ref })\n);\n\nconst CanvasWrapper: React.FunctionComponent<\n ViewProps & {\n canvasRef: React.Ref<HTMLCanvasElement>;\n }\n> = ({ pointerEvents, children, ...props }) => {\n const [size, setSize] = React.useState<{ width: number; height: number } | null>(null);\n\n const ref = React.useRef<View>(null);\n const _canvasRef = React.useRef<HTMLCanvasElement>(null);\n\n function updateCanvasSize(): void {\n const canvas = _canvasRef.current;\n // eslint-disable-next-line no-undef\n if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) {\n const size = getSize();\n const scale = PixelRatio.get();\n\n canvas.style.width = `${size.width}px`;\n canvas.style.height = `${size.height}px`;\n\n canvas.width = size.width * scale;\n canvas.height = size.height * scale;\n }\n }\n\n function getSize(): { width: number; height: number } {\n if (size) {\n return size;\n } else if (!ref.current || !Platform.isDOMAvailable) {\n return { width: 0, height: 0 };\n }\n const element = getElement(ref.current);\n const { offsetWidth: width = 0, offsetHeight: height = 0 } = element;\n return { width, height };\n }\n\n function onLayout(event: LayoutChangeEvent): void {\n const {\n nativeEvent: {\n layout: { width, height },\n },\n } = event;\n\n if (width !== size?.width || height !== size.height) {\n setSize({ width, height });\n\n if (props.onLayout) {\n props.onLayout(event);\n }\n }\n }\n\n React.useEffect(() => {\n if (ref.current != null) {\n setSize(getSize());\n }\n }, [ref]);\n\n React.useEffect(() => {\n updateCanvasSize();\n }, [size]);\n\n React.useEffect(() => {\n const canvas = _canvasRef.current;\n if (canvas) {\n updateCanvasSize();\n }\n setRef(props.canvasRef, canvas);\n }, [_canvasRef]);\n\n return (\n <View {...props} pointerEvents=\"box-none\" ref={ref} onLayout={onLayout}>\n <Canvas ref={_canvasRef} pointerEvents={pointerEvents} style={StyleSheet.absoluteFill} />\n {children}\n </View>\n );\n};\n\nexport default CanvasWrapper;\n"]}
|
package/build/GLUtils.js
CHANGED
|
@@ -34,7 +34,7 @@ export function configureLogging(gl) {
|
|
|
34
34
|
}
|
|
35
35
|
gl[key] = (...args) => {
|
|
36
36
|
if (loggingOption & GLLoggingOption.METHOD_CALLS) {
|
|
37
|
-
const params = args.map(arg => {
|
|
37
|
+
const params = args.map((arg) => {
|
|
38
38
|
// If the type is `number`, then try to find name of the constant that has such value,
|
|
39
39
|
// so it's easier to read these logs. In some cases it might be misleading
|
|
40
40
|
// if the parameter is for example a width or height, so the number is still logged.
|
package/build/GLUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLUtils.js","sourceRoot":"","sources":["../src/GLUtils.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAA6B,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;GAEG;AACH,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAA6B;IAC5D,kDAAkD;IAClD,IAAI,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC;IAE7C,EAAE,CAAC,gBAAgB,GAAG,CAAC,MAAuB,EAAQ,EAAE;QACtD,kEAAkE;QAClE,0DAA0D;QAC1D,IAAI,CAAC,aAAa,KAAK,CAAC,MAAM,EAAE;YAC9B,aAAa,GAAG,MAAM,CAAC;YACvB,OAAO;SACR;QAED,oBAAoB;QACpB,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,eAAe,CAAC,QAAQ,EAAE;YAClD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC1C,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,CAAC,QAAQ,EAAE;oBACjD,EAAE,CAAC,GAAG,CAA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AC,iBAAiB,CAAC,GAAG,KAAK,CAAC;6BAC9E;yBACF;wBAED,yCAAyC;wBACzC,OAAO,EAAE,GAAG,GAAG,CAAC;oBAClB,CAAC,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACrD;gBAED,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;gBAE7C,IAAI,aAAa,GAAG,eAAe,CAAC,YAAY,EAAE;oBAChD,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC;iBACtC;gBACD,IAAI,aAAa,GAAG,eAAe,CAAC,UAAU,IAAI,GAAG,KAAK,UAAU,EAAE;oBACpE,2DAA2D;oBAC3D,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAE5C,IAAI,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,QAAQ,EAAE;wBAClC,8EAA8E;wBAC9E,OAAO,CAAC,GAAG,CAAC,yBAAyB,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;qBAChE;iBACF;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;YACF,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,aAAa,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,aAAa,GAAG,MAAM,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import GLErrors from './GLErrors';\nimport { ExpoWebGLRenderingContext, GLLoggingOption } from './GLView.types';\n\n/**\n * Maximum length of the strings printed to the console.\n */\nconst MAX_STRING_LENGTH = 20;\n\n/**\n * Sets up `__expoSetLogging` method providing some logging options useful when debugging GL calls.\n */\nexport function configureLogging(gl: ExpoWebGLRenderingContext): void {\n // Enable/disable logging of all GL function calls\n let loggingOption = GLLoggingOption.DISABLED;\n\n gl.__expoSetLogging = (option: GLLoggingOption): void => {\n // If boolean values are the same, just change the internal value,\n // there is no need to wrap/unwrap functions in this case.\n if (!loggingOption === !option) {\n loggingOption = option;\n return;\n }\n\n // Turn off logging.\n if (!option || option === GLLoggingOption.DISABLED) {\n Object.entries(gl).forEach(([key, value]) => {\n if (typeof value === 'function' && value.original) {\n gl[key] = value.original;\n }\n });\n loggingOption = option;\n return;\n }\n\n // Turn on logging.\n Object.entries(gl).forEach(([key, originalValue]) => {\n if (typeof originalValue !== 'function' || key === '__expoSetLogging') {\n return;\n }\n\n gl[key] = (...args) => {\n if (loggingOption & GLLoggingOption.METHOD_CALLS) {\n const params = args.map((arg) => {\n // If the type is `number`, then try to find name of the constant that has such value,\n // so it's easier to read these logs. In some cases it might be misleading\n // if the parameter is for example a width or height, so the number is still logged.\n if (loggingOption & GLLoggingOption.RESOLVE_CONSTANTS && typeof arg === 'number') {\n for (const prop in gl) {\n if (gl[prop] === arg) {\n return `${arg} (${prop})`;\n }\n }\n }\n\n // Truncate strings so they don't produce too much output and don't block the bridge.\n // It mostly applies to shaders which might be very long...\n if (loggingOption & GLLoggingOption.TRUNCATE_STRINGS && typeof arg === 'string') {\n if (arg.length > MAX_STRING_LENGTH) {\n const lastIndex = arg.lastIndexOf(' ', MAX_STRING_LENGTH);\n return arg.substr(0, lastIndex >= 0 ? lastIndex : MAX_STRING_LENGTH) + '...';\n }\n }\n\n // Just return the parameter as a string.\n return '' + arg;\n });\n console.log(`ExpoGL: ${key}(${params.join(', ')})`);\n }\n\n const result = originalValue.apply(gl, args);\n\n if (loggingOption & GLLoggingOption.METHOD_CALLS) {\n console.log(`ExpoGL: = ${result}`);\n }\n if (loggingOption & GLLoggingOption.GET_ERRORS && key !== 'getError') {\n // @ts-ignore We need to call into the original `getError`.\n const error = gl.getError.original.call(gl);\n\n if (error && error !== gl.NO_ERROR) {\n // `console.error` would cause a red screen, so let's just log with red color.\n console.log(`\\x1b[31mExpoGL: Error ${GLErrors[error]}\\x1b[0m`);\n }\n }\n return result;\n };\n gl[key].original = originalValue;\n });\n\n loggingOption = option;\n };\n}\n"]}
|
package/build/GLView.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeModulesProxy, UnavailabilityError, requireNativeViewManager, CodedError, } from '
|
|
1
|
+
import { NativeModulesProxy, UnavailabilityError, requireNativeViewManager, CodedError, } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Platform, View, findNodeHandle } from 'react-native';
|
|
4
4
|
import { configureLogging } from './GLUtils';
|
|
@@ -9,23 +9,10 @@ const NativeView = requireNativeViewManager('ExponentGLView');
|
|
|
9
9
|
* A component that acts as an OpenGL render target
|
|
10
10
|
*/
|
|
11
11
|
export class GLView extends React.Component {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (this.props.nativeRef_EXPERIMENTAL) {
|
|
17
|
-
this.props.nativeRef_EXPERIMENTAL(nativeRef);
|
|
18
|
-
}
|
|
19
|
-
this.nativeRef = nativeRef;
|
|
20
|
-
};
|
|
21
|
-
this._onSurfaceCreate = ({ nativeEvent: { exglCtxId } }) => {
|
|
22
|
-
const gl = getGl(exglCtxId);
|
|
23
|
-
this.exglCtxId = exglCtxId;
|
|
24
|
-
if (this.props.onContextCreate) {
|
|
25
|
-
this.props.onContextCreate(gl);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
12
|
+
static NativeView;
|
|
13
|
+
static defaultProps = {
|
|
14
|
+
msaaSamples: 4,
|
|
15
|
+
};
|
|
29
16
|
static async createContextAsync() {
|
|
30
17
|
const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();
|
|
31
18
|
return getGl(exglCtxId);
|
|
@@ -38,10 +25,12 @@ export class GLView extends React.Component {
|
|
|
38
25
|
const exglCtxId = getContextId(exgl);
|
|
39
26
|
return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);
|
|
40
27
|
}
|
|
28
|
+
nativeRef = null;
|
|
29
|
+
exglCtxId;
|
|
41
30
|
render() {
|
|
42
31
|
const { onContextCreate, // eslint-disable-line no-unused-vars
|
|
43
32
|
msaaSamples, ...viewProps } = this.props;
|
|
44
|
-
return (React.createElement(View,
|
|
33
|
+
return (React.createElement(View, { ...viewProps },
|
|
45
34
|
React.createElement(NativeView, { ref: this._setNativeRef, style: {
|
|
46
35
|
flex: 1,
|
|
47
36
|
...(Platform.OS === 'ios'
|
|
@@ -51,6 +40,19 @@ export class GLView extends React.Component {
|
|
|
51
40
|
: {}),
|
|
52
41
|
}, onSurfaceCreate: this._onSurfaceCreate, msaaSamples: Platform.OS === 'ios' ? msaaSamples : undefined })));
|
|
53
42
|
}
|
|
43
|
+
_setNativeRef = (nativeRef) => {
|
|
44
|
+
if (this.props.nativeRef_EXPERIMENTAL) {
|
|
45
|
+
this.props.nativeRef_EXPERIMENTAL(nativeRef);
|
|
46
|
+
}
|
|
47
|
+
this.nativeRef = nativeRef;
|
|
48
|
+
};
|
|
49
|
+
_onSurfaceCreate = ({ nativeEvent: { exglCtxId } }) => {
|
|
50
|
+
const gl = getGl(exglCtxId);
|
|
51
|
+
this.exglCtxId = exglCtxId;
|
|
52
|
+
if (this.props.onContextCreate) {
|
|
53
|
+
this.props.onContextCreate(gl);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
54
56
|
async startARSessionAsync() {
|
|
55
57
|
if (!ExponentGLViewManager.startARSessionAsync) {
|
|
56
58
|
throw new UnavailabilityError('expo-gl', 'startARSessionAsync');
|
|
@@ -83,17 +85,16 @@ export class GLView extends React.Component {
|
|
|
83
85
|
return await GLView.takeSnapshotAsync(exglCtxId, options);
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
|
-
GLView.defaultProps = {
|
|
87
|
-
msaaSamples: 4,
|
|
88
|
-
};
|
|
89
88
|
GLView.NativeView = NativeView;
|
|
90
89
|
// JavaScript WebGL types to wrap around native objects
|
|
91
90
|
class WebGLRenderingContext {
|
|
91
|
+
__exglCtxId;
|
|
92
92
|
}
|
|
93
93
|
class WebGL2RenderingContext extends WebGLRenderingContext {
|
|
94
94
|
}
|
|
95
95
|
const idToObject = {};
|
|
96
96
|
export class WebGLObject {
|
|
97
|
+
id;
|
|
97
98
|
constructor(id) {
|
|
98
99
|
if (idToObject[id]) {
|
|
99
100
|
throw new Error(`WebGL object with underlying EXGLObjectId '${id}' already exists!`);
|
|
@@ -125,6 +126,7 @@ class WebGLShader extends WebGLObject {
|
|
|
125
126
|
class WebGLTexture extends WebGLObject {
|
|
126
127
|
}
|
|
127
128
|
class WebGLUniformLocation {
|
|
129
|
+
id;
|
|
128
130
|
constructor(id) {
|
|
129
131
|
this.id = id; // Native GL object id
|
|
130
132
|
}
|
|
@@ -133,6 +135,9 @@ class WebGLUniformLocation {
|
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
class WebGLActiveInfo {
|
|
138
|
+
name;
|
|
139
|
+
size;
|
|
140
|
+
type;
|
|
136
141
|
constructor(obj) {
|
|
137
142
|
Object.assign(this, obj);
|
|
138
143
|
}
|
|
@@ -141,6 +146,9 @@ class WebGLActiveInfo {
|
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
class WebGLShaderPrecisionFormat {
|
|
149
|
+
rangeMin;
|
|
150
|
+
rangeMax;
|
|
151
|
+
precision;
|
|
144
152
|
constructor(obj) {
|
|
145
153
|
Object.assign(this, obj);
|
|
146
154
|
}
|
|
@@ -161,8 +169,8 @@ class WebGLVertexArrayObject extends WebGLObject {
|
|
|
161
169
|
}
|
|
162
170
|
// Many functions need wrapping/unwrapping of arguments and return value. We handle each case
|
|
163
171
|
// specifically so we can write the tightest code for better performance.
|
|
164
|
-
const wrapMethods = gl => {
|
|
165
|
-
const wrap = (methodNames, wrapper) => (Array.isArray(methodNames) ? methodNames : [methodNames]).forEach(methodName => (gl[methodName] = wrapper(gl[methodName])));
|
|
172
|
+
const wrapMethods = (gl) => {
|
|
173
|
+
const wrap = (methodNames, wrapper) => (Array.isArray(methodNames) ? methodNames : [methodNames]).forEach((methodName) => (gl[methodName] = wrapper(gl[methodName])));
|
|
166
174
|
// We can be slow in `gl.getParameter(...)` since it's a blocking call anyways
|
|
167
175
|
const getParameterTypes = {
|
|
168
176
|
[gl.ARRAY_BUFFER_BINDING]: WebGLBuffer,
|
|
@@ -183,7 +191,7 @@ const wrapMethods = gl => {
|
|
|
183
191
|
[gl.UNIFORM_BUFFER_BINDING]: WebGLBuffer,
|
|
184
192
|
[gl.VERTEX_ARRAY_BINDING]: WebGLVertexArrayObject,
|
|
185
193
|
};
|
|
186
|
-
wrap('getParameter', orig => pname => {
|
|
194
|
+
wrap('getParameter', (orig) => (pname) => {
|
|
187
195
|
let ret = orig.call(gl, pname);
|
|
188
196
|
if (pname === gl.VERSION) {
|
|
189
197
|
// Wrap native version name
|
|
@@ -193,66 +201,66 @@ const wrapMethods = gl => {
|
|
|
193
201
|
return type ? wrapObject(type, ret) : ret;
|
|
194
202
|
});
|
|
195
203
|
// Buffers
|
|
196
|
-
wrap('bindBuffer', orig => (target, buffer) => orig.call(gl, target, buffer && buffer.id));
|
|
197
|
-
wrap('createBuffer', orig => () => wrapObject(WebGLBuffer, orig.call(gl)));
|
|
198
|
-
wrap('deleteBuffer', orig => buffer => orig.call(gl, buffer && buffer.id));
|
|
199
|
-
wrap('isBuffer', orig => buffer => buffer instanceof WebGLBuffer && orig.call(gl, buffer.id));
|
|
204
|
+
wrap('bindBuffer', (orig) => (target, buffer) => orig.call(gl, target, buffer && buffer.id));
|
|
205
|
+
wrap('createBuffer', (orig) => () => wrapObject(WebGLBuffer, orig.call(gl)));
|
|
206
|
+
wrap('deleteBuffer', (orig) => (buffer) => orig.call(gl, buffer && buffer.id));
|
|
207
|
+
wrap('isBuffer', (orig) => (buffer) => buffer instanceof WebGLBuffer && orig.call(gl, buffer.id));
|
|
200
208
|
// Framebuffers
|
|
201
|
-
wrap('bindFramebuffer', orig => (target, framebuffer) => orig.call(gl, target, framebuffer && framebuffer.id));
|
|
202
|
-
wrap('createFramebuffer', orig => () => wrapObject(WebGLFramebuffer, orig.call(gl)));
|
|
203
|
-
wrap('deleteFramebuffer', orig => framebuffer => orig.call(gl, framebuffer && framebuffer.id));
|
|
204
|
-
wrap('framebufferRenderbuffer', orig => (target, attachment, rbtarget, rb) => orig.call(gl, target, attachment, rbtarget, rb && rb.id));
|
|
205
|
-
wrap('framebufferTexture2D', orig => (target, attachment, textarget, tex, level) => orig.call(gl, target, attachment, textarget, tex && tex.id, level));
|
|
206
|
-
wrap('isFramebuffer', orig => framebuffer => framebuffer instanceof WebGLFramebuffer && orig.call(gl, framebuffer.id));
|
|
207
|
-
wrap('framebufferTextureLayer', orig => (target, attachment, texture, level, layer) => {
|
|
209
|
+
wrap('bindFramebuffer', (orig) => (target, framebuffer) => orig.call(gl, target, framebuffer && framebuffer.id));
|
|
210
|
+
wrap('createFramebuffer', (orig) => () => wrapObject(WebGLFramebuffer, orig.call(gl)));
|
|
211
|
+
wrap('deleteFramebuffer', (orig) => (framebuffer) => orig.call(gl, framebuffer && framebuffer.id));
|
|
212
|
+
wrap('framebufferRenderbuffer', (orig) => (target, attachment, rbtarget, rb) => orig.call(gl, target, attachment, rbtarget, rb && rb.id));
|
|
213
|
+
wrap('framebufferTexture2D', (orig) => (target, attachment, textarget, tex, level) => orig.call(gl, target, attachment, textarget, tex && tex.id, level));
|
|
214
|
+
wrap('isFramebuffer', (orig) => (framebuffer) => framebuffer instanceof WebGLFramebuffer && orig.call(gl, framebuffer.id));
|
|
215
|
+
wrap('framebufferTextureLayer', (orig) => (target, attachment, texture, level, layer) => {
|
|
208
216
|
return orig.call(gl, target, attachment, objectId(texture), level, layer);
|
|
209
217
|
});
|
|
210
218
|
// Renderbuffers
|
|
211
|
-
wrap('bindRenderbuffer', orig => (target, renderbuffer) => orig.call(gl, target, renderbuffer && renderbuffer.id));
|
|
212
|
-
wrap('createRenderbuffer', orig => () => wrapObject(WebGLRenderbuffer, orig.call(gl)));
|
|
213
|
-
wrap('deleteRenderbuffer', orig => renderbuffer => orig.call(gl, renderbuffer && renderbuffer.id));
|
|
214
|
-
wrap('isRenderbuffer', orig => renderbuffer => renderbuffer instanceof WebGLRenderbuffer && orig.call(gl, renderbuffer.id));
|
|
219
|
+
wrap('bindRenderbuffer', (orig) => (target, renderbuffer) => orig.call(gl, target, renderbuffer && renderbuffer.id));
|
|
220
|
+
wrap('createRenderbuffer', (orig) => () => wrapObject(WebGLRenderbuffer, orig.call(gl)));
|
|
221
|
+
wrap('deleteRenderbuffer', (orig) => (renderbuffer) => orig.call(gl, renderbuffer && renderbuffer.id));
|
|
222
|
+
wrap('isRenderbuffer', (orig) => (renderbuffer) => renderbuffer instanceof WebGLRenderbuffer && orig.call(gl, renderbuffer.id));
|
|
215
223
|
// Textures
|
|
216
|
-
wrap('bindTexture', orig => (target, texture) => orig.call(gl, target, texture && texture.id));
|
|
217
|
-
wrap('createTexture', orig => () => wrapObject(WebGLTexture, orig.call(gl)));
|
|
218
|
-
wrap('deleteTexture', orig => texture => orig.call(gl, texture && texture.id));
|
|
219
|
-
wrap('isTexture', orig => texture => texture instanceof WebGLTexture && orig.call(gl, texture.id));
|
|
224
|
+
wrap('bindTexture', (orig) => (target, texture) => orig.call(gl, target, texture && texture.id));
|
|
225
|
+
wrap('createTexture', (orig) => () => wrapObject(WebGLTexture, orig.call(gl)));
|
|
226
|
+
wrap('deleteTexture', (orig) => (texture) => orig.call(gl, texture && texture.id));
|
|
227
|
+
wrap('isTexture', (orig) => (texture) => texture instanceof WebGLTexture && orig.call(gl, texture.id));
|
|
220
228
|
// Programs and shaders
|
|
221
|
-
wrap('attachShader', orig => (program, shader) => orig.call(gl, program && program.id, shader && shader.id));
|
|
222
|
-
wrap('bindAttribLocation', orig => (program, index, name) => orig.call(gl, program && program.id, index, name));
|
|
223
|
-
wrap('compileShader', orig => shader => orig.call(gl, shader && shader.id));
|
|
224
|
-
wrap('createProgram', orig => () => wrapObject(WebGLProgram, orig.call(gl)));
|
|
225
|
-
wrap('createShader', orig => type => wrapObject(WebGLShader, orig.call(gl, type)));
|
|
226
|
-
wrap('deleteProgram', orig => program => orig.call(gl, program && program.id));
|
|
227
|
-
wrap('deleteShader', orig => shader => orig.call(gl, shader && shader.id));
|
|
228
|
-
wrap('detachShader', orig => (program, shader) => orig.call(gl, program && program.id, shader && shader.id));
|
|
229
|
-
wrap('getAttachedShaders', orig => program => orig.call(gl, program && program.id).map(id => wrapObject(WebGLShader, id)));
|
|
230
|
-
wrap('getProgramParameter', orig => (program, pname) => orig.call(gl, program && program.id, pname));
|
|
231
|
-
wrap('getProgramInfoLog', orig => program => orig.call(gl, program && program.id));
|
|
232
|
-
wrap('getShaderParameter', orig => (shader, pname) => orig.call(gl, shader && shader.id, pname));
|
|
233
|
-
wrap('getShaderPrecisionFormat', orig => (shadertype, precisiontype) => new WebGLShaderPrecisionFormat(orig.call(gl, shadertype, precisiontype)));
|
|
234
|
-
wrap('getShaderInfoLog', orig => shader => orig.call(gl, shader && shader.id));
|
|
235
|
-
wrap('getShaderSource', orig => shader => orig.call(gl, shader && shader.id));
|
|
236
|
-
wrap('linkProgram', orig => program => orig.call(gl, program && program.id));
|
|
237
|
-
wrap('shaderSource', orig => (shader, source) => orig.call(gl, shader && shader.id, source));
|
|
238
|
-
wrap('useProgram', orig => program => orig.call(gl, program && program.id));
|
|
239
|
-
wrap('validateProgram', orig => program => orig.call(gl, program && program.id));
|
|
240
|
-
wrap('isShader', orig => shader => shader instanceof WebGLShader && orig.call(gl, shader.id));
|
|
241
|
-
wrap('isProgram', orig => program => program instanceof WebGLProgram && orig.call(gl, program.id));
|
|
242
|
-
wrap('getFragDataLocation', orig => program => orig.call(gl, objectId(program)));
|
|
229
|
+
wrap('attachShader', (orig) => (program, shader) => orig.call(gl, program && program.id, shader && shader.id));
|
|
230
|
+
wrap('bindAttribLocation', (orig) => (program, index, name) => orig.call(gl, program && program.id, index, name));
|
|
231
|
+
wrap('compileShader', (orig) => (shader) => orig.call(gl, shader && shader.id));
|
|
232
|
+
wrap('createProgram', (orig) => () => wrapObject(WebGLProgram, orig.call(gl)));
|
|
233
|
+
wrap('createShader', (orig) => (type) => wrapObject(WebGLShader, orig.call(gl, type)));
|
|
234
|
+
wrap('deleteProgram', (orig) => (program) => orig.call(gl, program && program.id));
|
|
235
|
+
wrap('deleteShader', (orig) => (shader) => orig.call(gl, shader && shader.id));
|
|
236
|
+
wrap('detachShader', (orig) => (program, shader) => orig.call(gl, program && program.id, shader && shader.id));
|
|
237
|
+
wrap('getAttachedShaders', (orig) => (program) => orig.call(gl, program && program.id).map((id) => wrapObject(WebGLShader, id)));
|
|
238
|
+
wrap('getProgramParameter', (orig) => (program, pname) => orig.call(gl, program && program.id, pname));
|
|
239
|
+
wrap('getProgramInfoLog', (orig) => (program) => orig.call(gl, program && program.id));
|
|
240
|
+
wrap('getShaderParameter', (orig) => (shader, pname) => orig.call(gl, shader && shader.id, pname));
|
|
241
|
+
wrap('getShaderPrecisionFormat', (orig) => (shadertype, precisiontype) => new WebGLShaderPrecisionFormat(orig.call(gl, shadertype, precisiontype)));
|
|
242
|
+
wrap('getShaderInfoLog', (orig) => (shader) => orig.call(gl, shader && shader.id));
|
|
243
|
+
wrap('getShaderSource', (orig) => (shader) => orig.call(gl, shader && shader.id));
|
|
244
|
+
wrap('linkProgram', (orig) => (program) => orig.call(gl, program && program.id));
|
|
245
|
+
wrap('shaderSource', (orig) => (shader, source) => orig.call(gl, shader && shader.id, source));
|
|
246
|
+
wrap('useProgram', (orig) => (program) => orig.call(gl, program && program.id));
|
|
247
|
+
wrap('validateProgram', (orig) => (program) => orig.call(gl, program && program.id));
|
|
248
|
+
wrap('isShader', (orig) => (shader) => shader instanceof WebGLShader && orig.call(gl, shader.id));
|
|
249
|
+
wrap('isProgram', (orig) => (program) => program instanceof WebGLProgram && orig.call(gl, program.id));
|
|
250
|
+
wrap('getFragDataLocation', (orig) => (program) => orig.call(gl, objectId(program)));
|
|
243
251
|
// Uniforms and attributes
|
|
244
|
-
wrap('getActiveAttrib', orig => (program, index) => new WebGLActiveInfo(orig.call(gl, program && program.id, index)));
|
|
245
|
-
wrap('getActiveUniform', orig => (program, index) => new WebGLActiveInfo(orig.call(gl, program && program.id, index)));
|
|
246
|
-
wrap('getAttribLocation', orig => (program, name) => orig.call(gl, program && program.id, name));
|
|
247
|
-
wrap('getUniform', orig => (program, location) => orig.call(gl, program && program.id, location && location.id));
|
|
248
|
-
wrap('getUniformLocation', orig => (program, name) => new WebGLUniformLocation(orig.call(gl, program && program.id, name)));
|
|
249
|
-
wrap(['uniform1f', 'uniform1i', 'uniform1ui'], orig => (loc, x) => orig.call(gl, objectId(loc), x));
|
|
250
|
-
wrap(['uniform2f', 'uniform2i', 'uniform2ui'], orig => (loc, x, y) => orig.call(gl, objectId(loc), x, y));
|
|
251
|
-
wrap(['uniform3f', 'uniform3i', 'uniform3ui'], orig => (loc, x, y, z) => orig.call(gl, objectId(loc), x, y, z));
|
|
252
|
-
wrap(['uniform4f', 'uniform4i', 'uniform4ui'], orig => (loc, x, y, z, w) => orig.call(gl, objectId(loc), x, y, z, w));
|
|
253
|
-
wrap(['uniform1fv', 'uniform2fv', 'uniform3fv', 'uniform4fv'], orig => (loc, val) => orig.call(gl, objectId(loc), new Float32Array(val)));
|
|
254
|
-
wrap(['uniform1iv', 'uniform2iv', 'uniform3iv', 'uniform4iv'], orig => (loc, val) => orig.call(gl, objectId(loc), new Int32Array(val)));
|
|
255
|
-
wrap(['uniform1uiv', 'uniform2uiv', 'uniform3uiv', 'uniform4uiv'], orig => (loc, val) => orig.call(gl, objectId(loc), new Uint32Array(val)));
|
|
252
|
+
wrap('getActiveAttrib', (orig) => (program, index) => new WebGLActiveInfo(orig.call(gl, program && program.id, index)));
|
|
253
|
+
wrap('getActiveUniform', (orig) => (program, index) => new WebGLActiveInfo(orig.call(gl, program && program.id, index)));
|
|
254
|
+
wrap('getAttribLocation', (orig) => (program, name) => orig.call(gl, program && program.id, name));
|
|
255
|
+
wrap('getUniform', (orig) => (program, location) => orig.call(gl, program && program.id, location && location.id));
|
|
256
|
+
wrap('getUniformLocation', (orig) => (program, name) => new WebGLUniformLocation(orig.call(gl, program && program.id, name)));
|
|
257
|
+
wrap(['uniform1f', 'uniform1i', 'uniform1ui'], (orig) => (loc, x) => orig.call(gl, objectId(loc), x));
|
|
258
|
+
wrap(['uniform2f', 'uniform2i', 'uniform2ui'], (orig) => (loc, x, y) => orig.call(gl, objectId(loc), x, y));
|
|
259
|
+
wrap(['uniform3f', 'uniform3i', 'uniform3ui'], (orig) => (loc, x, y, z) => orig.call(gl, objectId(loc), x, y, z));
|
|
260
|
+
wrap(['uniform4f', 'uniform4i', 'uniform4ui'], (orig) => (loc, x, y, z, w) => orig.call(gl, objectId(loc), x, y, z, w));
|
|
261
|
+
wrap(['uniform1fv', 'uniform2fv', 'uniform3fv', 'uniform4fv'], (orig) => (loc, val) => orig.call(gl, objectId(loc), new Float32Array(val)));
|
|
262
|
+
wrap(['uniform1iv', 'uniform2iv', 'uniform3iv', 'uniform4iv'], (orig) => (loc, val) => orig.call(gl, objectId(loc), new Int32Array(val)));
|
|
263
|
+
wrap(['uniform1uiv', 'uniform2uiv', 'uniform3uiv', 'uniform4uiv'], (orig) => (loc, val) => orig.call(gl, objectId(loc), new Uint32Array(val)));
|
|
256
264
|
wrap([
|
|
257
265
|
'uniformMatrix2fv',
|
|
258
266
|
'uniformMatrix3fv',
|
|
@@ -263,70 +271,70 @@ const wrapMethods = gl => {
|
|
|
263
271
|
'uniformMatrix4x3fv',
|
|
264
272
|
'uniformMatrix2x4fv',
|
|
265
273
|
'uniformMatrix3x4fv',
|
|
266
|
-
], orig => (loc, transpose, val) => orig.call(gl, loc && loc.id, transpose, new Float32Array(val)));
|
|
267
|
-
wrap(['vertexAttrib1fv', 'vertexAttrib2fv', 'vertexAttrib3fv', 'vertexAttrib4fv'], orig => (index, val) => orig.call(gl, index, new Float32Array(val)));
|
|
268
|
-
wrap('vertexAttribI4iv', orig => (index, val) => orig.call(gl, index, new Int32Array(val)));
|
|
269
|
-
wrap('vertexAttribI4uiv', orig => (index, val) => orig.call(gl, index, new Uint32Array(val)));
|
|
274
|
+
], (orig) => (loc, transpose, val) => orig.call(gl, loc && loc.id, transpose, new Float32Array(val)));
|
|
275
|
+
wrap(['vertexAttrib1fv', 'vertexAttrib2fv', 'vertexAttrib3fv', 'vertexAttrib4fv'], (orig) => (index, val) => orig.call(gl, index, new Float32Array(val)));
|
|
276
|
+
wrap('vertexAttribI4iv', (orig) => (index, val) => orig.call(gl, index, new Int32Array(val)));
|
|
277
|
+
wrap('vertexAttribI4uiv', (orig) => (index, val) => orig.call(gl, index, new Uint32Array(val)));
|
|
270
278
|
// Query objects
|
|
271
|
-
wrap('createQuery', orig => () => wrapObject(WebGLQuery, orig.call(gl)));
|
|
272
|
-
wrap('deleteQuery', orig => query => orig.call(gl, objectId(query)));
|
|
273
|
-
wrap('beginQuery', orig => (target, query) => orig.call(gl, target, objectId(query)));
|
|
274
|
-
wrap('getQuery', orig => (target, pname) => {
|
|
279
|
+
wrap('createQuery', (orig) => () => wrapObject(WebGLQuery, orig.call(gl)));
|
|
280
|
+
wrap('deleteQuery', (orig) => (query) => orig.call(gl, objectId(query)));
|
|
281
|
+
wrap('beginQuery', (orig) => (target, query) => orig.call(gl, target, objectId(query)));
|
|
282
|
+
wrap('getQuery', (orig) => (target, pname) => {
|
|
275
283
|
const id = orig.call(gl, target, pname);
|
|
276
284
|
return id ? wrapObject(WebGLQuery, id) : id;
|
|
277
285
|
});
|
|
278
|
-
wrap('getQueryParameter', orig => (query, pname) => orig.call(gl, objectId(query), pname));
|
|
286
|
+
wrap('getQueryParameter', (orig) => (query, pname) => orig.call(gl, objectId(query), pname));
|
|
279
287
|
// Samplers
|
|
280
|
-
wrap('bindSampler', orig => (unit, sampler) => orig.call(gl, unit, objectId(sampler)));
|
|
281
|
-
wrap('createSampler', orig => () => wrapObject(WebGLSampler, orig.call(gl)));
|
|
282
|
-
wrap('deleteSampler', orig => sampler => orig.call(gl, objectId(sampler)));
|
|
283
|
-
wrap('isSampler', orig => sampler => sampler instanceof WebGLSampler && orig.call(gl, sampler.id));
|
|
284
|
-
wrap(['samplerParameteri', 'samplerParameterf'], orig => (sampler, pname, param) => {
|
|
288
|
+
wrap('bindSampler', (orig) => (unit, sampler) => orig.call(gl, unit, objectId(sampler)));
|
|
289
|
+
wrap('createSampler', (orig) => () => wrapObject(WebGLSampler, orig.call(gl)));
|
|
290
|
+
wrap('deleteSampler', (orig) => (sampler) => orig.call(gl, objectId(sampler)));
|
|
291
|
+
wrap('isSampler', (orig) => (sampler) => sampler instanceof WebGLSampler && orig.call(gl, sampler.id));
|
|
292
|
+
wrap(['samplerParameteri', 'samplerParameterf'], (orig) => (sampler, pname, param) => {
|
|
285
293
|
return orig.call(gl, objectId(sampler), pname, param);
|
|
286
294
|
});
|
|
287
|
-
wrap('getSamplerParameter', orig => (sampler, pname) => {
|
|
295
|
+
wrap('getSamplerParameter', (orig) => (sampler, pname) => {
|
|
288
296
|
return orig.call(gl, objectId(sampler), pname);
|
|
289
297
|
});
|
|
290
298
|
// Transform feedback
|
|
291
|
-
wrap('bindTransformFeedback', orig => (target, transformFeedback) => {
|
|
299
|
+
wrap('bindTransformFeedback', (orig) => (target, transformFeedback) => {
|
|
292
300
|
return orig.call(gl, target, objectId(transformFeedback));
|
|
293
301
|
});
|
|
294
|
-
wrap('createTransformFeedback', orig => () => wrapObject(WebGLTransformFeedback, orig.call(gl)));
|
|
295
|
-
wrap('deleteTransformFeedback', orig => transformFeedback => {
|
|
302
|
+
wrap('createTransformFeedback', (orig) => () => wrapObject(WebGLTransformFeedback, orig.call(gl)));
|
|
303
|
+
wrap('deleteTransformFeedback', (orig) => (transformFeedback) => {
|
|
296
304
|
return orig.call(gl, objectId(transformFeedback));
|
|
297
305
|
});
|
|
298
|
-
wrap('transformFeedbackVaryings', orig => (program, varyings, bufferMode) => {
|
|
306
|
+
wrap('transformFeedbackVaryings', (orig) => (program, varyings, bufferMode) => {
|
|
299
307
|
return orig.call(gl, objectId(program), varyings, bufferMode);
|
|
300
308
|
});
|
|
301
|
-
wrap('getTransformFeedbackVarying', orig => (program, index) => {
|
|
309
|
+
wrap('getTransformFeedbackVarying', (orig) => (program, index) => {
|
|
302
310
|
return new WebGLActiveInfo(orig.call(gl, objectId(program), index));
|
|
303
311
|
});
|
|
304
312
|
// Uniforms and attributes
|
|
305
|
-
wrap(['bindBufferBase', 'bindBufferRange'], orig => (target, index, buffer, ...rest) => {
|
|
313
|
+
wrap(['bindBufferBase', 'bindBufferRange'], (orig) => (target, index, buffer, ...rest) => {
|
|
306
314
|
return orig.call(gl, target, index, objectId(buffer), ...rest);
|
|
307
315
|
});
|
|
308
|
-
wrap('getUniformIndices', orig => (program, uniformNames) => {
|
|
316
|
+
wrap('getUniformIndices', (orig) => (program, uniformNames) => {
|
|
309
317
|
// according to WebGL2 specs, it returns Array instead of Uint32Array
|
|
310
318
|
const uintArray = orig.call(gl, objectId(program), uniformNames);
|
|
311
319
|
return Array.from(uintArray);
|
|
312
320
|
});
|
|
313
|
-
wrap('getActiveUniforms', orig => (program, uniformIndices, pname) => {
|
|
321
|
+
wrap('getActiveUniforms', (orig) => (program, uniformIndices, pname) => {
|
|
314
322
|
// according to WebGL2 specs, it returns Array instead of Int32Array
|
|
315
323
|
const intArray = orig.call(gl, objectId(program), new Uint32Array(uniformIndices), pname);
|
|
316
324
|
const boolResult = pname === gl.UNIFORM_IS_ROW_MAJOR;
|
|
317
325
|
const arr = Array.from(intArray);
|
|
318
|
-
return boolResult ? arr.map(val => !!val) : arr;
|
|
326
|
+
return boolResult ? arr.map((val) => !!val) : arr;
|
|
319
327
|
});
|
|
320
|
-
wrap('getUniformBlockIndex', orig => (program, uniformBlockName) => orig.call(gl, objectId(program), uniformBlockName));
|
|
321
|
-
wrap('getActiveUniformBlockName', orig => (program, uniformBlockIndex) => orig.call(gl, objectId(program), uniformBlockIndex));
|
|
322
|
-
wrap('uniformBlockBinding', orig => (program, uniformBlockIndex, uniformBlockBinding) => {
|
|
328
|
+
wrap('getUniformBlockIndex', (orig) => (program, uniformBlockName) => orig.call(gl, objectId(program), uniformBlockName));
|
|
329
|
+
wrap('getActiveUniformBlockName', (orig) => (program, uniformBlockIndex) => orig.call(gl, objectId(program), uniformBlockIndex));
|
|
330
|
+
wrap('uniformBlockBinding', (orig) => (program, uniformBlockIndex, uniformBlockBinding) => {
|
|
323
331
|
return orig.call(gl, objectId(program), uniformBlockIndex, uniformBlockBinding);
|
|
324
332
|
});
|
|
325
333
|
// Vertex array objects
|
|
326
|
-
wrap('bindVertexArray', orig => vertexArray => orig.call(gl, vertexArray && vertexArray.id));
|
|
327
|
-
wrap('createVertexArray', orig => () => wrapObject(WebGLVertexArrayObject, orig.call(gl)));
|
|
328
|
-
wrap('deleteVertexArray', orig => vertexArray => orig.call(gl, vertexArray && vertexArray.id));
|
|
329
|
-
wrap('isVertexArray', orig => vertexArray => vertexArray instanceof WebGLVertexArrayObject && orig.call(gl, vertexArray.id));
|
|
334
|
+
wrap('bindVertexArray', (orig) => (vertexArray) => orig.call(gl, vertexArray && vertexArray.id));
|
|
335
|
+
wrap('createVertexArray', (orig) => () => wrapObject(WebGLVertexArrayObject, orig.call(gl)));
|
|
336
|
+
wrap('deleteVertexArray', (orig) => (vertexArray) => orig.call(gl, vertexArray && vertexArray.id));
|
|
337
|
+
wrap('isVertexArray', (orig) => (vertexArray) => vertexArray instanceof WebGLVertexArrayObject && orig.call(gl, vertexArray.id));
|
|
330
338
|
};
|
|
331
339
|
// Get the GL interface from an EXGLContextID and do JS-side setup
|
|
332
340
|
const getGl = (exglCtxId) => {
|