Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- #include<stdlib.h>
- #include<stdio.h>
- #include<iostream>
- int ww=600,wh=400;
- int first=0;
- void drawLine()
- {
- }
- void display()
- { glClearColor(0.0,0.0,0.0,1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glFlush();
- }
- void mouse(int btn,int state,int x,int y)
- {
- if(btn == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
- {
- exit(1);
- }
- else if(btn == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
- {
- printf("%d %d\n", x,y);
- glBegin(GL_POINTS);
- glVertex2f(x,wh-y);
- glEnd();
- glFlush();
- }
- }
- void reshape()
- {
- glViewport(0,0,ww,wh);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(0.0,(GLdouble)ww,0.0,(GLdouble)wh);
- glMatrixMode(GL_MODELVIEW);
- }
- int main(int argc,char** argv)
- {
- glutInit(&argc,argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(ww,wh);
- glutCreateWindow("Draw Line With Mouse Click");
- glutDisplayFunc(display);
- reshape();
- glutMouseFunc(mouse);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement