Skip to content

Commit 1659b4b

Browse files
committed
Switch from the javax.microedition.khronos.* to the androd.opengl.* APIs and classes
1 parent 5ebcd66 commit 1659b4b

File tree

9 files changed

+266
-942
lines changed

9 files changed

+266
-942
lines changed

platform/android/java/lib/src/org/godotengine/godot/render/EGLLogWrapper.java

Lines changed: 0 additions & 596 deletions
This file was deleted.

platform/android/java/lib/src/org/godotengine/godot/render/GLSurfaceView.java

Lines changed: 91 additions & 202 deletions
Large diffs are not rendered by default.

platform/android/java/lib/src/org/godotengine/godot/render/OvrConfigChooser.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,34 @@
3030

3131
package org.godotengine.godot.render;
3232

33+
import android.opengl.EGL14;
34+
import android.opengl.EGLConfig;
35+
import android.opengl.EGLDisplay;
3336
import android.opengl.EGLExt;
3437

35-
import javax.microedition.khronos.egl.EGL10;
36-
import javax.microedition.khronos.egl.EGLConfig;
37-
import javax.microedition.khronos.egl.EGLDisplay;
38-
3938
/**
4039
* EGL config chooser for the Oculus Mobile VR SDK.
4140
*/
4241
class OvrConfigChooser implements GLSurfaceView.EGLConfigChooser {
4342
private static final int[] CONFIG_ATTRIBS = {
44-
EGL10.EGL_RED_SIZE, 8,
45-
EGL10.EGL_GREEN_SIZE, 8,
46-
EGL10.EGL_BLUE_SIZE, 8,
47-
EGL10.EGL_ALPHA_SIZE, 8, // Need alpha for the multi-pass timewarp compositor
48-
EGL10.EGL_DEPTH_SIZE, 0,
49-
EGL10.EGL_STENCIL_SIZE, 0,
50-
EGL10.EGL_SAMPLES, 0,
51-
EGL10.EGL_NONE
43+
EGL14.EGL_RED_SIZE, 8,
44+
EGL14.EGL_GREEN_SIZE, 8,
45+
EGL14.EGL_BLUE_SIZE, 8,
46+
EGL14.EGL_ALPHA_SIZE, 8, // Need alpha for the multi-pass timewarp compositor
47+
EGL14.EGL_DEPTH_SIZE, 0,
48+
EGL14.EGL_STENCIL_SIZE, 0,
49+
EGL14.EGL_SAMPLES, 0,
50+
EGL14.EGL_NONE
5251
};
5352

5453
@Override
55-
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
54+
public EGLConfig chooseConfig(EGLDisplay display) {
5655
// Do NOT use eglChooseConfig, because the Android EGL code pushes in
5756
// multisample flags in eglChooseConfig if the user has selected the "force 4x
5857
// MSAA" option in settings, and that is completely wasted for our warp
5958
// target.
6059
int[] numConfig = new int[1];
61-
if (!egl.eglGetConfigs(display, null, 0, numConfig)) {
60+
if (!EGL14.eglGetConfigs(display, null, 0, 0, numConfig, 0)) {
6261
throw new IllegalArgumentException("eglGetConfigs failed.");
6362
}
6463

@@ -68,29 +67,29 @@ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
6867
}
6968

7069
EGLConfig[] configs = new EGLConfig[configsCount];
71-
if (!egl.eglGetConfigs(display, configs, configsCount, numConfig)) {
70+
if (!EGL14.eglGetConfigs(display, configs, 0, configsCount, numConfig, 0)) {
7271
throw new IllegalArgumentException("eglGetConfigs #2 failed.");
7372
}
7473

7574
int[] value = new int[1];
7675
for (EGLConfig config : configs) {
77-
egl.eglGetConfigAttrib(display, config, EGL10.EGL_RENDERABLE_TYPE, value);
76+
EGL14.eglGetConfigAttrib(display, config, EGL14.EGL_RENDERABLE_TYPE, value, 0);
7877
if ((value[0] & EGLExt.EGL_OPENGL_ES3_BIT_KHR) != EGLExt.EGL_OPENGL_ES3_BIT_KHR) {
7978
continue;
8079
}
8180

8281
// The pbuffer config also needs to be compatible with normal window rendering
8382
// so it can share textures with the window context.
84-
egl.eglGetConfigAttrib(display, config, EGL10.EGL_SURFACE_TYPE, value);
85-
if ((value[0] & (EGL10.EGL_WINDOW_BIT | EGL10.EGL_PBUFFER_BIT)) != (EGL10.EGL_WINDOW_BIT | EGL10.EGL_PBUFFER_BIT)) {
83+
EGL14.eglGetConfigAttrib(display, config, EGL14.EGL_SURFACE_TYPE, value, 0);
84+
if ((value[0] & (EGL14.EGL_WINDOW_BIT | EGL14.EGL_PBUFFER_BIT)) != (EGL14.EGL_WINDOW_BIT | EGL14.EGL_PBUFFER_BIT)) {
8685
continue;
8786
}
8887

8988
// Check each attribute in CONFIG_ATTRIBS (which are the attributes we care about)
9089
// and ensure the value in config matches.
9190
int attribIndex = 0;
92-
while (CONFIG_ATTRIBS[attribIndex] != EGL10.EGL_NONE) {
93-
egl.eglGetConfigAttrib(display, config, CONFIG_ATTRIBS[attribIndex], value);
91+
while (CONFIG_ATTRIBS[attribIndex] != EGL14.EGL_NONE) {
92+
EGL14.eglGetConfigAttrib(display, config, CONFIG_ATTRIBS[attribIndex], value, 0);
9493
if (value[0] != CONFIG_ATTRIBS[attribIndex + 1]) {
9594
// Attribute key's value does not match the configs value.
9695
// Start checking next config.
@@ -101,7 +100,7 @@ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
101100
attribIndex += 2;
102101
}
103102

104-
if (CONFIG_ATTRIBS[attribIndex] == EGL10.EGL_NONE) {
103+
if (CONFIG_ATTRIBS[attribIndex] == EGL14.EGL_NONE) {
105104
// All relevant attributes match, set the config and stop checking the rest.
106105
return config;
107106
}

platform/android/java/lib/src/org/godotengine/godot/render/OvrContextFactory.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,25 @@
3131
package org.godotengine.godot.render;
3232

3333
import android.opengl.EGL14;
34-
35-
import javax.microedition.khronos.egl.EGL10;
36-
import javax.microedition.khronos.egl.EGLConfig;
37-
import javax.microedition.khronos.egl.EGLContext;
38-
import javax.microedition.khronos.egl.EGLDisplay;
34+
import android.opengl.EGLConfig;
35+
import android.opengl.EGLContext;
36+
import android.opengl.EGLDisplay;
3937

4038
/**
4139
* EGL Context factory for the Oculus mobile VR SDK.
4240
*/
4341
class OvrContextFactory implements GLSurfaceView.EGLContextFactory {
4442
private static final int[] CONTEXT_ATTRIBS = {
45-
EGL14.EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE
43+
EGL14.EGL_CONTEXT_CLIENT_VERSION, 3, EGL14.EGL_NONE
4644
};
4745

4846
@Override
49-
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
50-
return egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, CONTEXT_ATTRIBS);
47+
public EGLContext createContext(EGLDisplay display, EGLConfig eglConfig) {
48+
return EGL14.eglCreateContext(display, eglConfig, EGL14.EGL_NO_CONTEXT, CONTEXT_ATTRIBS, 0);
5149
}
5250

5351
@Override
54-
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
55-
egl.eglDestroyContext(display, context);
52+
public void destroyContext(EGLDisplay display, EGLContext context) {
53+
EGL14.eglDestroyContext(display, context);
5654
}
5755
}

platform/android/java/lib/src/org/godotengine/godot/render/OvrWindowSurfaceFactory.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,24 @@
3030

3131
package org.godotengine.godot.render;
3232

33+
import android.opengl.EGL14;
34+
import android.opengl.EGLConfig;
35+
import android.opengl.EGLDisplay;
36+
import android.opengl.EGLSurface;
3337
import android.view.SurfaceHolder;
3438

35-
import javax.microedition.khronos.egl.EGL10;
36-
import javax.microedition.khronos.egl.EGLConfig;
37-
import javax.microedition.khronos.egl.EGLDisplay;
38-
import javax.microedition.khronos.egl.EGLSurface;
39-
4039
/**
4140
* EGL window surface factory for the Oculus mobile VR SDK.
4241
*/
4342
class OvrWindowSurfaceFactory implements GLSurfaceView.EGLWindowSurfaceFactory {
4443
private final static int[] SURFACE_ATTRIBS = {
45-
EGL10.EGL_WIDTH, 16,
46-
EGL10.EGL_HEIGHT, 16,
47-
EGL10.EGL_NONE
44+
EGL14.EGL_WIDTH, 16,
45+
EGL14.EGL_HEIGHT, 16,
46+
EGL14.EGL_NONE
4847
};
4948

5049
@Override
51-
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, EGLConfig config, SurfaceHolder surfaceHolder) {
52-
return egl.eglCreatePbufferSurface(display, config, SURFACE_ATTRIBS);
50+
public EGLSurface createWindowSurface(EGLDisplay display, EGLConfig config, SurfaceHolder surfaceHolder) {
51+
return EGL14.eglCreatePbufferSurface(display, config, SURFACE_ATTRIBS, 0);
5352
}
5453
}

platform/android/java/lib/src/org/godotengine/godot/render/RegularConfigChooser.java

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,30 @@
3232

3333
import org.godotengine.godot.utils.GLUtils;
3434

35-
import javax.microedition.khronos.egl.EGL10;
36-
import javax.microedition.khronos.egl.EGLConfig;
37-
import javax.microedition.khronos.egl.EGLDisplay;
35+
import android.opengl.EGL14;
36+
import android.opengl.EGLConfig;
37+
import android.opengl.EGLDisplay;
3838

3939
/**
4040
* Used to select the egl config for pancake games.
4141
*/
4242
class RegularConfigChooser implements GLSurfaceView.EGLConfigChooser {
4343
private static final String TAG = RegularConfigChooser.class.getSimpleName();
4444

45-
private int[] mValue = new int[1];
45+
private final int[] mValue = new int[1];
4646

4747
/* This EGL config specification is used to specify 3.0 rendering.
4848
* We use a minimum size of 4 bits for red/green/blue, but will
4949
* perform actual matching in chooseConfig() below.
5050
*/
51-
private static int EGL_OPENGL_ES2_BIT = 4;
52-
private static int[] s_configAttribs = {
53-
EGL10.EGL_RED_SIZE, 4,
54-
EGL10.EGL_GREEN_SIZE, 4,
55-
EGL10.EGL_BLUE_SIZE, 4,
56-
// EGL10.EGL_DEPTH_SIZE, 16,
57-
// EGL10.EGL_STENCIL_SIZE, EGL10.EGL_DONT_CARE,
58-
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, //apparently there is no EGL_OPENGL_ES3_BIT
59-
EGL10.EGL_NONE
51+
private static final int[] s_configAttribs = {
52+
EGL14.EGL_RED_SIZE, 4,
53+
EGL14.EGL_GREEN_SIZE, 4,
54+
EGL14.EGL_BLUE_SIZE, 4,
55+
// EGL14.EGL_DEPTH_SIZE, 16,
56+
// EGL14.EGL_STENCIL_SIZE, EGL14.EGL_DONT_CARE,
57+
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, //apparently there is no EGL_OPENGL_ES3_BIT
58+
EGL14.EGL_NONE
6059
};
6160

6261
public RegularConfigChooser(int r, int g, int b, int a, int depth, int stencil) {
@@ -68,11 +67,11 @@ public RegularConfigChooser(int r, int g, int b, int a, int depth, int stencil)
6867
mStencilSize = stencil;
6968
}
7069

71-
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
70+
public EGLConfig chooseConfig(EGLDisplay display) {
7271
/* Get the number of minimally matching EGL configurations
7372
*/
7473
int[] num_config = new int[1];
75-
egl.eglChooseConfig(display, s_configAttribs, null, 0, num_config);
74+
EGL14.eglChooseConfig(display, s_configAttribs, 0, null, 0, 0, num_config, 0);
7675

7776
int numConfigs = num_config[0];
7877

@@ -83,47 +82,46 @@ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
8382
/* Allocate then read the array of minimally matching EGL configs
8483
*/
8584
EGLConfig[] configs = new EGLConfig[numConfigs];
86-
egl.eglChooseConfig(display, s_configAttribs, configs, numConfigs, num_config);
85+
EGL14.eglChooseConfig(display, s_configAttribs, 0, configs, 0, numConfigs, num_config, 0);
8786

8887
if (GLUtils.DEBUG) {
89-
GLUtils.printConfigs(egl, display, configs);
88+
GLUtils.printConfigs(display, configs);
9089
}
9190
/* Now return the "best" one
9291
*/
93-
return chooseConfig(egl, display, configs);
92+
return chooseConfig(display, configs);
9493
}
9594

96-
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
97-
EGLConfig[] configs) {
95+
public EGLConfig chooseConfig(EGLDisplay display, EGLConfig[] configs) {
9896
for (EGLConfig config : configs) {
99-
int d = findConfigAttrib(egl, display, config,
100-
EGL10.EGL_DEPTH_SIZE, 0);
101-
int s = findConfigAttrib(egl, display, config,
102-
EGL10.EGL_STENCIL_SIZE, 0);
97+
int d = findConfigAttrib(display, config,
98+
EGL14.EGL_DEPTH_SIZE, 0);
99+
int s = findConfigAttrib(display, config,
100+
EGL14.EGL_STENCIL_SIZE, 0);
103101

104102
// We need at least mDepthSize and mStencilSize bits
105103
if (d < mDepthSize || s < mStencilSize)
106104
continue;
107105

108106
// We want an *exact* match for red/green/blue/alpha
109-
int r = findConfigAttrib(egl, display, config,
110-
EGL10.EGL_RED_SIZE, 0);
111-
int g = findConfigAttrib(egl, display, config,
112-
EGL10.EGL_GREEN_SIZE, 0);
113-
int b = findConfigAttrib(egl, display, config,
114-
EGL10.EGL_BLUE_SIZE, 0);
115-
int a = findConfigAttrib(egl, display, config,
116-
EGL10.EGL_ALPHA_SIZE, 0);
107+
int r = findConfigAttrib(display, config,
108+
EGL14.EGL_RED_SIZE, 0);
109+
int g = findConfigAttrib(display, config,
110+
EGL14.EGL_GREEN_SIZE, 0);
111+
int b = findConfigAttrib(display, config,
112+
EGL14.EGL_BLUE_SIZE, 0);
113+
int a = findConfigAttrib(display, config,
114+
EGL14.EGL_ALPHA_SIZE, 0);
117115

118116
if (r == mRedSize && g == mGreenSize && b == mBlueSize && a == mAlphaSize)
119117
return config;
120118
}
121119
return null;
122120
}
123121

124-
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
122+
private int findConfigAttrib(EGLDisplay display,
125123
EGLConfig config, int attribute, int defaultValue) {
126-
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
124+
if (EGL14.eglGetConfigAttrib(display, config, attribute, mValue, 0)) {
127125
return mValue[0];
128126
}
129127
return defaultValue;

platform/android/java/lib/src/org/godotengine/godot/render/RegularContextFactory.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232

3333
import org.godotengine.godot.utils.GLUtils;
3434

35+
import android.opengl.EGL14;
36+
import android.opengl.EGLConfig;
37+
import android.opengl.EGLContext;
38+
import android.opengl.EGLDisplay;
3539
import android.util.Log;
3640

37-
import javax.microedition.khronos.egl.EGL10;
38-
import javax.microedition.khronos.egl.EGLConfig;
39-
import javax.microedition.khronos.egl.EGLContext;
40-
import javax.microedition.khronos.egl.EGLDisplay;
41-
4241
/**
4342
* Factory used to setup the opengl context for pancake games.
4443
*/
@@ -48,7 +47,7 @@ class RegularContextFactory implements GLSurfaceView.EGLContextFactory {
4847
private static final int _EGL_CONTEXT_FLAGS_KHR = 0x30FC;
4948
private static final int _EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR = 0x00000001;
5049

51-
private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
50+
private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
5251

5352
private final boolean mUseDebugOpengl;
5453

@@ -60,27 +59,27 @@ public RegularContextFactory(boolean useDebugOpengl) {
6059
this.mUseDebugOpengl = useDebugOpengl;
6160
}
6261

63-
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
62+
public EGLContext createContext(EGLDisplay display, EGLConfig eglConfig) {
6463
Log.w(TAG, "creating OpenGL ES 3.0 context :");
6564

66-
GLUtils.checkEglError(TAG, "Before eglCreateContext", egl);
65+
GLUtils.checkEglError(TAG, "Before eglCreateContext");
6766
EGLContext context;
68-
int[] debug_attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 3, _EGL_CONTEXT_FLAGS_KHR, _EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR, EGL10.EGL_NONE };
69-
int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE };
67+
int[] debug_attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 3, _EGL_CONTEXT_FLAGS_KHR, _EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR, EGL14.EGL_NONE };
68+
int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL14.EGL_NONE };
7069
if (mUseDebugOpengl) {
71-
context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, debug_attrib_list);
72-
if (context == null || context == EGL10.EGL_NO_CONTEXT) {
70+
context = EGL14.eglCreateContext(display, eglConfig, EGL14.EGL_NO_CONTEXT, debug_attrib_list, 0);
71+
if (context == null || context == EGL14.EGL_NO_CONTEXT) {
7372
Log.w(TAG, "creating 'OpenGL Debug' context failed");
74-
context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
73+
context = EGL14.eglCreateContext(display, eglConfig, EGL14.EGL_NO_CONTEXT, attrib_list, 0);
7574
}
7675
} else {
77-
context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
76+
context = EGL14.eglCreateContext(display, eglConfig, EGL14.EGL_NO_CONTEXT, attrib_list, 0);
7877
}
79-
GLUtils.checkEglError(TAG, "After eglCreateContext", egl);
78+
GLUtils.checkEglError(TAG, "After eglCreateContext");
8079
return context;
8180
}
8281

83-
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
84-
egl.eglDestroyContext(display, context);
82+
public void destroyContext(EGLDisplay display, EGLContext context) {
83+
EGL14.eglDestroyContext(display, context);
8584
}
8685
}

platform/android/java/lib/src/org/godotengine/godot/render/RegularFallbackConfigChooser.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,27 @@
3030

3131
package org.godotengine.godot.render;
3232

33+
import android.opengl.EGLConfig;
34+
import android.opengl.EGLDisplay;
3335
import android.util.Log;
3436

35-
import javax.microedition.khronos.egl.EGL10;
36-
import javax.microedition.khronos.egl.EGLConfig;
37-
import javax.microedition.khronos.egl.EGLDisplay;
38-
3937
/* Fallback if the requested configuration is not supported */
4038
class RegularFallbackConfigChooser extends RegularConfigChooser {
4139
private static final String TAG = RegularFallbackConfigChooser.class.getSimpleName();
4240

43-
private RegularConfigChooser fallback;
41+
private final RegularConfigChooser fallback;
4442

4543
public RegularFallbackConfigChooser(int r, int g, int b, int a, int depth, int stencil, RegularConfigChooser fallback) {
4644
super(r, g, b, a, depth, stencil);
4745
this.fallback = fallback;
4846
}
4947

5048
@Override
51-
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
52-
EGLConfig ec = super.chooseConfig(egl, display, configs);
49+
public EGLConfig chooseConfig(EGLDisplay display, EGLConfig[] configs) {
50+
EGLConfig ec = super.chooseConfig(display, configs);
5351
if (ec == null) {
5452
Log.w(TAG, "Trying ConfigChooser fallback");
55-
ec = fallback.chooseConfig(egl, display, configs);
53+
ec = fallback.chooseConfig(display, configs);
5654
}
5755
return ec;
5856
}

0 commit comments

Comments
 (0)