Game Development Reference
In-Depth Information
int numConfigs = num_config[0];
// Allocate then read the array of minimally matching EGL configs
EGLConfig[] configs = new EGLConfig[numConfigs];
egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config);
With this information, it chooses the best configuration that matches the original
configuration spec.
Listing 4-8. Configuration Chooser
class ConfigChooser implements GLSurfaceView.EGLConfigChooser {
private static final String TAG = "ConfigChooser";
private boolean DEBUG = false;
public ConfigChooser(int r, int g, int b, int a, int depth, int stencil) {
mRedSize = r;
mGreenSize = g;
mBlueSize = b;
mAlphaSize = a;
mDepthSize = depth;
mStencilSize = stencil;
}
/*
* This EGL config specification is used to specify rendering. We use a
* minimum size of 4 bits for red/green/blue, but perform actual matching
* in chooseConfig() below.
*/
private static int EGL_OPENGL_ES2_BIT = 4;
private static int[] s_configAttribs2 = { EGL10.EGL_RED_SIZE, 4,
EGL10.EGL_GREEN_SIZE, 4, EGL10.EGL_BLUE_SIZE, 4,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE };
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
/*
* Get the number of minimally matching EGL configurations
*/
int[] num_config = new int[1];
egl.eglChooseConfig(display, s_configAttribs2, null, 0, num_config);
int numConfigs = num_config[0];
if (numConfigs <= 0) {
throw new IllegalArgumentException("No configs match configSpec");
}
Search WWH ::




Custom Search