This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/gameengine/GameLogic
Campbell Barton c36f78dd41 [#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
2009-11-22 14:42:22 +00:00
..
2009-06-13 11:28:29 +00:00
2009-06-08 20:08:19 +00:00
2009-06-28 11:22:26 +00:00
2009-06-28 11:22:26 +00:00
2009-06-28 11:22:26 +00:00
2009-09-26 20:03:01 +00:00
2009-06-08 20:08:19 +00:00
2009-06-28 11:22:26 +00:00
2009-06-28 11:22:26 +00:00
2009-06-28 11:22:26 +00:00
2009-06-08 20:08:19 +00:00
2009-06-28 11:22:26 +00:00
2009-06-28 11:22:26 +00:00