I dont know what goes wrong in this code...
Help me here
I simply want to save the initial and final positions after dragging the mouse...
#include"iostream"
#include<glut.h>
class point1
{
public:
point1()
{
x=0;
y=0;
}
int x;
int y;
}p[2];
int flag=0;
void processMouse(int button, int state, int x, int y);
void actmot(int x, int y);
int main()
{
//glClear(GL_COLOR_BUFFER_BIT || GL_DEPTH_BUFFER_BIT);
glutMouseFunc(processMouse);
glutMotionFunc(actmot);
glutMainLoop();
return 0;
}
void processMouse(int button, int state, int x, int y)
{
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
if(flag!=1)
{
flag=1;
p[0].x=x;
p[0].y=y;
}
}
else if(button==GLUT_LEFT_BUTTON && state==GLUT_UP)
{
if (flag==1)
{
p[1].x=x;
p[1].y=y;
flag=0;
}
}
}
void actmot(int x,int y)
{
}