Skip to content

Commit 6ab655d

Browse files
committed
fix crash below api 16
1 parent cd16d46 commit 6ab655d

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

README-en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ allprojects {
4343
4444
// module build.gradle
4545
dependencies {
46-
implementation 'com.github.ChillingVan:android-openGL-canvas:v1.4.1.0'
46+
implementation 'com.github.ChillingVan:android-openGL-canvas:v1.4.1.1'
4747
}
4848
```
4949

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ allprojects {
4848
4949
// module build.gradle
5050
dependencies {
51-
implementation 'com.github.ChillingVan:android-openGL-canvas:v1.4.1.0'
51+
implementation 'com.github.ChillingVan:android-openGL-canvas:v1.4.1.1'
5252
}
5353
```
5454

canvasgl/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ android {
2828
defaultConfig {
2929
minSdkVersion 14
3030
targetSdkVersion 27
31-
versionCode 104010
32-
versionName "1.4.1.0"
31+
versionCode 104011
32+
versionName "1.4.1.1"
3333
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3434
}
3535
buildTypes {

canvasgl/src/main/java/com/chillingvan/canvasgl/glview/GLView.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public GLView(Context context, AttributeSet attrs) {
5959
protected void init() {
6060
setZOrderOnTop(true);
6161
setEGLContextClientVersion(2);
62-
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
62+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
63+
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
64+
} else {
65+
setEGLConfigChooser(5, 6, 5, 8, 0, 0);
66+
}
6367
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
6468
setPreserveEGLContextOnPause(true);
6569
}

canvasgl/src/main/java/com/chillingvan/canvasgl/glview/texture/gles/GLThread.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,21 @@ private int findConfigAttrib(EGL10 egl, EGLDisplay display,
881881
* or without a depth buffer.
882882
*/
883883
public static class SimpleEGLConfigChooser extends ComponentSizeChooser {
884+
public static SimpleEGLConfigChooser createConfigChooser(boolean withDepthBuffer, int contextClientVersion) {
885+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
886+
return new SimpleEGLConfigChooser(withDepthBuffer, contextClientVersion);
887+
} else {
888+
return new SimpleEGLConfigChooser(5, 6, 5, 8, 0, 0, contextClientVersion);
889+
}
890+
}
891+
884892
public SimpleEGLConfigChooser(boolean withDepthBuffer, int contextClientVersion) {
885893
super(8, 8, 8, 0, withDepthBuffer ? 16 : 0, 0, contextClientVersion);
886894
}
895+
896+
public SimpleEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize, int contextClientVersion) {
897+
super(redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize, contextClientVersion);
898+
}
887899
}
888900

889901

@@ -1037,7 +1049,7 @@ public Builder setSurface(Object surface) {
10371049

10381050

10391051
public Builder setEGLConfigChooser(boolean needDepth) {
1040-
setEGLConfigChooser(new SimpleEGLConfigChooser(needDepth, eglContextClientVersion));
1052+
setEGLConfigChooser(SimpleEGLConfigChooser.createConfigChooser(needDepth, eglContextClientVersion));
10411053
return this;
10421054
}
10431055

@@ -1096,7 +1108,7 @@ public GLThread createGLThread() {
10961108
throw new NullPointerException("surface has not been set");
10971109
}
10981110
if (configChooser == null) {
1099-
configChooser = new SimpleEGLConfigChooser(true, eglContextClientVersion);
1111+
configChooser = SimpleEGLConfigChooser.createConfigChooser(true, eglContextClientVersion);
11001112
}
11011113
if (eglContextFactory == null) {
11021114
eglContextFactory = new DefaultContextFactory(eglContextClientVersion);

canvasglsample/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ android {
2828
applicationId "com.chillingvan.canvasglsample"
2929
minSdkVersion 15
3030
targetSdkVersion 27
31-
versionCode 4
31+
versionCode 5
3232
versionName "1.4"
3333

3434
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

0 commit comments

Comments
 (0)