I started working on ImageTargets example and using OpenGL 1.1 I am rendering rectangular planes on the scene. And I want to get these rectangles' screen coordinates, so that I can check if they are overlapping or not.
My method to do this on a regular java - gles code is : get modelview matrix, get projection matrix, get viewport and using gluProject, project the 3D opengl coordinates into 2D screen coordinates. However, I am coding on NDK right now and it doesn't support GLU. Then I decided to use QCAR functions.
I changed my method to this: Get Camera Calibration from QCAR::CameraDevice, get pose from current trackable object, and project a 3D point using projectPoint function into camera coordinates. I know that I need to convert camera coordinates into screen coordinates too... Am I on the right track? :confused:
This path led me to another problem. I wanted to check to see if I'm doing right or wrong by rendering the 2D coordinates using orthographic projection on the scene. I tried to do some basic point rendering using orthographic projection, but couldn't see anything on the screen :( Here is the part where I try to do this ( inside renderFrame method of ImageTargets.cpp after I render the rectangles in 3D ):
glPushMatrix(); glMatrixMode(GL_PROJECTION); glOrthof(0, screenWidth, 0, screenHeight, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPointSize(10.0); glColor4f(0.0, 1.0, 0.0, 1.0); glTranslatef(100, 100, 0); glVertexPointer(2, GL_FLOAT, 0, (const GLvoid*) &tmpPoint); glDrawArrays(GL_POINTS, 0, 1); glPopMatrix();
How can I render 2D on top of the Vuforia rendering pipeline? The answer can be useful for implementing HUD for any Vuforia app.
Any help would be appreciated, thanks