d3alek / Texample2

Rendering Text in OpenGL ES 2 on Android
Other
83 stars 33 forks source link

Origin in left top flips text #9

Open bruenor41 opened 6 years ago

bruenor41 commented 6 years ago

Hi,

I changed content of OnSurfaceChanged function with code which sets origin to left top corner. But after that is text flipped. Please can someone help to fix it?

public void onSurfaceChanged(GL10 unused, int width, int height) { 
    GLES20.glViewport(0, 0, width, height);

    for(int i=0;i<16;i++)
    {
        mtrxProjection[i] = 0.0f;
        mtrxView[i] = 0.0f;
        mtrxProjectionAndView[i] = 0.0f;
    }

    Matrix.orthoM(mtrxProjection, 0, 0, width, height, 0, -1, 1);
    Matrix.setLookAtM(mtrxView, 0,
            0f, 0f, 1f,
            0f, 0f, 0f,
            0f, 1.0f, 0.0f);
    Matrix.multiplyMM(mtrxProjectionAndView, 0,
            mtrxProjection, 0,
            mtrxView, 0);
}

// Our matrices
private final float[] mtrxProjection = new float[16];
private final float[] mtrxView = new float[16];
private final float[] mtrxProjectionAndView = new float[16]; 

Many thanks