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 3 of 3

Thread: QT + GLUT NOT WORKING - help!!!

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Oct 2012
    Posts
    2

    QT + GLUT NOT WORKING - help!!!

    Im using OS X and QT. On my mac i can easily find GLUT.framework installed in my libraries, but when i try to use it in QT, it just throws me an error:
    /Users/Astroy/ProjektiQT/RacunalniskaGrafika1-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/../RacunalniskaGrafika1/main.cpp:3:
    error: GL/glut.h: No such file or directory
    and because of that also:
    error: 'glutInit' was not declared in this scope

    The program is simple:

    #include <QtGui/QApplication>
    #include "vaja1.h"
    #include <GL/glut.h>

    int main(int argc, char *argv[])
    {
    glutInit(&argc, argv);
    QApplication a(argc, argv);
    Vaja1 w;
    w.show();

    return a.exec();
    }
    and the project:
    #-------------------------------------------------
    #
    # Project created by QtCreator 2012-10-18T20:08:13
    #
    #-------------------------------------------------

    QT += core gui opengl

    TARGET = RacunalniskaGrafika1
    TEMPLATE = app


    SOURCES += main.cpp\
    vaja1.cpp \
    glwidget.cpp

    HEADERS += vaja1.h \
    glwidget.h

    FORMS += vaja1.ui

    LIBS += -lglut
    so it should be working, i have done this trough a tutorial but... its just doesn't seem to work.... Help please!

  2. #2
    Newbie Newbie
    Join Date
    Oct 2012
    Posts
    2
    ok also i get the error that it can not fint -lglut when i try to add the library, so where is the problem??

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    600
    GLUT+Qt == asking for trouble. GLUT provides making a window, some UI stuff, it's own "event system" etc. The Qt SDK from Nokia(or I guess now Digia) does NOT include GLUT, nor should it (it looks like your environment is MS-Windows).

    If you are already having Qt as a dependency, why would you want to use GLUT? The ritual for using GL on Qt is roughly:
    1. Derive from QGLWidget
    2. Optionally implement initializeGL() to perform one-time init that requires a GL context. This is done because in Qt, the GL context is not active (or even made actually) at constructor of QGLWidget.
    3. Implement paintGL() to do your drawing
    4. Implement various event handling functions: mousePressEvent, mouseReleaseEvent, mouseMoveEvent, keyPressEvent, keyReleaseEvent, etc. Optionally implement resizeGL to capture when your window changes sizes (reimplement resizeGL, NOT resizeEvent to make sure your GL context is current).

Posting Permissions

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