title: Drawing 2D on a GLSurfaceView
body: <p>I am attempting to draw a 2D square on a GLSurfaceView in 2D mode. I can draw the object in 3D mode and have tested that the square is out in 3D space. I then try to configure the matrix for 2d drawing and when I attempt to draw my object nothing appears.</p>
  
  <p>My GLSurfaceView instance implements GLSurfaceView.Renderer. </p>
  
  <p>I've broken the setup into two functions:</p>
  
  <pre><code>private void prepare3Ddrawing(GL10 gl)
  {
      gl.glLoadIdentity();
      gl.glViewport(0, 0, getWidth(), getHeight());
      gl.glDisable(GL10.GL_DITHER);
      gl.glEnable(GL10.GL_DEPTH_TEST);
      gl.glEnable(GL10.GL_CULL_FACE);
      gl.glMatrixMode(GL10.GL_PROJECTION);
      gl.glLoadIdentity();
      GLU.gluPerspective(gl, 45.0f, (float)getWidth()/(float)getHeight(),0.1f,100.0f);    
  }
  private void prepare2Ddrawing(GL10 gl)
  {
      gl.glDisable(GL10.GL_CULL_FACE);
      gl.glDisable(GL10.GL_DEPTH_TEST);
      gl.glMatrixMode(GL10.GL_PROJECTION);
      gl.glLoadIdentity();
      GLU.gluOrtho2D(gl,0,getWidth(), 0, getHeight());
      gl.glScalef(1, -1, 1);
      gl.glTranslatef(0, -getHeight(), 0);
      gl.glMatrixMode(GL10.GL_MODELVIEW);
  }
  </code></pre>
  
  <p>And here is my draw method...</p>
  
  <pre><code>public void onDrawFrame(GL10 gl)
  {
      gl.glClear(GL10.GL_DEPTH_BUFFER_BIT|GL10.GL_COLOR_BUFFER_BIT);  
      prepare3Ddrawing(gl);
  
      camera.draw(gl);
      go2d.draw(gl);
  
      prepare2Ddrawing(gl);
      go2d.draw(gl);
  
  }
  </code></pre>
  
  <p>and finally, my go2d object is an instance of an object I created called GameObject2d.  It's draw method looks like this...</p>
  
  <pre><code>@Override
  public void draw(GL10 gl)
  {
      super.draw(gl);
  
      gl.glEnable(GL10.GL_TEXTURE_2D);
      gl.glEnable(GL10.GL_ALPHA_TEST);
      gl.glAlphaFunc(GL10.GL_GREATER, 0.0f);
      gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
      gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,textureBuffer);
      gl.glBindTexture(GL10.GL_TEXTURE_2D, textureID);
  
      gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
      gl.glEnable(GL10.GL_BLEND);
  
  
      gl.glFrontFace(GL10.GL_CW);
      //gl.glEnable(GL10.GL_CULL_FACE);
      gl.glCullFace(GL10.GL_BACK);
      gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
      gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
  
      gl.glDrawElements(GL10.GL_TRIANGLES, 6, GL10.GL_UNSIGNED_SHORT, indexBuffer);
      gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
      gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
      gl.glDisable(GL10.GL_CULL_FACE);
      gl.glDisable(GL10.GL_ALPHA_TEST);
      gl.glDisable(GL10.GL_TEXTURE_2D);   
  }
  </code></pre>
  
  <p>Does anyone have any ideas? Again, I am still able to see the 3D rendered version of the go2D object, but I do not see the 2D version.</p>
  
  <p>Thanks.</p>