I want to have a virtual dpad in an Android game so that when you touch the forwards button the camera moves forwards and back/left/and right do the same(But for their respective direction). I am able to draw textured cubes to signify the floor but now I am stuck at drawing my virtual dpad. My attempt that is the wrong way to do this is in my draw function to have a canvas(How I would normally draw a 2d object) and the opengl call.
@Override
public void onDrawFrame(GL10 gl) {
// TODO Auto-generated method stub
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
Canvas c = new Canvas();
c.drawBitmap(bitmap, 0, 0, new Paint());
gl.glLoadIdentity();
for(int i =0;i<91;i++)
{
myfloortiles[i].draw(gl);
}
}
Bitmap is a png image that is set to an actual value.
How would you draw a 2d bitmap in the foreground to work as a heads up display or button? What should I search for?
After you draw your 3D-scene you need to change to an Orthographic projection (
glOrthoif fixed-function pipeline) and reset your matrix stack (glLoadIdentity( ), again if fixed-function).By doing this, your 3D-scene is drawn properly, and then your 2D/Ortho HUD/GUI is drawn on top of it.
glOrtho
glLoadIdentity