How to drag a 2D object/shape with mouse?

  • kmrox09
    Likes 0

    Problem Description

    I am trying to make a small project in which there is a part where i have to drag a shape from place to another but if i release the mouse it will go back to its original position or if I click on a random position the object will move to that place until the mouse is released. I am able to get the coordinates of the mouse click, but I am having difficulty in dragging/moving the shape to that coordinate.

    I am using Opengl and GLFW.

    thx in advance.

  • Sonar Systems admin
    Likes 0

    What do you have so far?

  • kmrox09
    Likes 0

    So far i have made a shape (a circle) and I am trying to move it mouse. I have created a function  -  void mousebuttoncallback(GLFWwindow* window, int button, int action, int mods) which gives the location of the position where the mouse is clicked on screen and then i call this function using glfwSetMouseButtonCallback(window, mousebuttoncallback) . problem is I am not able to use these coordindates


  • Sonar Systems admin
    Likes 0

    Why can you not use these coordinates?

Login to reply