开发者

Having problems with using glut display

I am trying to use Glut in C++, but I am having issues when I try to put my display function within the Renderer class.

The error i have is: error C2227: left of '->display' must point to class/struct/union/generic type

So far I have the following :

class Renderer
{
public:
   Renderer *gRenderer;
   ...
}

int Renderer::start(Renderer r)
{
...
setRenderer(r);
glutDisplayFunc(&Renderer::staticDisplay);
...
}

void Renderer::setRenderer(Renderer r){
 *gRenderer = r;
}

void Renderer::staticDisplay(){
 gRenderer->display();
}

void Renderer::display()
{
... show stuff
}

I开发者_StackOverflow中文版 am not sure what I am doing wrong :(

Thanks for all the help!


If staticDisplay is a static function (as the name suggests), you can't access gRenderer, which is a member variable, from it. You need an instance of the class to do that, while static methods have none.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜