The following is code to draw a rectangle, but I am getting an error in glutdisplayFunc(). How can I fix it?
#include <iostream>
#include <glut.h>
using namespace std;
class GUI
{
public:
int W,H;
GUI()
{
W = 800;
H = 600;
glClearColor(0, 0, 0, 0);
gluOrtho2D(-W, W, -H, H);
glMatrixMode(GL_PROJECTION);
}
void display()
{
glBegin(GL_POLYGON);
glVertex2d(-500, 300);
glVertex2d(500, 300);
glVertex2d(500, -300);
glVertex2d(-500, -300);
glEnd();
glFlush();
}
};
int main(int argv, char **argc)
{
GUI ob;
glutInit(&argv, argc);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowSize(ob.W, ob.H);
glutInitWindowPosition(100, 100);
glutCreateWindow("Queen Problem");
glutDisplayFunc(ob.display); //Error
glutMainLoop();
return 0;
}
I am using Visual Studio 2010. I created some of the programs in OpenGL, but without any clases. This is my first experience of using classes with OpenGL.
The error is:
Error 1 error C3867: 'GUI::display': function call missing argument list; use '&GUI::display' to create a pointer to member.
I tried to use &GUI::display
, but it also resulted in the error.