Where is your GLWidget being constructed? Did you add it in Qt Designer (and so it is being constructed via setupUi())?
You probably need to at least set the viewport size in the resizeGL() method:
void GLWidget::resizeGL( int w, int h )
{
glViewport( 0, 0, (GLint)w, (GLint)h );
}
void GLWidget::resizeGL( int w, int h )
{
glViewport( 0, 0, (GLint)w, (GLint)h );
}
To copy to clipboard, switch view to plain text mode
You could simply your test case further by eliminating the MainWindow:
#include "glwidget.h"
#include <QApplication>
#include <GL/glut.h>
int main(int argc, char *argv[])
{
glutInit(&argc,argv);
GLWidget w;
w.show();
return a.exec();
}
#include "glwidget.h"
#include <QApplication>
#include <GL/glut.h>
int main(int argc, char *argv[])
{
glutInit(&argc,argv);
QApplication a(argc, argv);
GLWidget w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
This makes the GLWidget your top-level application widget and eliminates MainWindow as the cause of any errors.
Bookmarks