Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm starting to study 3D programming with OpenGLes, so I'm total newbie on this :p.

I wanna ask something, I tried to set Perspective on my object (rectangle face, 6 vertices).
But, after setPerspective I couldn't see my object anymore.

C++
int init(....)
{
...
  projMatrix.SetPerspective(45.0f, 0.75f, 0.001f, 100.0f);
...
}

void draw (...)
{
...
        wvpMatrix = worldMatrix * viewMatrix * projMatrix;
	glUniformMatrix4fv(myShaders.wvpMatrixLocation, 1, GL_FALSE, (const GLfloat*)wvpMatrix.m);
	//end
	glDrawArrays(GL_TRIANGLES, 0, 6);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindTexture(GL_TEXTURE_2D,0);
	eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
}


this is setPerspective :
C++
Matrix & Matrix::SetPerspective(GLfloat fovY, GLfloat aspect, GLfloat nearPlane, GLfloat farPlane)
{
	GLfloat height = 2.0f * nearPlane * tanf(fovY * 0.5f);
	GLfloat width = height * aspect;
	GLfloat n2 = 2.0f * nearPlane;
	GLfloat rcpnmf = 1.f / (nearPlane - farPlane);

	m[0][0] = n2 / width;	
	m[1][0] = 0;
	m[2][0] = 0;
	m[3][0] = 0;

	m[0][1] = 0;
	m[1][1] = n2 / height;
	m[2][1] = 0;
	m[3][1] = 0;

	m[0][2] = 0;
	m[1][2] = 0;
	m[2][2] = (farPlane + nearPlane) * rcpnmf;	
	m[3][2] = farPlane * rcpnmf * n2;

	m[0][3] = 0;
	m[1][3] = 0;
	m[2][3] = -1.f;
	m[3][3] = 0;

	return *this;
}


anyone can hep me?
thanks
Posted

You could call
C++
Matrix::GetPerspective
to get the current values and then change each one slightly to see the effect and work out what it is that you are changing and the extent of those changes that causes your object to be unseen that way.

this assumes there is such a method of course.
 
Share this answer
 
v2
Try this:
C++
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindTexture(GL_TEXTURE_2D,0);
glDrawArrays(GL_TRIANGLES, 0, 6);


You have you bind buffers before calling any draw functions.

-Saurabh
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900