Click here to Skip to main content
15,909,205 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: why like this? Pin
Michael Dunn10-Dec-01 16:41
sitebuilderMichael Dunn10-Dec-01 16:41 
QuestionHow can I make address of a member-function (__cdecl *)??? Pin
10-Dec-01 9:39
suss10-Dec-01 9:39 
AnswerRe: How can I make address of a member-function (__cdecl *)??? Pin
Joaquín M López Muñoz10-Dec-01 10:05
Joaquín M López Muñoz10-Dec-01 10:05 
AnswerHere's how Pin
Ravi Bhavnani10-Dec-01 10:13
professionalRavi Bhavnani10-Dec-01 10:13 
AnswerRe: How can I make address of a member-function (__cdecl *)??? Pin
Ravi Bhavnani10-Dec-01 10:15
professionalRavi Bhavnani10-Dec-01 10:15 
AnswerRe: How can I make address of a member-function (__cdecl *)??? Pin
Fazlul Kabir10-Dec-01 10:40
Fazlul Kabir10-Dec-01 10:40 
AnswerSpecification of the problem. Pin
10-Dec-01 12:15
suss10-Dec-01 12:15 
GeneralRe: Specification of the problem. Pin
Joaquín M López Muñoz10-Dec-01 22:33
Joaquín M López Muñoz10-Dec-01 22:33 
Well, the standard solution is to provide a pointer to the class when you register your function (this is usually called a callback parameter): this callback parameter can be used by your static callback function to transfer the function call to the actual class responsible for doing the job.
Unfortunately, GLUT seems not to provide any mechanism to store any callback parameter on callback registration. But do not abandon any hope, there's still a way (if a little convoluted) to retrieve the class, via glutGetWindow(). The idea is having a map associating windows IDs with classes, and having the static method dispatch to the appropriate class using this map. This is s little piece of pseudocode that describes the process using the glutMouseFunc callback:
class MyGlutWindow{
private:
  static std::map<int,MyGlutWindow*> ID2MyGlutWindow;
public:
  MyGlutWindow(){
    ...
    ID2MyGlutWindow[glutGetWindow()]=this; // associates current GLUT window ID to myself
  }
  static void __cdecl glutMouseFuncCallback(int button,int state,int x, int y){
   ID2MyGlutWindow[glutGetWindow()]->doGlutMouseFuncCallback(button,state,x,y);
  }
  void doGlutMouseFuncCallback(int button,int state,int x, int y){
    ...
  }
};
There are some details missing (cleanup when windows are destroyed, for instance), but the basics are here, I hope you get the idea and find it useful.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: Specification of the problem. Pin
11-Dec-01 6:15
suss11-Dec-01 6:15 
GeneralRe: char* byte* DLL-VC++ and Delphi Please help ! Pin
Joaquín M López Muñoz10-Dec-01 9:37
Joaquín M López Muñoz10-Dec-01 9:37 
QuestionUSB support for VC++???? Pin
Johnny_8910-Dec-01 8:23
Johnny_8910-Dec-01 8:23 
QuestionCMenu::CheckMenuItem(...)??? Pin
Rickard Andersson2010-Dec-01 7:38
Rickard Andersson2010-Dec-01 7:38 
AnswerRe: CMenu::CheckMenuItem(...)??? Pin
Christian Graus10-Dec-01 11:12
protectorChristian Graus10-Dec-01 11:12 
AnswerRe: CMenu::CheckMenuItem(...)??? Pin
Ravi Bhavnani11-Dec-01 5:18
professionalRavi Bhavnani11-Dec-01 5:18 
Generalchar* byte* DLL-VC++ and Delphi Please help ! Pin
mimi10-Dec-01 7:36
mimi10-Dec-01 7:36 
GeneralCreate a CBitmap object, draw in it, save in (.bmp file) Pin
Remi Morin10-Dec-01 7:34
Remi Morin10-Dec-01 7:34 
GeneralRe: Create a CBitmap object, draw in it, save in (.bmp file) Pin
Bill Wilson10-Dec-01 7:42
Bill Wilson10-Dec-01 7:42 
QuestionHow to insert characters in a CRichEditViewed application? Pin
davilism10-Dec-01 7:33
davilism10-Dec-01 7:33 
QuestionHow to move the caret in CRichEditViewed application? Pin
davilism10-Dec-01 7:32
davilism10-Dec-01 7:32 
AnswerRe: How to move the caret in CRichEditViewed application? Pin
squizz10-Dec-01 10:05
squizz10-Dec-01 10:05 
GeneralRe: How to move the caret in CRichEditViewed application? Pin
davilism10-Dec-01 17:19
davilism10-Dec-01 17:19 
GeneralCan't use RTTI Pin
Chen Jiadong10-Dec-01 7:05
Chen Jiadong10-Dec-01 7:05 
GeneralRe: Can't use RTTI Pin
Ernest Laurentin10-Dec-01 8:04
Ernest Laurentin10-Dec-01 8:04 
GeneralRe: Can't use RTTI Pin
Chen Jiadong10-Dec-01 19:10
Chen Jiadong10-Dec-01 19:10 
GeneralRe: Can't use RTTI Pin
Christian Graus10-Dec-01 10:00
protectorChristian Graus10-Dec-01 10:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.