Results 1 to 8 of 8

Thread: Qi with glut

  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Qi with glut

    hi I have a small problem. I make an aplication in Glut and now i need to transfer to Qt because in final project i need this aplikation in thread. And I have problem with function stop I try this:
    void Sporic::stop(){
    glutDestroyWindow(this->win);
    }

    but it isnt working. There is some of warning :
    First-chance exception at 0x1000bacd in sporic.exe: 0xC0000005: Access violation reading location 0x33725bb4.
    Unhandled exception at 0x1000bacd in sporic.exe: 0xC0000005: Access violation reading location 0x33725bb4.

    and then the aplication crashed.

    thx for help

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qi with glut

    Some more info would be nice but in general you are probably accessing GUI components from a worker thread which is forbidden.

  3. The following user says thank you to wysota for this useful post:

    hudi (13th April 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qi with glut

    what information do you want to know ?
    So if this is forbidden how I can stop glut aplication ?
    Last edited by hudi; 13th April 2010 at 12:13.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qi with glut

    How should I know? I haven't seen a piece of relevant code of yours. If you use Qt in your application then you can emit a signal from a worker thread and process it in the main thread. But it would probably be better if you just used QGLWidget instead of the glut window. I don't see why you are using threads either, would you care to explain?

  6. The following user says thank you to wysota for this useful post:

    hudi (13th April 2010)

  7. #5
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qi with glut

    I will try...
    So I have a server,which listen on port. This is main thread. Depending on what information it accepted I run other thread with glut aplication. Here is the method run:
    Qt Code:
    1. void Sporic::run() {
    2. glutInit(&argc, argv);
    3. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    4. glutInitWindowPosition(5, 5);
    5. glutInitWindowSize(WIDTH, HEIGHT);
    6.  
    7. /* Create main window and set callbacks. */
    8. this->win = glutCreateWindow(TITLE);
    9. glutDisplayFunc(myDisplay);
    10. glutReshapeFunc(myReshape);
    11.  
    12. glutIdleFunc(myIdle);
    13.  
    14. /* Create main menu. */
    15. glutCreateMenu(myMenu);
    16. glutAddMenuEntry("Quit", 99);
    17.  
    18. /* Menu will be invoked by the right mouse button */
    19. glutAttachMenu(GLUT_RIGHT_BUTTON);
    20.  
    21.  
    22.  
    23. init();
    24.  
    25.  
    26. /* Run endless main loop to process events. */
    27. glutMainLoop();
    28. }
    To copy to clipboard, switch view to plain text mode 

    and now I want to stop this thread but i dont know how. I must close this glut window but glut function glutDestroyWindow(this->win); doesnt work.
    Last edited by wysota; 14th April 2010 at 01:56. Reason: missing [code] tags

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qi with glut

    What do you use Qt for then?

  9. #7
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qi with glut

    and what should I can use except qt ?

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qi with glut

    Eeem... I'm afraid I don't understand. I asked you what you use Qt for, because there is no single line of Qt code here anywhere. You are using glut for your user interface so it's not obvious where is Qt in that so I asked you to clarify it. Becuase from what I see you can get rid of most glut calls (all related to windows and event loops) and implement them in Qt. And you won't need threads so your problem will go away by itself. You don't need threads with glut alone too as you can use the idle function to handle the network.

Similar Threads

  1. How to link GLUT to Qt Project?
    By Lawand in forum Newbie
    Replies: 5
    Last Post: 20th March 2010, 21:29
  2. using GLUT along with qtcreator/mingw in windows
    By stephanepoirier in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2009, 06:26

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.