Jump to content
  • Advertisement
Sign in to follow this  
stevenie

OpenGL Math Behind the Perspective View and ModelView

This topic is 2807 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

Hello everyone, I'm trying to practice the math behind the matrix magic behind opengl. I want to draw a cube by using the matrix multiplication instead of glFrustum and glrotation.

Here's what the code look like when drawing the right side of the cube.

Please assume we can only draw a line in 2D.

http://snipt.net/stevenie/opengl?key=6785e6b975db5d7cf223101ef1bc2f6f

However the right face doesn't look perspective at all. I can only see one straight line.
Please help.

Thanks!

Steven

Share this post


Link to post
Share on other sites
Advertisement
You forgot the perspective division. And for that matter, what's going on with the W values of your vertices?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
You forgot the perspective division. And for that matter, what's going on with the W values of your vertices?


Thanks for your reply. Now i can see the 3D effect if i divided x and y by z. However, they are inverted. Do you need to divided them by -z? Thanks!

Steven

Share this post


Link to post
Share on other sites
Quote:
Original post by stevenie
Thanks for your reply. Now i can see the 3D effect if i divided x and y by z. However, they are inverted. Do you need to divided them by -z? Thanks!

That's not how the perspective division works. What are you using as a reference for this?

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!