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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:01:55+00:00 2026-05-28T18:01:55+00:00

I am looking over this piece of code, and am having trouble with the

  • 0

I am looking over this piece of code, and am having trouble with the syntax:

struct Instance
{
    typedef glm::vec3(*OffsetFunc)(float);

    OffsetFunc CalcOffset;

    glm::mat4 ConstructMatrix(float fElapsedTime)
    {
        glm::mat4 theMat(1.0f);

        theMat[3] = glm::vec4(CalcOffset(fElapsedTime), 1.0f);

        return theMat;
    }
};

It is C++ code, related to OpenGL, but my question is not about OpenGL. The glm::vec3, vec4, mat4 are just vectors of dimension 3 and 4, and mat4 is a 4×4 square matrix. The glm library has overloaded operators so lines like:

theMat[3] = glm::vec4(CalcOffset(fElapsedTime), 1.0f);

work as you might expect, filling up the 4th column of theMat with a 4-d vector that is comprised of 1.0f and that cast or typedef or function call, I’m not exactly sure what that is, and that is my question.

What does typedef glm::vec3(*OffsetFunc)(float); and CalcOffset(fElapsedTime) mean?

I tried reading here: http://en.wikipedia.org/wiki/Typedef#Using_typedef_with_type_casts , but that explanation doesn’t really seem to make sense to me.

Edit: I know how typedefs work when it simply involves providing another alias for a type.

Edit 2: I thought that this might be doing something with a pointer to a function because it kind of looks like a pointer and has float in there like its a function parameter type, and it seems like this is the case, but I am still not sure what this kind of code precisely does.

  • 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-28T18:01:57+00:00Added an answer on May 28, 2026 at 6:01 pm
    typedef glm::vec3(*OffsetFunc)(float);
    

    defines OffsetFunc to be an alias for the type glm::vec3(*)(float), i.e. pointer to function taking float and returning glm::vec3.

    CalcOffset(fElapsedTime)
    

    calls the function pointed to by CalcOffset on fElapsedTime.

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

Sidebar

Related Questions

I have been looking over this code for the past hour, I cant see
I am looking over some code someone else did and I see this: if
I was looking over this code to calculate math.sqrt in Java. Why did they
I'm looking over some previous developers code and I come across this line: location.href
I'm looking over the code for Python's multiprocessing module, and it contains this line:
Looking over code examples in my lecture slides, I notice this: c = head();
I have been looking all over for this. I have two seperate prpt files
I have been looking over the internet for a while about this, but it
I've been looking for this extra div for over 5 hours and am at
I was looking over the code for qunit. My question is why would you

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.