"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

GLUProject get 2d from 3d coordinates

Hello,

 

I am trying to convert 3d coordinates into 2d in renderframe method using following code.

 

if (vbCounter>0)        {            // Render frame around button            glUseProgram(vbShaderProgramID);            glVertexAttribPointer(vbVertexHandle, 3, GL_FLOAT, GL_FALSE, 0,                (const GLvoid*) &vbVertices[0]);            glEnableVertexAttribArray(vbVertexHandle);            glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,                (GLfloat*)&modelViewProjection.data[0] );            // We multiply by 8 because that's the number of vertices per button            // The reason is that GL_LINES considers only pairs. So some vertices            // must be repeated.            glDrawArrays(GL_LINES, 0, target->getNumVirtualButtons()*8);             SampleUtils::checkGlError("VirtualButtons drawButton");            glDisableVertexAttribArray(vbVertexHandle);            ///////////////////////////////Light Rectangle /////////////////////////////////////////////////////            glGetDoublev(GL_MODELVIEW_MATRIX, ModelViewMat);            glGetDoublev(GL_PROJECTION_MATRIX, ProjMat);            glGetIntegerv(GL_VIEWPORT, Viewport);                  gluProject(-97.68f, -28.f, 0.f, modelViewMatrix.data,projectionMatrix.data,Viewport,& blY_Lite,& blX_Lite,&winZ);                  gluProject(-15.93.f, -28.f, 0.f, modelViewMatrix.data,projectionMatrix.data,Viewport,& brY_Lite,& brX_Lite,&winZ);                  gluProject(-97.68f, -50.52.f, 0.f, modelViewMatrix.data,projectionMatrix.data,Viewport,& tlY_Lite,& tlX_Lite,&winZ);                  gluProject(-15.93f, -50.52f, 0.f, modelViewMatrix.data,projectionMatrix.data,Viewport,& trY_Lite,& trX_Lite,&winZ);}

 

Now NDK does not build and give errors that it does not recognize GL_VIEWPORT, GL_PROJECTION_MATRIX and GL_MODELVIEW_MATRIX constants. Does anybody knows solution to it? It says opengl es2/gl2 at top. Does anybody knows how to get these constants.

UsmanKurd

Thu, 10/11/2012 - 07:03

The link you posted i.e. https://ar.qualcomm.at/content/error-projecting-point-screen shows a method that takes camerapoint and returns screen point. How I will fetch camerapoint using opengl es 2 or 1

AlessandroB

Thu, 10/11/2012 - 09:24

The point I've used is just an example ;

for instance in your case you will the points that appear in the code you copy-pasted in this post originally: