Search in sources :

Example 1 with StarWarsRenderer

use of com.yalantis.starwars.render.StarWarsRenderer in project StarWars.Android by Yalantis.

the class TilesFrameLayout method initGlSurfaceView.

private void initGlSurfaceView() {
    mGLSurfaceView = new StarWarsTilesGLSurfaceView(getContext());
    mGLSurfaceView.setBackgroundColor(Color.TRANSPARENT);
    // Check if the system supports OpenGL ES 2.0.
    final ActivityManager activityManager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
    if (supportsEs2) {
        // Request an OpenGL ES 2.0 compatible context.
        mGLSurfaceView.setEGLContextClientVersion(2);
        mRenderer = new StarWarsRenderer(mGLSurfaceView, this, mAnimationDuration, mNumberOfTilesX);
        mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
        mGLSurfaceView.setRenderer(mRenderer);
        mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
        mGLSurfaceView.setZOrderOnTop(true);
    } else {
        throw new UnsupportedOperationException();
    }
}
Also used : StarWarsTilesGLSurfaceView(com.yalantis.starwars.widget.StarWarsTilesGLSurfaceView) ActivityManager(android.app.ActivityManager) StarWarsRenderer(com.yalantis.starwars.render.StarWarsRenderer) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Aggregations

ActivityManager (android.app.ActivityManager)1 ConfigurationInfo (android.content.pm.ConfigurationInfo)1 StarWarsRenderer (com.yalantis.starwars.render.StarWarsRenderer)1 StarWarsTilesGLSurfaceView (com.yalantis.starwars.widget.StarWarsTilesGLSurfaceView)1