Log in or register to post comments

Draw 2D button on the opengl window

December 3, 2013 - 8:16pm #1

Hi All,

Applogies if this question asked before.

I am trying to render a render 2D GUI like object on the opengl screen. (orthographic projection)

Below is my cpp code.

float *nProjMatrix = new float[16];
unsigned int screenWidth = 0;
unsigned int screenHeight = 0;

// took from https://developer.vuforia.com/forum/rendering-opengl-es/videoplayback-sample
void setOrthoMatrix(float nLeft, float nRight, float nBottom, float nTop, float nNear, float nFar, float *nProjMatrix);

// calcualte ortho matrix
setOrthoMatrix(0, screenWidth, 0, screenHeight, -1, 1, nProjMatrix);

void ActivityApplication::GLRenderFrame(JNIEnv *env, jobject obj) {
	// end of sample code
	// drawing code starts
	glViewport(0, 0, (GLsizei)screenWidth, (GLsizei)screenHeight);

	glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)nProjMatrix);

	GLfloat vVertices[] = {0.0f, 0.0f, 2.0f, 
							0.0f, -1.0f, 0.0f,
							0.0f, 1.0f, 0.0f};

	 glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, vVertices);
	 glDrawArrays(GL_TRIANGLES, 0, 3);
	 glDisableVertexAttribArray (1);
	 // drawing code ends

I cannot see anything what I am trying to render. I am not much familier with this technology.

Please help



Log in or register to post comments