You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, January 7th 2012, 11:17am

glut with opengl doesn't open

I am following a tutorial on youtube how to use glut with Qt.
http://www.youtube.com/watch?v=1nzHSkY4K18
I write just the same as the maker of the tutorial. But when i compile it, it compiles but the window doesn't open.
Starting C:\Users\DirectGamex10\Qtprogs\glut-build-desktop\debug\glut.exe...

C:\Users\DirectGamex10\Qtprogs\glut-build-desktop\debug\glut.exe exited with code -1073741515


I putted the glut.h in the source map and the glut.dll in the build map.

I linked glut.lib . LIBS += -LC:\glut


Here is the source:
main.cpp:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <glut.h>

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

    return a.exec();
}




glwidget.cpp:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "glwidget.h"
#include <glut.h>

GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(parent)
{
    connect(&timer, SIGNAL(timeout()), this, SLOT(updateGL()));
    timer.start(16);
}

void GLWidget::initializeGL(){
    glClearColor(0.2,0.2,0.2,0);
}

void GLWidget::paintGL(){
    glClear(GL_COLOR_BUFFER_BIT);

    glRotatef(0.5,1,1,1);
    glutWireTeapot(0.6);
}

void GLWidget::resizeGL(int w, int h){
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    GLfloat x = GLfloat(w) / h;
    glFrustum(-x, +x, -1.0, +1.0, 0.0, 15.0);
    glMatrixMode(GL_MODELVIEW);
}




glwidget.h:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef GLWIDGET_H
#define GLWIDGET_H

#include <QGLWidget>
#include <glut.h>
#include <QTimer>

class GLWidget : public QGLWidget
{
    Q_OBJECT
public:
    explicit GLWidget(QWidget *parent = 0);

    void initializeGL();
    void paintGL();
    void resizeGL(int w, int h);

private:
    QTimer timer;

};

#endif // GLWIDGET_H




mainwindow.cpp and mainwindow.h stay unchanged.




All help is welcome :)
Belgiumarthur

Similar threads