tags:

views:

16

answers:

1

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 am not sure what I am doing wrong :(

Thanks for all the help!

A: 

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.

casablanca