Re: pthread and opengl
On Feb 10, 4:47 pm, Rolf Magnus <ramag...@t-online.de> wrote:
Leon wrote:
Hey, i am trying to develop a game, and I am using OpenGL
and pthread.
Both OpenGL and pthreads are off-topic here. A better newsgroup for your
question is comp.graphics.api.opengl.
I found out that it was because OpenGL can't be painted from
a different thread than the initialising thread. Can anyone
help me what to do to fix this?
Most OpenGL implementations aren't thread-safe. You must do
all the OpenGL calls in one thread.
Isn't this more or less true of all Windowing frameworks? I
would expect the usual architecture to have a dedicated thread
for handling the graphics on the screen, with at the most the
model component being accessible from more than one thread.
Which isn't quite the same thing as his problem, if I understand
it correctly. He initializes the graphics from the "original"
thread (in fact, before starting threading), and then wants to
serve them from another, dedicated thread. Normally, I would
expect this to work, as long as the initializing thread doesn't
do anything with the objects after the server thread has been
started. But I can imagine a debugging implementation which
notes which thread it was created in, and asserts that all of
the following requests are in that thread. The solution, of
course, is to move the initialization to the graphics thread. I
tend to do this anyway if the initialization is non-trivial; to
me, it seems somehow cleaner.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34