How can i run the openGL main loop in a separate thread instead of the main. When i try to do that for example:
void *displayThread (void *threadData)
It does not work.
10-06-2004, 10:16 AM
My answer to you will not help much, but here it is.
It is best to build your own event-loop and handler.
I do this. So, I am asking you to ditch glut, which
will be difficult at first but will make you gain
much programming experience in coding your own event
loop, etc. As an alternative, use SDL, which should
have support for threads.
What I used to do is simple -- the beginner's way.
The main code allocates all the memory, does reading
operations and spawns the rendering process. The
rendering process accepts a pointer to a structure
that contains all the communication information
and the scene data. The spawned process runs a
"while()" loop with a check for when it should
stop/return. The spawned process also does event
handling with regard to the input from the
window. When events are trapped, variables are
set to reflect the state. The main code runs its
own loop, which does whatever the state requires
and "runs the show." I use usleep() or nansleep()
in the while() loops. This is the simplest and
not the most efficient way to go, but it is a
The right way to do it is by communicating from
the spawned process to the main code via some
pipe or socket, etc. This is for advanced coders.
In short, the main code spawns a process which
renders and traps window events. Based an what
variables the slave sets, the main decides what
many words, little help. good luck!
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.