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 8465163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:57:48+00:00 2026-06-10T14:57:48+00:00

I recently thought it would be a good idea to switch from the old

  • 0

I recently thought it would be a good idea to switch from the old (deprecated) functionality that OpenGL provides, such as matrix operations and the fixed function pipeline.

I am using GLM as my matrix library to simplify things a bit. The problem is that it may have caused more problems than it simplified…

Perspective projections worked fine with my shaders and setup, but when I tried to switch to orthogonal, everything broke down. My points and simple quads wouldn’t display. When I used the old OpenGL matrices, things started working again.

I narrowed it all down to the projection matrix. Here is how I called it:

glm::mat4 projMat = glm::ortho( 0, 400, 0, 400, -1, 1 );

I compared that to the one supplied by opengl once this is called”

glOrtho( 0, 400, 0, 400, -1, 1 );

The only differences are the [0][0] element and [1][1] element (which, as far as I know, be equal to “2/width” and “2/height”, respectively). From the OpenGL matrix, the values were exactly that! On the glm matrix, though, the values were 0.

Once I manually switched the values from the glm matrix after I called glm::ortho, everything was working again!

So my question: is the glm::ortho() function really broken, or am I just using it wrong?

  • 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-06-10T14:57:50+00:00Added an answer on June 10, 2026 at 2:57 pm

    It doesn’t appear that it should be broken from the source code (v 0.9.3.4)

    template <typename valType> 
    GLM_FUNC_QUALIFIER detail::tmat4x4<valType> ortho
    (
        valType const & left, 
        valType const & right, 
        valType const & bottom, 
        valType const & top, 
        valType const & zNear, 
        valType const & zFar
    )
    {
        detail::tmat4x4<valType> Result(1);
        Result[0][0] = valType(2) / (right - left);
        Result[1][1] = valType(2) / (top - bottom);
        Result[2][2] = - valType(2) / (zFar - zNear);
        Result[3][0] = - (right + left) / (right - left);
        Result[3][1] = - (top + bottom) / (top - bottom);
        Result[3][2] = - (zFar + zNear) / (zFar - zNear);
        return Result;
    }
    

    My only thought is that this template might be creating a matrix of integers (as you’ve passed all ints to the function), and thus doing integer division instead of floating point. Can you try appending .f to all your parameters?

    glm::mat4 projMat = glm::ortho( 0.f, 400.f, 0.f, 400.f, -1.f, 1.f );

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

Sidebar

Related Questions

I recently started programming JavaScript and thought everything would be good... Well today I
Recently, I was studying about throwing our own exceptions and I thought that maybe
I have recently started studying about threads. I thought of starting from the beginning
I'm new to programming and thought Python would be a good language to learn.
Recently I posted a answer to a question that I thought was quite an
UPDATE: I recently learned from this question that in the entire discussion below, I
I have an applet, which I was writing in Java. Recently, I thought that
I have been recently looking into NServiceBus, as I thought messaging would be a
I have recently learned that you can use a neat switch statement with fallthrough
I was recently brought a challenge from a friend. Thought I'd share it here

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.