I’m noob in OpenGL and trying to implement a program as When a user clicks in the widow area a pixel should be drawn at that position. But the pixel is not drawn. If any body can help me then it would be great…Thank you
Here is my code.
#include <iostream>
#include <GL/glut.h>
int a,b;
using namespace std;
void display()
{
glPointSize(20);
glBegin(GL_POINTS);
glColor3f(1.0,1.0,1.0);
glVertex2f(a,b);
glEnd();
glFlush();
}
void mouse(int button,int state,int x,int y)
{
switch(button)
{
case GLUT_LEFT_BUTTON:
a=x;
b=y;
glutPostRedisplay();
return;
case GLUT_RIGHT_BUTTON:
return;
default:
break;
}
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(400,300);
glutInitWindowPosition(200,200);
glutCreateWindow("My First OpenGL");
glutMouseFunc(mouse);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}