Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kvinther

Registering glut functions.

This topic is 5335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Initializing glut, I would normaly write something like: void display() { ... } glutDisplayFunc(display); But, what if I want to place the display function within an object? For example I could put it into a class called Scene, thus writing: Scene scene; glutDisplayFunc(scene.display); Trying this gives me the following error: error C2664: 'glutDisplayFunc' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)' What am I doing wrong? Kristian [edited by - kvinther on January 12, 2004 6:12:19 AM]

Share this post


Link to post
Share on other sites
Advertisement
(1) Is the type of the ''display'' member correct? (not a problem if ''display'' is actually a *method* of scene - but you might be trying to store a function pointer as part of scene''s data - in which case you''d need to match up your types.)

(2) If display is a method of scene, is it static? Scraping together some stuff I''ve heard in recent discussion here, it will need to be. The reason is simply this: if you could point to a non-static method of scene, and then pass that pointer to somewhere... when the recipient tries to dereference the pointer, it doesn''t know where to get ''this'' from (since the pointer doesn''t remember anything about the initial ''scene'' instance). Thus the whole process is impossible.

Share this post


Link to post
Share on other sites
Excellent!

That solved the problem. I guess I should have thought about the problem a little longer, instead of just sobbing over compiler errors...

Thank you.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!