0
$\begingroup$

I want to get the coordinates of my mouse after the left mouse button is released after being dragged in OpenGL? I am new to this and wanted to know how I can implement it.

$\endgroup$
1
  • 4
    $\begingroup$ The mouse coordinates are obtained from the operating system (or through some piece of software that gets the coordinates on your behalf) OpenGL has nothing to do it. Are you using GLFW? It has functions for obtaining the coordinates. $\endgroup$
    – pmw1234
    Commented May 7, 2022 at 10:41

1 Answer 1

0
$\begingroup$

I found this method and I am using GLUT.

void myMouse(int button, int state, int x, int y) 
{
// If left button was clicked
    if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) 
    {
        
    }
    // Event after mouse is clicked and released
    else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) 
    {
        //initialize a point and set it coordinates given to us by the function
        Point p1;
        p1.setxy(x, y);
    }
}
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.