PDA

View Full Version : OpenGL-ES 2.0 problem



SimonS
01-15-2009, 10:09 AM
Hi. Iīm having problem with my simple OpenGL-ES program.

I think itīs the view or projection matrix. Hereīs what it looks like:

Projection:


mProjM.transpose();

float f = 1.0 / tan( fov / 2);

mProjM[0][0] = f/aspect; mProjM[0][1] = 0.0; mProjM[0][2] = 0.0; mProjM[0][3] = 0.0;
mProjM[1][0] = 0.0; mProjM[1][1] = f; mProjM[1][2] = 0.0; mProjM[1][3] = 0.0;
mProjM[2][0] = 0.0; mProjM[2][1] = 0.0; mProjM[2][2] = fz/(nz-fz); mProjM[2][3] = -1.0;
mProjM[3][0] = 0.0; mProjM[3][1] = 0.0; mProjM[3][2] = (nz*fz)/(nz-fz); mProjM[3][3] = 0.0;

View Matrix:

mLookV = mLookV.normalize();

mUpV = cross(mLookV, mRightV);
mUpV = mUpV.normalize();

mRightV = cross(mUpV, mLookV);
mRightV = mRightV.normalize();

float x = dot(-mCamPos, mRightV);
float y = dot(-mCamPos, mUpV);
float z = dot(-mCamPos, -mLookV);

mViewM[0][0] = mRightV.x();
mViewM[0][1] = mRightV.y();
mViewM[0][2] = mRightV.z();
mViewM[0][3] = x;

mViewM[1][0] = mUpV.x();
mViewM[1][1] = mUpV.y();
mViewM[1][2] = mUpV.z();
mViewM[1][3] = y;

mViewM[2][0] = -mLookV.x();
mViewM[2][1] = -mLookV.y();
mViewM[2][2] = -mLookV.z();
mViewM[2][3] = z;

mViewM[3][0] = 0.0f;
mViewM[3][1] = 0.0f;
mViewM[3][2] = 0.0f;
mViewM[3][3] = 1.0f;

Is this correct?

MegaJiXiang
09-14-2010, 09:11 PM
See my matrix.h and matrix.c in my engine. viewtopic.php?f=9&t=3140 (http://www.khronos.org/message_boards/viewtopic.php?f=9&t=3140)

You'll be able to make all the matrices you need.

lizy11
09-06-2011, 12:26 AM
Thank you for the provided link, a very helpful one!!! :D