
I want to draw a triangle like this
I think I have to change these part of my codes
glBegin(GL_LINES);
glVertex2f(point[0][0], point[0][1]);
glVertex2f(point[1][0], point[1][1]);
glEnd();
and my mouse button down codes are like this
if (action == GLFW_PRESS && button == GLFW_MOUSE_BUTTON_LEFT)
{
inputMode = InputMode::DRAGGING; // Dragging starts
point[0][0] = xw; point[0][1] = yw; // Start point
point[1][0] = xw; point[1][1] = yw; // End point
}
How I have to do?
You need some global variables for 3 points and one index that is telling you which point you actually edit ...
the render change to
now I do not code in GLFW but you need to change the onclick events to something like:
This is my standard editation code I use in my editors for more info see:
I am not sure about the
q1as I do not code in GLFW its possible you could extract the left mouse button state directly with different expression. theq0does not need to be static but in such case it should be global... Also its possible the GLFW holds such state too in which case you could extract it similarly toq1and no global or static is needed for it anymore...