PDA

View Full Version : how to use glutMouseFunc



printf
31st May 2017, 03:31
i use QT and am programming for a Native program which draw figures(like triangles) and user can select one of the figures and the figures can be changed.
so i want to use glutMouseFunc, searched google and found this source.

https://www.opengl.org/archives/resources/code/samples/redbook/pickdepth.c

and i am making [QT Widget App] which use Mainwindow and my code is just this.
but it's not working.
what's the Reason?
i want to know the usage.


//maint.cpp
int main(int argc, char *argv[])
{
glutInit(&argc, argv);

QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}




//openglwidget.cpp, it use QOpenGlView of QT UI
void pickRects(int button, int state, int x, int y)
{
qDebug()<<"pickRects";
printf("pickRects\n");
}

OpenGLWidget::OpenGLWidget(QWidget *parent): QGLWidget(parent)
{
glutMouseFunc(pickRects);
}

wysota
1st June 2017, 22:24
What is not working? What would you expect your code to be doing? You don't have any GLUT windows so obviously the callback is never called.