This commit is contained in:
Hannes Janetzek
2014-01-21 02:53:06 +01:00
parent 764a62986e
commit f9d262d6a7
2 changed files with 7 additions and 96 deletions

View File

@@ -6,20 +6,11 @@ import javax.microedition.khronos.egl.EGLDisplay;
import android.opengl.GLSurfaceView;
/**
*
*
*/
public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
/**
*
*/
public static int stencilSize = 0;
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
mValue = new int[1];
int[] val = new int[1];
// Try to find a normal multisample configuration first.
int[] configSpec = {
@@ -33,13 +24,12 @@ public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
EGL10.EGL_STENCIL_SIZE, 8,
EGL10.EGL_NONE };
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
if (!egl.eglChooseConfig(display, configSpec, null, 0, val)) {
throw new IllegalArgumentException("eglChooseConfig failed");
}
int numConfigs = mValue[0];
int numConfigs = val[0];
if (numConfigs <= 0) {
stencilSize = 4;
configSpec = new int[] {
// EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE };
@@ -52,21 +42,19 @@ public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
EGL10.EGL_STENCIL_SIZE, 8,
EGL10.EGL_NONE };
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
if (!egl.eglChooseConfig(display, configSpec, null, 0, val)) {
throw new IllegalArgumentException("eglChooseConfig failed");
}
numConfigs = mValue[0];
numConfigs = val[0];
if (numConfigs <= 0) {
throw new IllegalArgumentException("No configs match configSpec");
}
} else {
stencilSize = 8;
}
// Get all matching configurations.
EGLConfig[] configs = new EGLConfig[numConfigs];
if (!egl.eglChooseConfig(display, configSpec, configs, numConfigs, mValue)) {
if (!egl.eglChooseConfig(display, configSpec, configs, numConfigs, val)) {
throw new IllegalArgumentException("data eglChooseConfig failed");
}
@@ -75,83 +63,10 @@ public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
// configurations are considered to be "better" and returned first.
// You need to explicitly filter the data returned by eglChooseConfig!
// for (int i = 0; i < configs.length; ++i) {
// log.info(configs[i]));
// }
// int index = -1;
// for (int i = 0; i < configs.length; ++i) {
// // if (findConfigAttrib(egl, display, configs[i], EGL10.EGL_RED_SIZE, 0) == 8
// // &&
// // findConfigAttrib(egl, display, configs[i], EGL10.EGL_ALPHA_SIZE, 0) == 0) {
// // index = i;
// // break;
// // }
// // else
// if (findConfigAttrib(egl, display, configs[i], EGL10.EGL_RED_SIZE, 0) == 8
// &&
// findConfigAttrib(egl, display, configs[i], EGL10.EGL_ALPHA_SIZE, 0) == 0
// &&
// findConfigAttrib(egl, display, configs[i], EGL10.EGL_DEPTH_SIZE, 0) == 24) {
// index = i;
// break;
// }
// }
// if (index == -1) {
// log.warn(using first");
// index = 0;
// }
int index = 0;
//log.info(configs[index]);
EGLConfig config = configs.length > 0 ? configs[index] : null;
EGLConfig config = configs.length > 0 ? configs[0] : null;
if (config == null) {
throw new IllegalArgumentException("No config chosen");
}
return config;
}
// from quake2android
private String printConfig(EGL10 egl, EGLDisplay display,
EGLConfig config) {
int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
/*
* EGL_CONFIG_CAVEAT value #define EGL_NONE 0x3038 #define
* EGL_SLOW_CONFIG 0x3050 #define
* EGL_NON_CONFORMANT_CONFIG 0x3051
*/
return String.format("EGLConfig rgba=%d%d%d%d depth=%d stencil=%d",
Integer.valueOf(r), Integer.valueOf(g),
Integer.valueOf(b), Integer.valueOf(a), Integer.valueOf(d),
Integer.valueOf(s))
+ " native="
+ findConfigAttrib(egl, display, config, EGL10.EGL_NATIVE_RENDERABLE, 0)
+ " buffer="
+ findConfigAttrib(egl, display, config, EGL10.EGL_BUFFER_SIZE, 0)
+ String.format(
" caveat=0x%04x",
Integer.valueOf(findConfigAttrib(egl, display, config,
EGL10.EGL_CONFIG_CAVEAT, 0)));
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config,
int attribute, int defaultValue) {
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
return mValue[0];
}
return defaultValue;
}
private int[] mValue;
}

View File

@@ -24,7 +24,6 @@ import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.map.Map;
import org.oscim.map.Viewport;
import org.oscim.renderer.GLState;
import org.oscim.renderer.GridRenderer;
import org.oscim.renderer.MapRenderer;
import org.oscim.theme.InternalRenderTheme;
@@ -105,9 +104,6 @@ public abstract class GdxMap implements ApplicationListener {
* also render frame FIXME (does nothing atm)
*/
private void redrawMapInternal(boolean forceRedraw) {
// FIXME needed?
GLState.blend(false);
GLState.test(false, false);
updateLayers();