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.
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);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindTexture(GL_TEXTURE_2D,0);
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
}
this is setPerspective :
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