QGL

Hi there, I wrote this little qt-programm, which should bring a trinagle up to the screen, but it doesn’t. Can anybody tell me what I did wrong?
#include <qgl.h>
#include <qapplication.h>

class GWidget : public QGLWidget {
public:
GWidget(QWidget *parent=0,const char *name=0);
protected:
void initializeGL();
void resizeGL(int, int);
void paintGL();
};

static GLint obj1;

GWidget::GWidget(QWidget *parent, const char *name) {
}

void GWidget::initializeGL() {
static GLfloat pos[4] = { 1.0, 1.0, 10.0, 1.0};
static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0};
glLightfv(GL_LIGHT0,GL_POSITION,pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
obj1 = glGenLists(1);
glNewList(obj1, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
glShadeModel(GL_FLAT);
glNormal3f(0.0,0.0,1.0);
glBegin(GL_TRIANGLES);
glVertex3f(1.0,1.0,1.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(2.0,2.0,2.0);
glEnd();
}

void GWidget::resizeGL(int width, int height) {
glViewport( 0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum( -width/height, width/height, -1.0, 1.0, 5.0, 60.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void GWidget: aintGL() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
}

int main(int argc, char* argv[]) {
QApplication app(argc,argv);
GWidget w;
app.setMainWidget(&w);
w.show();
return app.exec();
}

You must have a glCallList( obj1 )
inside paintGL(). That’s the first thing
I saw… there may be others.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.