need help

Hay,guys! I would appreciate any of you if can give me some comments about the following question.

I write a class for circles as following;
class glCircle
{
public:
glCircle(GLint x=0,GLint y=0,GLint r=50);
void setColor(GLfloat r=1.0,GLfloat g=0, GLfloat b=0);
void plot(void);

private:
GLint xCenter;
GLint yCenter;
GLint radius;
void setPixel(GLint xCoord,GLint yCoord);
void midpoint();
void plotPoints(screenPt circPt);
};

and plot function like this,

void glCircle::plot(void)
{
//Clear display window
glClear(GL_COLOR_BUFFER_BIT);

//activate the antialias
glEnable(GL_POINT_SMOOTH);

//declare the identifiers
GLuint regCircle;

//get an identifier for the circle routine
regCircle=glGenLists(1);
glNewList(regCircle,GL_COMPILE);
	midpoint();
glEndList();

//Call lists here
glCallList(regCircle);

//Process all OpenGl routines as quickly as possible
glFlush();

}

Now I want to call this plot in main function as follow,
glCircle circle;
glutDisplayFunc(circle.plot);

when I compile using VC++, the following error occurs,

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.

Did any of you have the situation before?

Thanks in anticipation.

the problem seems to be that you want to use a class member function. to avoid this, try:

glCircle   circle;

void plot_circle() {
 circle.plot();}

...

main() {

...

glutDisplayFunc(plot_circle);
}

by the way, usually you don’t clear the color buffer in a class member function. if you have two circles and plot them both the buffer will be cleared twice. a better way would look like

glCircle  circles[3];

void plot_circles(){

 glClear();

 for(int i = 0; i < 3; i ++)
   circles[i].plot();

 glFlush();}

about display lists: it doesn’t make so much sense to call a display list right after you’ve created it. usually you create a list ONCE at program start (assuming that your model geometry does not change) and then call it in the plot() function.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.