I tried to create my method for generating parallel projection matrix:

- Code: Select all
`/**`

* Generates and returns parallel projection matrix.

* @param left - left surface position,

* @param right - right surface position,

* @param bottom - bottom surface position,

* @param top - top surface position,

* @param near - distance to near clipping plane,

* @param far - distance to far clipping plane.

* @return 4x4 parallel projection matrix.

*/

public static final float[] parallelProjection(

float left, float right, float bottom, float top, float near, float far) {

// Calculate essential matrix elements.

float x1y1 = 2.0f / (right - left);

float x2y2 = 2.0f / (top - bottom);

float x3y3 = -2.0f / (far - near);

float x4y1 = - (right + left) / (right - left);

float x4y2 = - (top + bottom) / (top - bottom);

float x4y3 = - (far + near) / (far - near);

// 4x4 projection matrix.

return new float[] {

x1y1, 0.0f, 0.0f, x4y1,

0.0f, x2y2, 0.0f, x4y2,

0.0f, 0.0f, x3y3, x4y3,

0.0f, 0.0f, 0.0f, 1.0f,

};

}

The problem is, that instead of square I get a deformed line.

Here' my rendering code:

- Code: Select all
`// Set up 2D projection.`

gl.glMatrixMode(GL10.GL_PROJECTION);

//gl.glOrthof(.0f, GameRenderer.width, GameRenderer.height, .0f, 0.0f, 1.0f);

gl.glMultMatrixf(Matrix3D.parallelProjection(.0f, GameRenderer.width, GameRenderer.height, .0f, 0.0f, 1.0f), 0);

If I uncomment the Ortho method and comment mine, everything works fine.

Any idea what might be wrong?