OpenGL ES 2.0 X-Axis upside down?

I started drawing my Quad, but when I started playing with the vertices, I noticed that the X-coordinates were inverted. Here is an image to show what I mean:

enter image description here

Here are my peaks - the indices and texture coordinates, which I really don't need to show.

static final int COORDS_PER_VERTEX = 3; static float positionCoords[] = { -0.5f, 0.5f, 0.0f, // top left -0.5f, -0.5f, 0.0f, // bottom left 0.5f, -0.5f, 0.0f, // bottom right 0.5f, 0.5f, 0.0f }; // top right static final int COORDS_PER_TEXTURE = 2; static float textureCoords[] = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, }; private final short indices[] = { 0, 1, 2 }; 

And here I change the Projection and View Matrices.

 public void onSurfaceChanged(GL10 naGl, int width, int height) { Log.d(TAG, "GL Surface Changed - Setting Up View"); GLES20.glViewport(0, 0, width, height); float ratio = (float) width / height; Matrix.frustumM(ProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7); Matrix.setLookAtM(ViewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f); } 

Why would this be reversed. I also thought that my camera could be behind the object, so in the three-dimensional space on the left it will be positive if I am behind the object.

+4
source share
1 answer

You really look at the object from the back.

Your lookAt function puts the eye at (0,0, -3) and the lookAt point (0, 0, 0). By default, the negative z axis points to the screen, but you look at it from the opposite direction (in the direction of the positive z axis).

You should look at (0,0,3), looking to the side (0,0,0) to get the expected idea.

You can find this chapter of the Red Book informational information.

+6
source

All Articles