Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Problem with ProjMatrix

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 IceBreaker23   Members   

618
Like
0Likes
Like

Posted 30 December 2012 - 05:17 AM

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:

@Override
    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:

@Override
    public void onDrawFrame(GL10 unused) {

        // Draw background color
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
        
        
        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);
        
        Square.getInstance().draw(mVPMatrix);
    }

 

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);

 

 

Attached Thumbnails

  • orthoproblem.PNG


#2 Brother Bob   Moderators   

10276
Like
1Likes
Like

Posted 30 December 2012 - 05:26 AM

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






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.