Jump to content
  • Advertisement
Sign in to follow this  

Problem with ProjMatrix

This topic is 2118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there!


I am working on my own 2d sprite framework for android, but I am struggling with defining the right projection-matrix.

Please take a look at the attached screenshot...

If I use a normal Matrix.frustumM call it works as expected, but as soon as I use orthoM there´s only a line on the screen...


Here´s the code where the projectionmatrix is defined:

    public void onSurfaceChanged(GL10 unused, int width, int height) {
        // Adjust the viewport based on geometry changes,
        // such as screen rotation
        GLES20.glViewport(0, 0, width, height);
        Matrix.orthoM(mProjMatrix, 0, 0, width, 0, height, -1f, 1f);


Here the matrix is used and multiplied by the view matrix:

    public void onDrawFrame(GL10 unused) {

        // Draw background color
        Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
        // Calculate the projection and view transformation
        Matrix.multiplyMM(mVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);


Here is a part of the draw()-method where the matrix gets passed to the shader:

// Apply the projection and view transformation
        GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mVPMatrix, 0);



Share this post

Link to post
Share on other sites

You should not expect perspective and orthographic projections to give comparable results in general. They are fundamentally different projections.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!