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.

Hi,

when using OpenGL ES 2.0, you cannot use the following lines:

glGetDoublev(GL_MODELVIEW_MATRIX, ModelViewMat);

glGetDoublev(GL_PROJECTION_MATRIX, ProjMat);

glGetIntegerv(GL_VIEWPORT, Viewport);

First reason is that glGetDoublev is not supported, second reason is that GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX and GL_VIEWPORT do not exist in OpenGL ES 2.0.

If you want to use those functions, you will have to switch to OpenGL ES 1.1 (instead of 2.0); to do that, you can open the android.mk file in the jni directory of your project, and change this variable to true:

USE_OPENGL_ES_1_1 := true

On the other hand, you can also keep using OpenGL ES 2.0, in this case you don't need to call glGetDouble / glGetInteger, as you already have the modelview and projection matrices in you application code (check otherwise the sample code in ImageTargets.cpp), and the viewport as well.