Search in sources :

Example 1 with EGLConfigChooser

use of android.opengl.GLSurfaceView.EGLConfigChooser in project libgdx by libgdx.

the class AndroidGraphics method createGLSurfaceView.

protected View createGLSurfaceView(AndroidApplicationBase application, final ResolutionStrategy resolutionStrategy) {
    if (!checkGL20())
        throw new GdxRuntimeException("Libgdx requires OpenGL ES 2.0");
    EGLConfigChooser configChooser = getEglConfigChooser();
    int sdkVersion = android.os.Build.VERSION.SDK_INT;
    if (sdkVersion <= 10 && config.useGLSurfaceView20API18) {
        GLSurfaceView20API18 view = new GLSurfaceView20API18(application.getContext(), resolutionStrategy);
        if (configChooser != null)
            view.setEGLConfigChooser(configChooser);
        else
            view.setEGLConfigChooser(config.r, config.g, config.b, config.a, config.depth, config.stencil);
        view.setRenderer(this);
        return view;
    } else {
        GLSurfaceView20 view = new GLSurfaceView20(application.getContext(), resolutionStrategy, config.useGL30 ? 3 : 2);
        if (configChooser != null)
            view.setEGLConfigChooser(configChooser);
        else
            view.setEGLConfigChooser(config.r, config.g, config.b, config.a, config.depth, config.stencil);
        view.setRenderer(this);
        return view;
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) GLSurfaceView20(com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20) GLSurfaceView20API18(com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20API18) EGLConfigChooser(android.opengl.GLSurfaceView.EGLConfigChooser)

Example 2 with EGLConfigChooser

use of android.opengl.GLSurfaceView.EGLConfigChooser in project libgdx by libgdx.

the class AndroidGraphicsLiveWallpaper method createGLSurfaceView.

// <- specific for live wallpapers
// Grabbed from AndroidGraphics superclass and modified to override
// getHolder in created GLSurfaceView and GLSurfaceViewAPI18 instances
@Override
protected View createGLSurfaceView(AndroidApplicationBase application, final ResolutionStrategy resolutionStrategy) {
    if (!checkGL20())
        throw new GdxRuntimeException("Libgdx requires OpenGL ES 2.0");
    EGLConfigChooser configChooser = getEglConfigChooser();
    int sdkVersion = android.os.Build.VERSION.SDK_INT;
    if (sdkVersion <= 10 && config.useGLSurfaceView20API18) {
        GLSurfaceView20API18 view = new GLSurfaceView20API18(application.getContext(), resolutionStrategy) {

            @Override
            public SurfaceHolder getHolder() {
                return getSurfaceHolder();
            }

            // This method is invoked via reflection by AndroidLiveWallpaper.onDestroy() 
            public void onDestroy() {
                // calls GLSurfaceView.mGLThread.requestExitAndWait();
                onDetachedFromWindow();
            }
        };
        if (configChooser != null)
            view.setEGLConfigChooser(configChooser);
        else
            view.setEGLConfigChooser(config.r, config.g, config.b, config.a, config.depth, config.stencil);
        view.setRenderer(this);
        return view;
    } else {
        GLSurfaceView20 view = new GLSurfaceView20(application.getContext(), resolutionStrategy) {

            @Override
            public SurfaceHolder getHolder() {
                return getSurfaceHolder();
            }

            // This method is invoked via reflection by AndroidLiveWallpaper.onDestroy() 
            public void onDestroy() {
                // calls GLSurfaceView.mGLThread.requestExitAndWait();
                onDetachedFromWindow();
            }
        };
        if (configChooser != null)
            view.setEGLConfigChooser(configChooser);
        else
            view.setEGLConfigChooser(config.r, config.g, config.b, config.a, config.depth, config.stencil);
        view.setRenderer(this);
        return view;
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) GLSurfaceView20(com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20) GLSurfaceView20API18(com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20API18) EGLConfigChooser(android.opengl.GLSurfaceView.EGLConfigChooser)

Aggregations

EGLConfigChooser (android.opengl.GLSurfaceView.EGLConfigChooser)2 GLSurfaceView20 (com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20)2 GLSurfaceView20API18 (com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20API18)2 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2