BGL Live Preview Window

I am in the process of developing a 3d vjing application (have already read the thread on that) however we wish to use the Blender engine on its own rather than the game engine.

Im looking for a way to create a BGL window and then somehow refresh it. I can create the window ok, but the only way i can see to update it is to use the event callback. I need some way to loop this and cannot appear to find any useable hook (updating on mouse movements is no good as we are performing some mathematical functions then rendering the output via BGL to another part of the blender window. A sort of make objects in blender, animate them in the blender engine (which ive got working ok), then render them to a live preview (BGL window) on the fly.

Ive noticed from searching the forums that threads are a no go, and timers also (as they rely on threading).

Does anyone know a clever way to make a regular callback / loop to refresh a bgl window?

I noticed in the documentation there is a reference to the windowing loop
“Inside the windowing loop (after Draw.Register() has been executed and before Draw.Exit() is called)”
I dont know if i can somehow magically link a function to that?

Also i don’t know if its somehow possible to generate a key press in python and route it to the specific window, thus imitating an event from elsewhere.


Unfortunately for you, what you suggest is not possible. Blender doesn’t provide a facility for a regular callback (eg a timer event). There are reasons why and it has both good and bad sides, but the short answer is no, there is no way around it. At least not with Python.

you could press play in the timeline and then make your script use an “OnRedraw” scriptlink. then you could mess with event handelers to get it to read user input,

I am currently using the redraw scriptlink in the timeline to run another loop, any bright ideas on how i make it send an event to my output (BGL) window?