Log in or register to post comments

Draw 2D component

March 19, 2012 - 1:19am #1

Hi all,

With vuforia sdk Imagetargets example I am trying to draw a 2d component (Buttons, Label etc...).

Following is my approach and it worked for me in other opengl projects

1 First I save the current opengl state

2 create orthographic

3 draw 2d stuff

4 Then restore the opengl state

following is code and it didn't wok with ImageTargets example and it did work for other opengl android projects

// modify ImageTargets example
public void onDrawFrame(GL10 gl)
{
// draw the camera texture and do tracking
renderFrame();

// 2D start
gl.glDisable(gl.GL_LIGHTING);
gl.glDisable(gl.GL_FOG);
gl.glDisable(gl.GL_TEXTURE_2D);
gl.glDisable(gl.GL_DEPTH_TEST);
gl.glDisable(gl.GL_CULL_FACE);

gl.glViewport(0, 0, w, h);

 gl.glMatrixMode(gl.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();

gl.glOrthof(0, w, 0, h, -1, 1) ;
gl.glMatrixMode(gl.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();

// draw 2D here

//restore
gl.glMatrixMode(gl.GL_PROJECTION);
gl.glPopMatrix();

gl.glMatrixMode(gl.GL_MODELVIEW);
gl.glPopMatrix();
}

But this never draw any thing

Could you please advice?

Re: Draw 2D component

March 19, 2012 - 9:15pm #2

I was able to merge the BasicGLSurfaceView Android sample with Vuforia. Note that uses OpenGL ES 2.0 instead of 1.1. For your code, be sure to set the USE_OPENGL_ES_1_1 flag in the Android.mk file to true.

If you include the 2D rendering code I'd be happy to test further.

- Kim

Log in or register to post comments