expo-gl 15.0.3 → 15.0.4
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
CHANGED
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '15.0.
|
|
4
|
+
version = '15.0.4'
|
|
5
5
|
|
|
6
6
|
def reactNativeArchitectures() {
|
|
7
7
|
def value = project.getProperties().get("reactNativeArchitectures")
|
|
@@ -26,7 +26,7 @@ android {
|
|
|
26
26
|
namespace "expo.modules.gl"
|
|
27
27
|
defaultConfig {
|
|
28
28
|
versionCode 31
|
|
29
|
-
versionName "15.0.
|
|
29
|
+
versionName "15.0.4"
|
|
30
30
|
|
|
31
31
|
externalNativeBuild {
|
|
32
32
|
cmake {
|
|
@@ -61,6 +61,7 @@ import static android.opengl.GLES30.glUniformMatrix4fv;
|
|
|
61
61
|
import static android.opengl.GLES30.glUseProgram;
|
|
62
62
|
import static android.opengl.GLES30.glVertexAttribPointer;
|
|
63
63
|
import static android.opengl.GLES30.glViewport;
|
|
64
|
+
import static android.opengl.Matrix.orthoM;
|
|
64
65
|
import static expo.modules.gl.cpp.EXGL.EXGLContextMapObject;
|
|
65
66
|
|
|
66
67
|
public class GLCameraObject extends GLObject implements SurfaceTexture.OnFrameAvailableListener {
|
|
@@ -77,24 +78,34 @@ public class GLCameraObject extends GLObject implements SurfaceTexture.OnFrameAv
|
|
|
77
78
|
|
|
78
79
|
private SurfaceTexture mCameraSurfaceTexture;
|
|
79
80
|
|
|
81
|
+
/* Coordinates that define how a texture is mapped onto a surface. Typically the values are
|
|
82
|
+
0.0f, 0.0f
|
|
83
|
+
1.0f, 0.0f
|
|
84
|
+
0.0f, 1.0f
|
|
85
|
+
1.0f, 0.0f
|
|
86
|
+
1.0f, 1.0f
|
|
87
|
+
0.0f, 1.0f
|
|
88
|
+
We invert them because [SurfaceTexture] has an inverted Y-Axis
|
|
89
|
+
*/
|
|
80
90
|
private float textureCoords[] = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
0.0f, 1.0f, // Bottom-left
|
|
92
|
+
1.0f, 1.0f, // Bottom-right
|
|
93
|
+
0.0f, 0.0f, // Top-left
|
|
94
|
+
1.0f, 1.0f, // Bottom-right
|
|
95
|
+
1.0f, 0.0f, // Top-right
|
|
96
|
+
0.0f, 0.0f // Top-left
|
|
87
97
|
};
|
|
88
98
|
|
|
89
99
|
private static String vertexShaderSource
|
|
90
100
|
= "precision highp float;"
|
|
91
101
|
+ "attribute vec4 position;"
|
|
92
102
|
+ "uniform mat4 transformMatrix;"
|
|
103
|
+
+ "uniform mat4 projectionMatrix;"
|
|
93
104
|
+ "varying vec2 coords;"
|
|
94
105
|
+ "void main() {"
|
|
95
106
|
+ " vec2 clipSpace = (1.0 - 2.0 * position.xy);"
|
|
96
107
|
+ " coords = (transformMatrix * position).xy;"
|
|
97
|
-
+ " gl_Position = vec4(clipSpace, 0.0, 1.0);"
|
|
108
|
+
+ " gl_Position = projectionMatrix * vec4(clipSpace, 0.0, 1.0);"
|
|
98
109
|
+ "}";
|
|
99
110
|
|
|
100
111
|
private static String fragmentShaderSource
|
|
@@ -180,6 +191,9 @@ public class GLCameraObject extends GLObject implements SurfaceTexture.OnFrameAv
|
|
|
180
191
|
int[] prevVertexArray = new int[1];
|
|
181
192
|
int[] viewport = new int[4];
|
|
182
193
|
float[] transformMatrix = new float[16];
|
|
194
|
+
float[] projectionMatrix = new float[16];
|
|
195
|
+
|
|
196
|
+
orthoM(projectionMatrix, 0, -1f, 1f, -1f, 1f, -1f, 1f);
|
|
183
197
|
|
|
184
198
|
// get previous state
|
|
185
199
|
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, prevFramebuffer, 0);
|
|
@@ -196,6 +210,7 @@ public class GLCameraObject extends GLObject implements SurfaceTexture.OnFrameAv
|
|
|
196
210
|
int positionLocation = glGetAttribLocation(mProgram, "position");
|
|
197
211
|
int transformLocation = glGetUniformLocation(mProgram, "transformMatrix");
|
|
198
212
|
int textureLocation = glGetUniformLocation(mProgram, "cameraTexture");
|
|
213
|
+
int projectionLocation = glGetUniformLocation(mProgram, "projectionMatrix");
|
|
199
214
|
|
|
200
215
|
// setup objects on the first frame
|
|
201
216
|
if (mTextureWidth == -1) {
|
|
@@ -242,6 +257,9 @@ public class GLCameraObject extends GLObject implements SurfaceTexture.OnFrameAv
|
|
|
242
257
|
glBindTexture(GL_TEXTURE_EXTERNAL_OES, mExtTexture);
|
|
243
258
|
glUniform1i(textureLocation, prevActiveTexture[0] - GL_TEXTURE0);
|
|
244
259
|
glUniformMatrix4fv(transformLocation, 1, false, transformMatrix, 0);
|
|
260
|
+
glUniformMatrix4fv(projectionLocation, 1, false, projectionMatrix, 0);
|
|
261
|
+
glUniform1i(textureLocation, prevActiveTexture[0] - GL_TEXTURE0);
|
|
262
|
+
glUniformMatrix4fv(transformLocation, 1, false, transformMatrix, 0);
|
|
245
263
|
|
|
246
264
|
// change viewport to fit the texture and draw
|
|
247
265
|
glViewport(0, 0, mTextureWidth, mTextureHeight);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gl",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.4",
|
|
4
4
|
"description": "Provides GLView that acts as OpenGL ES render target and gives GL context object implementing WebGL 2.0 specification.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"optional": true
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0a0c6d35a691fc59c0d94675d159ac9e3dfd6f26"
|
|
61
61
|
}
|