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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:31:25+00:00 2026-05-18T20:31:25+00:00

I have made an openGL camera class that uses lazy evaluation to provide the

  • 0

I have made an openGL camera class that uses lazy evaluation to provide the final projection or model-view-projection matrices through getter functions. The user provides the various camera parameters throughout the life of the instance (FOV, position, etc. ), but rather than have the projection matrix and/or MVP matrix recalculated every time a parameter is changed, a ‘changed’ flag is set (i.e. the old cached matrix is now invalid). Whenever the user then requests the updated final matrix, it is recalculated, the result cached, and a const reference returned.

Everything sounds fine until I call my:

const QMatrix4x4& oE_GLCamera::getModelViewProjection() const;

function from a const oE_GLCamera instance… I use const references everywhere in my app to extract camera data from CAD viewports without changing the camera, but my getter function performs lazy evaluation on member variables if they are invalid – therefore breaking const-correctness.

Is there a language feature or design paradigm I’m unaware of to help with this? Or is lazy evaluation fundamentally incompatible with const-correctness? I am aware of const_cast<>, I have never used it myself but have a read few things about it which boil down to: If you have you use it, you have already gone wrong somewhere. Or will it be my saviour?

Any advice will be greatfully received,
Cam

  • 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-18T20:31:26+00:00Added an answer on May 18, 2026 at 8:31 pm

    Is there a language feature or design paradigm I’m unaware of to help with this?

    Perhaps, mutable ?

    A member of a class that is marked as mutable is always non-const even if it is accessed via a reference or pointer to the owning class which is a const reference or a pointer to const.

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

Sidebar

Related Questions

I have made an openGL camera class that uses lazy evaluation to provide the
I have made a window with an NSOpenGLView that I am rendering openGL content
i have made a small opengl program using the d programming language. what i
I have made a debugger for the websites i develop that i simply include
I have made a background that needs to cover the whole page. I know
I have made a program with vb.net and I want that program to run
I am new to OpenGL programming.I have made a rotating cube with different images
I have to implement VBOs in a very old OpenGL program made in Broldand
I have an OpenGL ES scene which is made up of about 20 objects.
I have a very simple openGL program in C++. I have made a Sphere

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.