我正在实现一个名为FilesWorkFlow的类:
//this function is called by other functions of the class to set openGL data type
//based on GDAL data type
void FilesWorkFlow::setOpenGLDataType(void)
{
switch (eType)
{
case GDT_Byte:
type = GL_UNSIGNED_BYTE;
break;
case GDT_UInt16:
type = GL_UNSIGNED_SHORT;
break;
case GDT_Int16:
type = GL_SHORT;
break;
case GDT_UInt32:
type = GL_UNSIGNED_INT;
break;
case GDT_Int32:
type = GL_INT;
}
}
//this function is called by other functions of the class to draw scene
void FilesWorkFlow::RenderScene(void)
{
GLint iWidth = (GLint)RasterXSize;
GLint iHeight = (GLint)RasterYSize;
setOpenGLDataType();
glClear(GL_COLOR_BUFFER_BIT);
glRasterPos2i(0,0);
glDrawPixels(iWidth,iHeight,format,type,pImage);
glFlush();
}
//this function is called by other functions of the class to setup the
//rendering state
void FilesWorkFlow::SetupRC(void)
{
glClearColor(0.0f,0.0f,0.0f,1.0f);
}
void FilesWorkFlow::Show(void)
{
int argc = 1;
char **argv;
argv[0] = "OPENGL";
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE);
glutCreateWindow("Image");
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop();
}
这是将在MFC应用程序中使用的类的一部分,用于渲染创建窗口,在其上呈现tiff图像,但在行glutDisplayFunc(RenderScene)
我得到错误
argument of type "void (FilesWorkFlow::*)()" is incompatible with parameter of type "void (__cdecl *)()"
即使将代码编写为glutDisplayFunc((_cdecl)RenderScene)
也无济于事。如何解决此问题并在将在MFC应用程序中使用的类中实现此任务?
答案 0 :(得分:1)
首先要解决这个误解: GLUT 不是是OpenGL的一部分,你不必使用它!
您不能混用GLUT和MFC。 GLUT和MFC都做同样的事情:
你不能在同一个程序中有两个不同的东西尝试做同样的事情。
无论如何,您收到的错误会告诉您以下内容:
或者换句话说:你尝试做的事情是不可能的(没有建立一些包装或使用一些肮脏的黑客)。