Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6825591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:03:06+00:00 2026-05-26T22:03:06+00:00

I am trying to understand what the following code does: glm::mat4 Projection = glm::perspective(35.0f,

  • 0

I am trying to understand what the following code does:

glm::mat4 Projection = glm::perspective(35.0f, 1.0f, 0.1f, 100.0f);

Does it create a projection matrix? Clips off anything that is not in the user’s view?
I wasn’t able to find anything on the API page, and the only thing I could find in the pdf on their website was this:

gluPerspective:

glm::mat4 perspective(float fovy, float aspect, float zNear,
float zFar);
glm::dmat4 perspective(
double fovy, double aspect, double zNear,
double zFar);
From GLM_GTC_matrix_transform extension: <glm/gtc/matrix_transform.hpp>

But it doesn’t explain the parameters. Maybe I missed something.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:03:06+00:00Added an answer on May 26, 2026 at 10:03 pm

    It creates a projection matrix, i.e. the matrix that describes the set of linear equations that transforms vectors from eye space into clip space. Matrices really are not black magic. In the case of OpenGL they happen to be a 4-by-4 arrangement of numbers:

    X_x Y_x Z_x T_x
    X_y Y_y Z_y T_y
    X_z Y_z Z_z T_z
    X_w Y_w Z_w W_w
    

    You can multply a 4-vector by a 4×4 matrix:

    v' = M * v
    
    v'_x = M_xx * v_x + M_yx * v_y + M_zx * v_z + M_tx * v_w
    v'_y = M_xy * v_x + M_yy * v_y + M_zy * v_z + M_ty * v_w
    v'_z = M_xz * v_x + M_yz * v_y + M_zz * v_z + M_tz * v_w
    v'_w = M_xw * v_x + M_yw * v_y + M_zw * v_z + M_tw * v_w
    

    After reaching clip space (i.e. after the projection step), the primitives are clipped. The vertices resulting from the clipping are then undergoing the perspective divide, i.e.

    v'_x = v_x / v_w
    v'_y = v_y / v_w
    v'_z = v_z / v_w
    ( v_w = 1 = v_w / v_w )
    

    And that’s it. There’s really nothing more going on in all those transformation steps than ordinary matrix-vector multiplication.

    Now the cool thing about this is, that matrices can be used to describe the relative alignment of a coordinate system within another coordinate system. What the perspective transform does is, that it let’s the vertices z-values “slip” into their projected w-values as well. And by the perspective divide a non-unity w will cause “distortion” of the vertex coordinates. Vertices with small z will be divided by a small w, thus their coordinates “blow” up, whereas vertices with large z will be “squeezed”, which is what’s causing the perspective effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just trying to understand delegates using the following code. public class delegatesEx
I am trying to understand why the following snippet of code is giving a
I am trying to understand how Boost memory mapped files work. The following code
I have the following assembly code snippet I am trying to understand. It is
I'm trying to understand what const_iterator means. I have the following example code: void
I've been trying to understand Samy Kamkar's evercookie code and he does at least
I am trying to understand virtual memory paging. I have the following code snippet
I'm trying to understand what's going on in the following code. When object-a is
I m trying to understand what the following does. ^([^=]+)(?:(?:\\=)(.+))?$ Any ideas? This is
I'm trying to understand some C++ code which has the following class syntax: class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.