Search in sources :

Example 11 with GLSurfaceView

use of android.opengl.GLSurfaceView in project android_frameworks_base by DirtyUnicorns.

the class DemoPresentation method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Be sure to call the super class.
    super.onCreate(savedInstanceState);
    // Get the resources for the context of the presentation.
    // Notice that we are getting the resources from the context of the presentation.
    Resources r = getContext().getResources();
    // Inflate the layout.
    setContentView(R.layout.presentation_content);
    // Set up the surface view for visual interest.
    mRenderer = new CubeRenderer(false);
    mSurfaceView = (GLSurfaceView) findViewById(R.id.surface_view);
    mSurfaceView.setRenderer(mRenderer);
    // Add a button.
    mExplodeButton = (Button) findViewById(R.id.explode_button);
    mExplodeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mRenderer.explode();
        }
    });
}
Also used : Resources(android.content.res.Resources) GLSurfaceView(android.opengl.GLSurfaceView) View(android.view.View)

Example 12 with GLSurfaceView

use of android.opengl.GLSurfaceView in project android_frameworks_base by DirtyUnicorns.

the class GLDepthTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mGLSurfaceView = new GLSurfaceView(this);
    if (detectOpenGLES20()) {
        // Tell the surface view we want to create an OpenGL ES
        // 2.0-compatible
        // context, and set an OpenGL ES 2.0-compatible renderer.
        mGLSurfaceView.setEGLContextClientVersion(2);
        mRenderer = new GLES20TriangleRenderer(this);
        mGLSurfaceView.setRenderer(mRenderer);
    } else {
        throw new IllegalStateException("Can't find OGL ES2.0 context");
    }
    setContentView(mGLSurfaceView);
}
Also used : GLSurfaceView(android.opengl.GLSurfaceView)

Example 13 with GLSurfaceView

use of android.opengl.GLSurfaceView in project jmonkeyengine by jMonkeyEngine.

the class OGLESContext method createView.

/**
     * <code>createView</code> creates the GLSurfaceView that the renderer will
     * draw to. <p> The result GLSurfaceView will receive input events and
     * forward them to the Application. Any rendering will be done into the
     * GLSurfaceView. Only one GLSurfaceView can be created at this time. The
     * given configType specifies how to determine the display configuration.
     *
     * @return GLSurfaceView The newly created view
     */
public GLSurfaceView createView(Context context) {
    // NOTE: We assume all ICS devices have OpenGL ES 2.0.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // below 4.0, check OpenGL ES 2.0 support.
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        if (info.reqGlEsVersion < 0x20000) {
            throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device");
        }
    } else if (Build.VERSION.SDK_INT < 9) {
        throw new UnsupportedOperationException("jME3 requires Android 2.3 or later");
    }
    // Start to set up the view
    GLSurfaceView view = new GLSurfaceView(context);
    logger.log(Level.INFO, "Android Build Version: {0}", Build.VERSION.SDK_INT);
    if (androidInput == null) {
        if (Build.VERSION.SDK_INT >= 14) {
            androidInput = new AndroidInputHandler14();
        } else if (Build.VERSION.SDK_INT >= 9) {
            androidInput = new AndroidInputHandler();
        }
    }
    androidInput.setView(view);
    androidInput.loadSettings(settings);
    // setEGLContextClientVersion must be set before calling setRenderer
    // this means it cannot be set in AndroidConfigChooser (too late)
    view.setEGLContextClientVersion(2);
    view.setFocusableInTouchMode(true);
    view.setFocusable(true);
    // setFormat must be set before AndroidConfigChooser is called by the surfaceview.
    // if setFormat is called after ConfigChooser is called, then execution
    // stops at the setFormat call without a crash.
    // We look at the user setting for alpha bits and set the surfaceview
    // PixelFormat to either Opaque, Transparent, or Translucent.
    // ConfigChooser will do it's best to honor the alpha requested by the user
    // For best rendering performance, use Opaque (alpha bits = 0).
    int curAlphaBits = settings.getAlphaBits();
    logger.log(Level.FINE, "curAlphaBits: {0}", curAlphaBits);
    if (curAlphaBits >= 8) {
        logger.log(Level.FINE, "Pixel Format: TRANSLUCENT");
        view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        view.setZOrderOnTop(true);
    } else if (curAlphaBits >= 1) {
        logger.log(Level.FINE, "Pixel Format: TRANSPARENT");
        view.getHolder().setFormat(PixelFormat.TRANSPARENT);
    } else {
        logger.log(Level.FINE, "Pixel Format: OPAQUE");
        view.getHolder().setFormat(PixelFormat.OPAQUE);
    }
    AndroidConfigChooser configChooser = new AndroidConfigChooser(settings);
    view.setEGLConfigChooser(configChooser);
    view.setRenderer(this);
    // reloading all the OpenGL objects.
    if (Build.VERSION.SDK_INT >= 11) {
        view.setPreserveEGLContextOnPause(true);
    }
    return view;
}
Also used : AndroidInputHandler(com.jme3.input.android.AndroidInputHandler) AndroidInputHandler14(com.jme3.input.android.AndroidInputHandler14) ActivityManager(android.app.ActivityManager) GLSurfaceView(android.opengl.GLSurfaceView) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Example 14 with GLSurfaceView

use of android.opengl.GLSurfaceView in project PD-classes by watabou.

the class Game method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BitmapCache.context = TextureCache.context = instance = this;
    DisplayMetrics m = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(m);
    density = m.density;
    try {
        version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        version = "???";
    }
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    view = new GLSurfaceView(this);
    view.setEGLContextClientVersion(2);
    view.setEGLConfigChooser(false);
    view.setRenderer(this);
    view.setOnTouchListener(this);
    setContentView(view);
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) DisplayMetrics(android.util.DisplayMetrics) GLSurfaceView(android.opengl.GLSurfaceView)

Example 15 with GLSurfaceView

use of android.opengl.GLSurfaceView in project android_frameworks_base by crdroidandroid.

the class DemoPresentation method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Be sure to call the super class.
    super.onCreate(savedInstanceState);
    // Get the resources for the context of the presentation.
    // Notice that we are getting the resources from the context of the presentation.
    Resources r = getContext().getResources();
    // Inflate the layout.
    setContentView(R.layout.presentation_content);
    // Set up the surface view for visual interest.
    mRenderer = new CubeRenderer(false);
    mSurfaceView = (GLSurfaceView) findViewById(R.id.surface_view);
    mSurfaceView.setRenderer(mRenderer);
    // Add a button.
    mExplodeButton = (Button) findViewById(R.id.explode_button);
    mExplodeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mRenderer.explode();
        }
    });
}
Also used : Resources(android.content.res.Resources) GLSurfaceView(android.opengl.GLSurfaceView) View(android.view.View)

Aggregations

GLSurfaceView (android.opengl.GLSurfaceView)24 View (android.view.View)7 Resources (android.content.res.Resources)4 IOException (java.io.IOException)3 Bitmap (android.graphics.Bitmap)2 Camera (android.hardware.Camera)2 Parameters (android.hardware.Camera.Parameters)2 Uri (android.net.Uri)2 AbsListView (android.widget.AbsListView)2 SeekBar (android.widget.SeekBar)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2 ActivityManager (android.app.ActivityManager)1 Intent (android.content.Intent)1 ConfigurationInfo (android.content.pm.ConfigurationInfo)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Renderer (android.opengl.GLSurfaceView.Renderer)1 DisplayMetrics (android.util.DisplayMetrics)1 FrameLayout (android.widget.FrameLayout)1