QGL and textures

Hi there, i am just playing around with the qtlibs and gl, but the textures messed my up. Can you modifie my example by using the QImage-lib to texture the triangle?
THX
#include <qgl.h>
#include <qapplication.h>

class GWidget : public QGLWidget {
protected:
void initializeGL();
void resizeGL(int, int);
void paintGL();
};

void GWidget::initializeGL() {
glShadeModel(GL_SMOOTH);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
}

void GWidget::resizeGL(int width, int height) {
glViewport( 0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, width/height, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void GWidget: aintGL() {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0, 0.0, -6.0);
glBegin(GL_TRIANGLES);
glVertex3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glVertex3f( 1.0, -1.0, 0.0);
glEnd();
}

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

There are some examples with Qt-2.2.x that show use of textures.

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