Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: QGL and textures

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2000
    Posts
    9

    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();
    }

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    London, ON. Canada
    Posts
    6

    Re: QGL and textures

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •