Not precise positioning in Android (OpenGL ES 2.0)

OnDrawFrame I am calling Matrix.setLookAtM, Matrix.multiplyMM, Matrix.translateM, Matrix.scaleM a lot because I need to render different objects in 2D. I have created two objects - circle ( and line. I render many of them by changing their position, color and scale. There might be some more extra work in GLRenderer class to calculate correct position after receiving information from network. The problem is that shake effect appears as other objects moves a little bit upside and down when I’m trying to translate one object’s position by 1f each second and to lock view on it (trying to move).

Device must be running on 30 FPS.

DDMS information:

I have managed to capture the screenshots of the actual problem:

As you can see in this example only the light blue bubble with border moves with the grid. The problem is that that the orange bubble with border moves randomly up and down when I’m changing light blue bubble position. While idling nothing happens. The difference of the orange bubble position on Y axis is about 0.03f-0.05f when this happens. After this happens it moves back to it’s real position. So this happens only for a very short moment and about 5-10 times a second.

P.S. Multisampling anti-lasing is 4x, problem persists with depth size 16 and 24.

Don’t post a link to another question as a question. If you can’t be bothered to at least copy-and-paste from there, then you shouldn’t expect us to bother following that link and answering it.

I have added whole content to the thread now.

What are the translation values in the setLookAtM and translateM matrices and the scale values in the scaleM matrix? I’m interested in their magnitudes.

And are you using an orthographic projection? If not, post your near/far clip plane values and the Z value you’re using for your 2D drawing surface.

This is how I draw circles:

        float camera = -3.01f
        for (float[] cp : buffer.cp) {
	    	int colour = Float.valueOf(cp[0]).intValue()*6;

	    	int i = 0;
	       	for (int i = 0; i < cp[1]; i += 3) {
	       		Matrix.setLookAtM(mViewMatrix, 0, cp[2+i], cp[3+i], zoom, cp[2+i], cp[3+i], 0f, 0f, 1f, 0f);
		        Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
		        Matrix.scaleM(mMVPMatrix, 0, cp[4+i], cp[4+i], 1f);
		        Matrix.translateM(mMVPMatrix, 0, 0f, 0f, camera);
		        mCircle.setColor(GameUtils.colours[colour], GameUtils.colours[colour+1], GameUtils.colours[colour+2], 1f);
		        Matrix.scaleM(mMVPMatrix, 0, 0.85f, 0.85f, 1f);
		        mCircle.setColor(GameUtils.colours[colour+3], GameUtils.colours[colour+4], GameUtils.colours[colour+5], 1f);

cp[2+i] - final X coordinate
cp[3+i] - final Y coordinate
cp[4+i] - final object scale compared to zoom value

public void onSurfaceChanged(GL10 unused, int width, int height) {
        GLES20.glViewport(0, 0, width, height);
        this.width = width;
        this.height = height;
        ratio = (float) width / height;
        ratioInv = (float) Math.pow(ratio, -1);
        // This projection matrix is applied to object coordinates in the onDrawFrame() method
        Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 50);

I have tried to change Far value and set zoom variable to -10f or -20f but it didn’t helped.

temp[2] = (playerPart.getPosX()-buffer.diffX);
temp[3] = -(playerPart.getPosY()-buffer.diffY);
temp[4] = GameUtils.PLAYER_SIZE;

This is how I calculate circle position. Buffer.diffX and buffer.diffY are the main player’s coordinates.

In this case which was explained in the first message the coordinates of circles with borders were around -2f both X and Y.
I am using perspective projections but in reality I’m trying to create a 2D game. So I have no idea if that’s a good choice.

After some research I found that there were problem with Android application optimization. The delay was not related to OpenGL ES 2.0.