我想画一个这样的三角形
我想我必须更改我的代码的这一部分
glBegin(GL_LINES);
glVertex2f(point[0][0], point[0][1]);
glVertex2f(point[1][0], point[1][1]);
glEnd();
我的鼠标按键代码是这样的
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
}
我要怎么做?
1条答案
按热度按时间ztigrdn81#
您需要针对3个点的一些全局变量和一个告诉您实际编辑哪个点的索引……
渲染器将更改为
现在,我不使用GLFW编写代码,但您需要将onClick事件更改为如下所示:
这是我在我的编辑器中使用的标准编辑代码。有关更多信息,请参阅:
我不确定
q1
,因为我不是用GLFW编码的,有可能你可以用不同的表达式直接提取鼠标左键的状态。q0
不需要是静态的,但在这种情况下,它应该是全局的...也有可能GLFW也具有这样的状态,在这种情况下,您可以类似于q1
来提取它,并且它不再需要全局或静态...