Results 1 to 2 of 2

Thread: Qt with OpenGL 3.3

  1. #1
    kaszewczyk Guest

    Default Qt with OpenGL 3.3

    Hello
    I'm learning OpenGL 3.3 with Qt 4.8 and I have a problem to run my application
    I have created class called Mesh where i use some OpenGL functions from glew library code looks like this:

    Qt Code:
    1. void Mesh::compile()
    2. {
    3. glGenBuffers(1, &this->vbo);
    4. glBindBuffer(GL_ARRAY_BUFFER, this->vbo);
    5. glBufferData(GL_ARRAY_BUFFER, sizeof(this->vertexs), vertexs, GL_STATIC_DRAW);
    6. glBindBuffer(GL_ARRAY_BUFFER, 0);
    7. }
    To copy to clipboard, switch view to plain text mode 

    My application crash on the line "glGenBuffers(1, &this->vbo);" with message "The program stopped working unexpectedly."

    My pro file look like this
    Qt Code:
    1. QT += core gui opengl
    2.  
    3. TARGET = GLSL
    4. TEMPLATE = app
    5.  
    6.  
    7. SOURCES += main.cpp\
    8. glwidget.cpp \
    9. mesh.cpp
    10.  
    11. HEADERS += glwidget.h \
    12. mesh.h
    13.  
    14. FORMS += glwidget.ui
    15.  
    16. CONFIG += glew
    17.  
    18. unix|win32: LIBS += -lGLEW
    To copy to clipboard, switch view to plain text mode 

    Can someone help me please ?

    --------EDIT

    I solve this problem out.

    To use OpenGL 3.3 with Qt please follow these steps

    • add to ur .pro file line
      Qt Code:
      1. unix|win32: LIBS += -lGLEW
      To copy to clipboard, switch view to plain text mode 
    • add this code in ur QGLWidget initializeGL method
      Qt Code:
      1. makeCurrent();
      2. glewExperimental = GL_TRUE;
      3. int glewErr = glewInit();
      4. if( glewErr != GLEW_OK )
      5. {
      6. qDebug("Error %s", glewGetErrorString(glewErr) ) ;
      7. }
      To copy to clipboard, switch view to plain text mode 
    Last edited by kaszewczyk; 21st October 2012 at 18:56.

  2. #2
    Join Date
    Feb 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt with OpenGL 3.3

    Thanks for posting the solution! I just experienced this same problem

Similar Threads

  1. [Qt 4.6.3/OpenGL 4.1] : Unrecognized OpenGL
    By didier in forum Qt Programming
    Replies: 3
    Last Post: 6th August 2011, 00:33
  2. Replies: 0
    Last Post: 6th December 2009, 01:41
  3. Qt with OpenGL ES for ARM9 - All OpenGL ES tests have failed!
    By vinpa in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 3rd December 2009, 11:10
  4. Problem from OpenGL to QT OpenGL
    By nuts_fever_007 in forum Newbie
    Replies: 5
    Last Post: 15th May 2009, 10:37
  5. opengl
    By tpthyd in forum Qt Programming
    Replies: 1
    Last Post: 2nd March 2009, 14:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.