PDA

View Full Version : Using OpenGL with mutex?



suo_alex
02-12-2003, 09:46 AM
Dear all,

I am currently coding a game. I have a render engine using OpenGL to paint the scene, and I have a collision detection module.

Since I assume using hardware acceleration in collision detection (matrix calculation) should be faster, I tried to use mutex and single lock on OpenGL so that the render engien and collision module will only use it one after one.

However, when debugging I found the render engine access the OpenGL correctly, while the collision module always cause invalid operation by operating the model view matrix. I explicitely examined the glBegin() and glEnd() pair, and found that the render engine did release the OpenGL after finished the painting.

Is it that I can only use single thread on OpenGL in a process? Or I simply have some problem in threading coordination?

Besides, is my assumption right that using hardware (say, GeForce 2) to compute the transforma matrix will be much faster?

Thank you for your help!

Yours Alex

Humus
02-12-2003, 11:58 AM
Your assumption will most likely be false, any speed increase is killed by the time it takes to transfer the stuff over the AGP, not to talk about driver latencies and everything.

jwatte
02-12-2003, 05:10 PM
A graphics card is not intended to accelerate collision detection.

You should have an efficient implementation of geometry and collision to use for culling when deciding what to draw; this can be re-used when you want to figure out what's near each other to collide against. Then run your typical ball/mesh intersect or whatever.

Btw: multi-threading a sequence of dependent steps, such as input-simulate-render, almost never increases overall speed.