السلام عليكــم ورحمـة الله وبركاتــه ،،
حاولت ارسم دائرة عن طريق التناظر
لكن صار فيه مشكلة في استدعاء دالة و انا نسيت شوي c++
فأتمنى تصححون كودي
رسالة الخطأ:
error C2664: 'glutDisplayFunc' : cannot convert parameter 1 from 'void' to 'void (__cdecl *)(void)'
#include <glut.h>
class screenPt
{
private:
GLint x,y;
public:
screenPt()
{
x=y=0;
}
void setCoords(GLint xCoordValue,GLint yCoordValue)
{
x=xCoordValue;
y=yCoordValue;
}
GLint getx()const
{
return x;
}
GLint gety()const
{
return y;
}
void incrementx()
{
x++;
}
void decrementy()
{
y--;
}
void setPixel(GLint xCoord,GLint yCoord)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
glVertex2i(xCoord,yCoord);
glEnd();
}
void Init()
{
glClearColor(1,1,1,1);
glColor3f(1,0,0);
glPointSize(2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-200,200,-250,250);
}
void circleMidpoint(GLint xc,GLint yc,GLint radius)
{
screenPt circPt;
GLint p=1-radius;
circPt.setCoords(0,radius);
//circlePlotPoints(GLint ,GLint,screenPt);
circlePlotPoints(xc,yc,circPt);
while (circPt.getx() < circPt.gety())
{
circPt.incrementx();
if (p<0)
p+=2*circPt.getx() +1;
else{
circPt.decrementy();
p+=2*circPt.getx() - circPt.gety()+1;
}
circlePlotPoints(xc,yc,circPt);
}
}
void circlePlotPoints(GLint xc,GLint yc, screenPt circPt)
{
setPixel (xc + circPt.getx() , yc + circPt.gety());
setPixel (xc - circPt.getx() , yc + circPt.gety());
setPixel (xc + circPt.getx() , yc - circPt.gety());
setPixel (xc - circPt.getx() , yc - circPt.gety());
setPixel (xc + circPt.gety() , yc - circPt.getx());
setPixel (xc - circPt.gety() , yc + circPt.getx());
setPixel (xc + circPt.gety() , yc - circPt.getx());
setPixel (xc - circPt.gety() , yc - circPt.getx());
}
};
int main(int argc,char** argv)
{
screenPt sp;
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400,400);
glutInitWindowPosition(200,200);
glutCreateWindow("My first OpenGl program");
sp.Init();
glutDisplayFunc(sp.circleMidpoint('y','t','y'));
glFlush();
glutMainLoop();
return 0;
}