in Education by
Now i am writing a MFC program with opengl in it. And when i tried to combine opengl with MFC, i come across some problems: First, I defined a class named:CSCommTestDlg, and defined a member function with codes as follows: void CSCommTestDlg::OpglMain(int argc, char* argv[]) { glutDisplayFunc(displayCude); } displayCube is also a member function of class CSCommTestDlg, and glutDisplayFunc is a global funcion(an opengl function), the function declarations of glutDisplayFunc is as follows: GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void)); Yes, just as you can see, the parameter of glutDisplayFunc is a function pointer, and i made it point to a member function displayCube, which seems illegal, and i got an error like that: error C2664: 'glutDisplayFunc' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)' None of the functions with this name in scope match the target type seems that i can't point to a member function in a global function, but i need it. How to fix it ? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
glutDisplayFunc takes a global function, so, simply put, you can't make it take a member function pointer. One solution would be to mark displayCube as static, but that kinda ruins the point of having a class in the first place. Another option would be to declare a global function as the glut display callback, and then inside that function, call the displayCube member function of your CSCommTestDlg object - if you can get hold of a global pointer to it.

Related questions

0 votes
    Now i am writing a MFC program with opengl in it. And when i tried to combine opengl with MFC, i ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    Differentiate between ordinary function and member functions in c++. Explain with an example Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    What is the isa member in Objective-C?...
asked Nov 10, 2020 in Technology by JackTerrance
+1 vote
    What is the default value of local and global variables in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    look at the following function header for a member function void circle::Radius[ ] what is the name of the ... function a member of Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Static member function cannot invalid non static member function Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    This smells buggy, but probably, someone can explain it: The following script doesn't work, the output is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    In a function, How to create and use a global variable? How can I use it in other functions? Is it compulsory ... it in a function? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    The boiling point of water at 750mmHg is 99.63∘C . How muCHM sucrose is to be added to 500g of water suCHM that it boils at 100∘C . Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
0 votes
    I want to click on group add button of Facebook, but I have not found it possible using an xpath. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am studying Artificial Intelligence as a module in my Computer Games Programming course and one of my tasks ... appreciated, thanks. Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I have a Member class: public class Member { // key public Guid UserId { get; set; } // some ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 15, 2022 in Education by JackTerrance
0 votes
    Point out the wrong statement. (a) Each universal function takes array inputs and produces array outputs (b) Broadcasting ... input arguments are ndarrays (d) All of the mentioned...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    I am importing a project from C to Java which involves a lot of floating-point arithmetic. Are there ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
...