I need to run at least 25 windows concurrently with each window rendering a different game state. I am storing all the 25 game states in the array of type GameState allGameStates[25].

For each of the window, i am currently doing this to register a different draw callback for each of the 25 windows.


The issue here is that glutDisplayFunc requires a parameter of type function ptr, and i cannot pass in a member function ptr.(i am using GLUT which is in C)

It is not feasible to make the Draw function static as i require the Draw function to render differently accordingly to the other variables in the game state object.

How do i overcome this problem?

  • \$\begingroup\$ Does this game need to be playable? That sounds like a recipe for disaster. If you enable VSYNC you'll basically only get 2 FPS in your application in the best case ;) \$\endgroup\$ Mar 23, 2015 at 6:56
  • \$\begingroup\$ Luckily for my case ,only 1 window is to be shown to the user at any point in time so vsync is not required.Thanks for the comment though. \$\endgroup\$ Mar 23, 2015 at 7:42

1 Answer 1


According to the documentation for glutDisplayFunc():

Before the callback, the current window is set to the window needing to be redisplayed

This means that inside the display callback, you can call glutGetWindow() to find out which window is being drawn to.

This means that you can use a static member function as the display callback; just have that static member function figure out which window is being drawn to, and map from that window to its particular game state object instance, and then call a non-static member function on that instance.

  • \$\begingroup\$ You Sir , is a Genius \$\endgroup\$ Mar 22, 2015 at 10:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .