diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-22 17:42:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-22 17:42:22 +0300 |
commit | c36f78dd41b8d2c714b2a94c43eabe928afea26a (patch) | |
tree | 48856d51a20eb4024f142e1fb68a9d345a291aeb /source/gameengine/GameLogic | |
parent | f4a0c9239ff21a75a336ed3f496dd88d3997d28e (diff) |
[#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
Diffstat (limited to 'source/gameengine/GameLogic')
-rw-r--r-- | source/gameengine/GameLogic/SCA_PythonController.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index ac3e0434d20..aeebce6c7d7 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -465,7 +465,8 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) { /* clear after PyErrPrint - seems it can be using * something in this dictionary and crash? */ - PyDict_Clear(excdict); + // This doesn't appear to be needed anymore + //PyDict_Clear(excdict); Py_DECREF(excdict); } |