PDA

View Full Version : glThreads in OpenGL + C



sergio pinto
07-07-2010, 06:16 PM
hello I trying to draw many objects (ball) in a scene in the same time but a can't,

??

something help about glthread to draw many objects in a scene?
please help

ZbuffeR
07-07-2010, 11:58 PM
draw loop {
for each ball to draw {
drawBall(ball.parameters);
}
swapbuffers()
}

Why do you want threads ?

sergio pinto
07-08-2010, 07:40 AM
hi :O).. thanks for answer.

I need threads because I want draw many objects in the some time,
I have a function that draw a ball animation of one point to another, THen I want call to that function 5 times with differents objects at the same time have draw all this objects in the scene.

ZbuffeR
07-08-2010, 08:05 AM
You can not do that.
You have to split your monolithic function into parts, to fit that inside the draw loop I wrote above.

sergio pinto
07-08-2010, 12:14 PM
MMMM,,.
jjejeje
thankssss.......

but if someone have a example to use pthreads with opengl...
i will give thanks,,,, because i am in my work .... please

ZbuffeR
07-08-2010, 01:03 PM
If you use threads with OpenGL, you will have to mutex the hell of it, so it will becomes completely serialized instead of parallel.
A complete waste of time.

The GPU can not take commands in parallel.

Good luck.

Rosario Leonardi
07-08-2010, 03:03 PM
ZBuffer is right, an openGl application can use only one context attached to the viewport.
Using multiple thread to draw is like printing 5 word documents at the same time (in the same printer).
You can use some technique to render on a offline texture, but is too complex and the performance gain is so little (the GPU is still the same) that is better to spend your time doing an efficient single thread render queue.

sergio pinto
08-03-2010, 04:04 PM
thans for the help....
I am thinking use 2 hilos o thread uno para dibujo y otro para el glClear.....


para usar hilos porque tengo que si o si usar hilos ... para dibujar objetos en paralelo.