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

  • Home
  • SEARCH
  • 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 8547791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:20:40+00:00 2026-06-11T13:20:40+00:00

My Application is a Graphics Application written in C++ using OpenGL. I need to

  • 0

My Application is a Graphics Application written in C++ using OpenGL. I need to use some libraries like GLFW, GLEW and GLM. But you don’t need to know about these libraries or OpenGL to answer this question. The point is that all these libraries are written in C so there is no object orientation.

I ran into troubles because of that multiple times. For example currently I have to pass a function, espacially for the resize event of my window, as parameter to GLEW. It expects a static function because there are no classes in C. And reveals the problem that I can’t modify any class member in this function. (And I couldn’t handle it to provide a global pointer to that class…)

Because of the fact that I want to stay object orientated I had to restructurize my code several times recently. And I am sad of it now.

So are there any approaches or guidelines for handling such object orientated projects using libraries without object orientated support?

  • 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-11T13:20:41+00:00Added an answer on June 11, 2026 at 1:20 pm

    Many times the C library lets you pass in a context pointer/reference constant, generally of type void * or const void *. Your callback is then passed this argument. This is to let you thread state through to the callback. You can use this to pass through the object you wish to use.

    I’ve seen this done by declaring a static member function, making that the target of the callback, and then bouncing to a proper member function therefrom, something like:

    /*static*/ int Class::_callback(void *ctx, int callback_arg) {
        Class *me = (Class *)ctx;
        return me->callback(callback_arg);
    }
    
    int Class::callback(int callback_arg) {
        return this->fCount;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a small Python application where I use PyGame for displaying some
In my graphics application, there is canvas area that has some graph. The scrollbars
I have a simple graphics application which draws some stuff on the screen. Before,
Just tried some small graphics application of mine on Windows 7, and I'm getting
I'm working on a graphics application that is using virtual classes fairly extensively. It
I'm working on a 3d globe application written in java using java3d for the
I am currently programming a graphics application with OpenGL and the Windows API in
I want to know if I can develop graphics application with DirectX using C#?
How to move graphics rectangle using mouse in c or c++. This is some
I am making application and i am using HD graphics. my application is good

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.