Results 1 to 2 of 2

Thread: Crash during OpenGL context creation

  1. #1
    Join Date
    Mar 2007
    Posts
    11
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Crash during OpenGL context creation

    I'm having an interesting problem with OpenGL contexts in Qt 4.3.3 (Kubuntu 8.04).

    When I try to customize the format, liks so:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : KXmlGuiWindow(parent)
    3. {
    4. QGLFormat format;
    5. QGLContext *context;
    6.  
    7. qDebug("Setting up GL format...");
    8. format.setAccum(false);
    9. format.setAlpha(true);
    10. format.setAlphaBufferSize(8);
    11. format.setBlueBufferSize(8);
    12. format.setDepth(true);
    13. format.setDepthBufferSize(24);
    14. format.setDirectRendering(true);
    15. format.setDoubleBuffer(true);
    16. format.setGreenBufferSize(8);
    17. format.setOverlay(false);
    18. format.setPlane(0);
    19. format.setRedBufferSize(8);
    20. format.setRgba(true);
    21. format.setSampleBuffers(true);
    22. format.setSamples(4);
    23. format.setStencil(true);
    24. format.setStencilBufferSize(8);
    25. format.setStereo(false);
    26. format.setSwapInterval(0);
    27.  
    28. qDebug("Creating Context...");
    29. context = new QGLContext(format);
    30. if(!context->create()) {
    31. qWarning("Failed to create context...");
    32. qDebug("Disabling multisampling...");
    33. format.setSampleBuffers(false);
    34. context->setFormat(format);
    35. if(!context->create()) {
    36. qFatal("Still can't create a context...");
    37. exit(0);
    38. }
    39. }
    40.  
    41. qDebug("Creating preview widget...");
    42. preview = new MaterialPreview(context);
    43.  
    44. setCentralWidget(preview);
    45. setupGUI();
    46. }
    To copy to clipboard, switch view to plain text mode 
    I get a crash during the first call to context->create().

    When I don't setup a custom format and context, and just create a QGLWidget, I don't have the crash.

    In case you're curious, the odd bit with multisampling is just a test to see if I can actually setup a multisampled rendering context on my machine.

    EDIT:
    Here's the backtrace:
    Qt Code:
    1. #0 0xb755dc35 in QX11Info::screen () from /usr/lib/libQtGui.so.4
    2. #1 0xb6d31671 in QGLContext::tryVisual () from /usr/lib/libQtOpenGL.so.4
    3. #2 0xb6d30529 in QGLContext::chooseVisual () from /usr/lib/libQtOpenGL.so.4
    4. #3 0xb6d30984 in QGLContext::chooseContext () from /usr/lib/libQtOpenGL.so.4
    5. #4 0xb6d062a4 in QGLContext::create () from /usr/lib/libQtOpenGL.so.4
    6. #5 0x0804ca79 in MainWindow (this=0x80fdf80, parent=0x0) at mainwindow.cpp:39
    7. #6 0x0804c778 in main (argc=1, argv=0xbfc0c574) at main.cpp:25
    To copy to clipboard, switch view to plain text mode 

    *Yes, I know this is a KDE program, but the problem appears to be in Qt
    Last edited by PaladinOfKaos; 18th January 2008 at 19:32. Reason: Additional information

  2. #2
    Join Date
    May 2008
    Location
    Melbourne, Australia
    Posts
    136
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Crash during OpenGL context creation

    hello,

    I know this was a long time ago, but did you ever figure out the context problem?

    On my system (Windows XP, Qt 4.5.1) I found setting the context manually does not work and the only way to enable multisampling was through the constructor:
    Qt Code:
    1. MyWidget:: MyWidget(QWidget *parent):QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
    To copy to clipboard, switch view to plain text mode 

    I got the hint from this article that setContext() has problems: http://doc.trolltech.com/qq/qq06-glimpsing.html

    hope that helps someone,
    Richard

Similar Threads

  1. Crash when minimizing OpenGL widget
    By MistaPain in forum Qt Programming
    Replies: 5
    Last Post: 7th October 2006, 16:58
  2. help on openGL context
    By mickey in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2006, 19:21
  3. Qt's optimized OpenGL context switching
    By sverhoff in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 16:40
  4. Context OpenGL
    By mickey in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2006, 21:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.