Blender Git Commit Log

Git Commits -> Revision c36f78d

Revision c36f78d by Campbell Barton (master)
November 22, 2009, 14:42 (GMT)
[#19258] [patch] Adding drawing capabilities to BGE Python
patch from Mitchell Stokes (moguri)

simple use case
scene.post_draw = [pyOpenGLFunc]

this only needs to be set once, then the funcion runs each redraw.

note, this patch also changes how python scripts run (not modules): Dont clear the namespace after running a script, since functions still use the namespace, BGE API is now better when dealing with stale data.

made some changes to this patch.
- assigning a list didnt decrement the existing list.
- initialize as NULL rather then a blank list
- dont use string comparisons for the callbacks, pass the python list to use instead.
- dont check the list items are callable. python will display an error if they are not.
- use python list macros that dont do any type checking sine blender does this when assigning the list

---- from tracker, edited since an updated patch changes some things.
Here is a patch to be able to draw to the screen with BGE Python. This will be very handy for GUI stuff. This patch
works by having the user register a callback in the scene. Two options are available KX_Scene.pre_draw
and KX_Scene.post_draw. The difference between these is when Python draws to the screen (before or after the BGE).
Each can take a list of functions. Here is an example that draws a blue semi-transparent

Commit Details:

Full Hash: c36f78dd41b8d2c714b2a94c43eabe928afea26a
SVN Revision: 24769
Parent Commit: f4a0c92
Lines Changed: +106, -2

4 Modified Paths:

/source/gameengine/GameLogic/SCA_PythonController.cpp (+2, -1) (Diff)
/source/gameengine/Ketsji/KX_KetsjiEngine.cpp (+6, -0) (Diff)
/source/gameengine/Ketsji/KX_Scene.cpp (+84, -0) (Diff)
/source/gameengine/Ketsji/KX_Scene.h (+14, -1) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021