voidWidgetPointView::mousePressEvent(QMouseEvent*event) { if(event->button()==Qt::LeftButton){ m_selecting=true; m_startPos=QVector2D(event->pos()); m_endPos=QVector2D(event->pos()); } } voidWidgetPointView::mouseMoveEvent(QMouseEvent*event) { if(m_selecting){ m_endPos=QVector2D(...
我也遇到过类似的问题,通过qglwidget制作一个opengl游戏,我想出的解决方案是使用正交投影来呈现划痕生成...
voidsetProjectionMatrix(); voidsetViewMatrix(); voiddrawGrid(); }; #endif// WIDGETPOINTVIEW_H widgetpointview.cpp #include"widgetpointview.h" #include<QMouseEvent> #include<QOpenGLShaderProgram> #include<QDebug> #include<cmath> WidgetPointView::WidgetPointView(QWidget*parent) :QOpenGLWidget(...