PDA

View Full Version : Qi with glut



hudi
13th April 2010, 07:13
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

wysota
13th April 2010, 10:09
Some more info would be nice but in general you are probably accessing GUI components from a worker thread which is forbidden.

hudi
13th April 2010, 11:03
what information do you want to know ?
So if this is forbidden how I can stop glut aplication ?

wysota
13th April 2010, 13:16
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?

hudi
13th April 2010, 15:31
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:

void Sporic::run() {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowPosition(5, 5);
glutInitWindowSize(WIDTH, HEIGHT);

/* Create main window and set callbacks. */
this->win = glutCreateWindow(TITLE);
glutDisplayFunc(myDisplay);
glutReshapeFunc(myReshape);

glutIdleFunc(myIdle);

/* Create main menu. */
glutCreateMenu(myMenu);
glutAddMenuEntry("Quit", 99);

/* Menu will be invoked by the right mouse button */
glutAttachMenu(GLUT_RIGHT_BUTTON);



init();


/* Run endless main loop to process events. */
glutMainLoop();
}

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.

wysota
14th April 2010, 00:56
What do you use Qt for then?

hudi
14th April 2010, 11:37
and what should I can use except qt ?

wysota
14th April 2010, 11:41
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.