(Help please) How to show drawing in QGLWidget on mainwindow?
I'm new to QT and OpenGL and need your help for my question. I have created a QT+OpenGL application. I have a mainwindow UI and have place a Widget inherited from QGLWidget on the mainwindow.
I have write a simple OpenGL code to show points on the screen. The function is called (I had placed a messagebox there) but the app does not display the points I pained on screen. Please help what I should do to have the points display on screen.
Here is my code in .h file.
class MyPanelOpenGL : public QGLWidget
explicit MyPanelOpenGL(QWidget *parent = 0);
void resizeGL(int width, int height);
and here is my implementation .cpp file - in which I draw points in draw()
@MyPanelOpenGL::MyPanelOpenGL(QWidget *parent) :
setFormat(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer));
void MyPanelOpenGL::resizeGL(int width, int height)
GLfloat x = GLfloat(width)/height;
glFrustum(-x, +x, -1.0, +1.0, 4.0, 15.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
Really thanks for your help ^^
My guess is that you can't see the points because they are outside the viewing frustum - try glVertex2i(0,0).
Hi Arnaut, Thanks for that but it still doesn't work.