Git Product home page Git Product logo

Comments (5)

wangjiangchuan avatar wangjiangchuan commented on May 27, 2024

Then I use the perspective function to create a perspective matrix, but still there is nothing.
Matrix4f projection = Matrix4f.perspective(45f, 800f/600f, 0.1f, 100.0f);

from lwjgl3-tutorial.

SilverTiger avatar SilverTiger commented on May 27, 2024

In OpenGL you have a right-handed coordinate system. Basically if you want to see the object, you have to translate the z-Position in the reverse direction.

Does it work, if you use negative z-Coordinates like this?

vertices.put(-0.6f).put(-0.4f).put(-2.0f).put(1f).put(0f).put(0f);
vertices.put(0.6f).put(-0.4f).put(-2.0f).put(0f).put(1f).put(0f);
vertices.put(0f).put(0.6f).put(-2.0f).put(0f).put(0f).put(1f);

from lwjgl3-tutorial.

wangjiangchuan avatar wangjiangchuan commented on May 27, 2024

no it doesn't works. Finally, I find the reason. For I didn't use any projection matrix in it. It may acquiesce in using orthogonal projection not the perspective projection. So the z axis only contains value from -1 to 1. When you use the perspective projection, you will find you can change the z to -2.

from lwjgl3-tutorial.

SilverTiger avatar SilverTiger commented on May 27, 2024

With an orthogonal projection you can have any desired z values. When creating the projection matrix you have the Function Matrix4f.orthographic(left, right, bottom, top, near, far).
In the tutorial I'm using -1.0f and 1.0f for the values near and far but you can also change them to -2.0f and 2.0f or any other value.

from lwjgl3-tutorial.

wangjiangchuan avatar wangjiangchuan commented on May 27, 2024

Yes, this is right. When using the orthogonal projection, we can change the variation of z axis to any values.

from lwjgl3-tutorial.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.