title: Android OpenGL hello world
body: <p>By following the short tutorial <a href="http://developer.android.com/training/graphics/opengl/environment.html#glsurfaceview" rel="nofollow">http://developer.android.com/training/graphics/opengl/environment.html#glsurfaceview</a>.  My example does not work in the emulator.  I wish to have a basic opengl example working in the emulator but it continues to be a problem and even the instructions by the developers fail to work.</p>
  
  <p>I have three classes:</p>
  
  <pre><code>package com.test.flushrummy;
  
  import android.opengl.GLSurfaceView;
  import android.os.Bundle;
  import android.app.Activity;
  
  public class MainActivity extends Activity {
  
      private GLSurfaceView m_GlView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          m_GlView = new MyGLSurfaceView(this);
          setContentView(m_GlView);
      }
  
  }
  
  package com.test.flushrummy;
  
  import javax.microedition.khronos.opengles.GL10;
  import android.opengl.GLES20;
  import android.opengl.GLSurfaceView.Renderer;
  
  public class MyGLRenderer implements Renderer {
  
      public void onDrawFrame(GL10 unused) {
          // Redraw background color
          GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
      }
  
      public void onSurfaceChanged(GL10 unused, int width, int height) {
          GLES20.glViewport(0, 0, width, height);
      }
  
      @Override
      public void onSurfaceCreated(GL10 gl,
              javax.microedition.khronos.egl.EGLConfig config) {
          // TODO Auto-generated method stub
          GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
      }
  
  }
  
  package com.test.flushrummy;
  
  import android.content.Context;
  import android.opengl.GLSurfaceView;
  
  class MyGLSurfaceView extends GLSurfaceView {
  
      public MyGLSurfaceView(Context context) {
          super(context);
          setRenderer(new MyGLRenderer());
  
          // Create an OpenGL ES 2.0 context
          setEGLContextClientVersion(2);
  
          // Render the view only when there is a change in the drawing data
          setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
      }
  
  }
  </code></pre>
  
  <p>I have  in my manifest.  </p>
  
  <pre><code>&lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /&gt;
  </code></pre>
  
  <p>project.properties:</p>
  
  <pre><code>target=android-19
  </code></pre>
  
  <p>"use gpu host" is snabled in avd.</p>