Skip to content

Commit

Permalink
[expo-gl-cpp] enable stencil buffer on Android (#9928)
Browse files Browse the repository at this point in the history
* [expo-gl-cpp] enable stencil buffer on Android

* update CHANGELOG.md
  • Loading branch information
wkozyra95 committed Aug 25, 2020
1 parent 5810672 commit 0bf8402
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/native-component-list/package.json
Expand Up @@ -23,6 +23,7 @@
"date-format": "^2.0.0",
"deep-object-diff": "^1.1.0",
"expo": "~39.0.0",
"expo-2d-context": "^0.0.2",
"expo-ads-admob": "~8.3.0",
"expo-ads-facebook": "~8.4.0",
"expo-app-auth": "~9.2.0",
Expand Down
31 changes: 31 additions & 0 deletions apps/native-component-list/src/screens/GL/GLScreens.tsx
Expand Up @@ -3,6 +3,7 @@ import './BeforePIXI';
import * as React from 'react';
import { Platform } from '@unimodules/core';
import { Asset } from 'expo-asset';
import Expo2DContext from 'expo-2d-context';
import * as PIXI from 'pixi.js';
import { Dimensions } from 'react-native';

Expand Down Expand Up @@ -492,6 +493,36 @@ const GLScreens: Screens = {
}),
},

Canvas: {
screen: GLWrap('Canvas example - expo-2d-context', async gl => {
const ctx = new Expo2DContext(gl);
ctx.translate(50, 200);
ctx.scale(4, 4);
ctx.fillStyle = 'grey';
ctx.fillRect(20, 40, 100, 100);
ctx.fillStyle = 'white';
ctx.fillRect(30, 100, 20, 30);
ctx.fillRect(60, 100, 20, 30);
ctx.fillRect(90, 100, 20, 30);
ctx.beginPath();
ctx.arc(50, 70, 18, 0, 2 * Math.PI);
ctx.arc(90, 70, 18, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = 'grey';
ctx.beginPath();
ctx.arc(50, 70, 8, 0, 2 * Math.PI);
ctx.arc(90, 70, 8, 0, 2 * Math.PI);
ctx.fill();
ctx.strokeStyle = 'black';
ctx.beginPath();
ctx.moveTo(70, 40);
ctx.lineTo(70, 30);
ctx.arc(70, 20, 10, 0.5 * Math.PI, 2.5 * Math.PI);
ctx.stroke();
ctx.flush();
}),
},

HeadlessRendering: {
screen: GLHeadlessRenderingScreen,
},
Expand Down
Binary file modified packages/expo-gl-cpp/android/dist/arm64-v8a/libexpo-gl.so
Binary file not shown.
Binary file modified packages/expo-gl-cpp/android/dist/armeabi-v7a/libexpo-gl.so
Binary file not shown.
Binary file modified packages/expo-gl-cpp/android/dist/x86/libexpo-gl.so
Binary file not shown.
Binary file modified packages/expo-gl-cpp/android/dist/x86_64/libexpo-gl.so
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/expo-gl-cpp/cpp/EXGLNativeMethods.cpp
Expand Up @@ -36,7 +36,7 @@ NATIVE_METHOD(getContextAttributes) {
jsi::Object jsResult(runtime);
jsResult.setProperty(runtime, "alpha", true);
jsResult.setProperty(runtime, "depth", true);
jsResult.setProperty(runtime, "stencil", false);
jsResult.setProperty(runtime, "stencil", true);
jsResult.setProperty(runtime, "antialias", false);
jsResult.setProperty(runtime, "premultipliedAlpha", false);
return jsResult;
Expand Down
2 changes: 2 additions & 0 deletions packages/expo-gl/CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@

### 🎉 New features

- Enable stencil buffer on Android ([#9928](https://github.com/expo/expo/pull/9928) by [@wkozyra95](https://github.com/wkozyra95))

### 🐛 Bug fixes

## 9.1.0 — 2020-08-18
Expand Down
Expand Up @@ -377,7 +377,7 @@ private void initEGL() {
int[] configSpec = {
EGL10.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_STENCIL_SIZE, 0,
EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_STENCIL_SIZE, 8,
EGL10.EGL_NONE,
};
if (!mEGL.eglChooseConfig(mEGLDisplay, configSpec, configs, 1, configsCount)) {
Expand Down

0 comments on commit 0bf8402

Please sign in to comment.