L
Leon
Hey, i am trying to develop a game, and I am using OpenGL and pthread.
(on Ubuntu, so i also use the X library.) Now i have a problem. I have
initialized OpenGL in the main thread, and i want to repaint 30 times
every second (the usual framerate). Now i programmed a timer, which was
able to wait for 30/1000 seconds. That happens in another thread, and
after the delay (nanosleep, from the time.h header), it calls the paint()
function. And it returned a error message. 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? I can't
let the initialising thread delay and repaint, because it has to wait for
X inputs.
(main_thread)
|
\ /
(initialize OpenGL)
|
\ /
(start painting timer)
| \
\ / \
(wait for X events, XNextEvent()) |
\ /
(wait 30/1000 second, and then
call the repaint function)
Can anyone help me please?
grz, Leon
(on Ubuntu, so i also use the X library.) Now i have a problem. I have
initialized OpenGL in the main thread, and i want to repaint 30 times
every second (the usual framerate). Now i programmed a timer, which was
able to wait for 30/1000 seconds. That happens in another thread, and
after the delay (nanosleep, from the time.h header), it calls the paint()
function. And it returned a error message. 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? I can't
let the initialising thread delay and repaint, because it has to wait for
X inputs.
(main_thread)
|
\ /
(initialize OpenGL)
|
\ /
(start painting timer)
| \
\ / \
(wait for X events, XNextEvent()) |
\ /
(wait 30/1000 second, and then
call the repaint function)
Can anyone help me please?
grz, Leon