I have function to draw eclipse :
void drawEclipse(GLfloat x, GLfloat y, GLfloat xrad,GLfloat yrad)
When I'm calling glutDisplayFunc(drawEclipse(10,10,3,3));
It has compilation error:
error: invalid use of void expression
How can I pass parameter to function inside glutDisplayFunc
?
And this eclipse drawing function is being called dynamically, with a mouse click.
My updated code:
void mouseClicks(int button, int state, int x, int y) {
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
printf("%s -- %d -- %d\n", "clicked",x,y);
//Way 1
glutDisplayFunc[&]() { drawEclipse(x,y,5,5); };
//Way 2
auto display = [x,y]() { return drawFilledelipse(x,y,3,3); };
glutDisplayFunc(display);
}
}
...
int main(){
...
glutMouseFunc(mouseClicks);
...