blender/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
..
Joystick allow building without SDL 2009-06-13 11:28:29 +00:00
CMakeLists.txt option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
Makefile 2.50: 2009-06-08 20:08:19 +00:00
SCA_2DFilterActuator.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_2DFilterActuator.h BGE Python API 2009-06-28 11:22:26 +00:00
SCA_ActuatorEventManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_ActuatorEventManager.h almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_ActuatorSensor.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_ActuatorSensor.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_AlwaysEventManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_AlwaysEventManager.h almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_AlwaysSensor.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_AlwaysSensor.h BGE Python API 2009-06-28 11:22:26 +00:00
SCA_ANDController.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_ANDController.h BGE Python API 2009-06-28 11:22:26 +00:00
SCA_BasicEventManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_BasicEventManager.h Sound: 2009-09-26 20:03:01 +00:00
SCA_DelaySensor.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_DelaySensor.h remove all python api functions deprecated in 2.49 2009-08-25 22:51:18 +00:00
SCA_EventManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_EventManager.h BGE: dynamic loading patch commited. API and demo files available here: https://projects.blender.org/tracker/?func=detail&aid=19492&group_id=9&atid=127 2009-11-15 23:58:56 +00:00
SCA_ExpressionController.cpp fix for own error in active bone commit, wasnt checking object type was an armature 2009-11-10 13:20:32 +00:00
SCA_ExpressionController.h BGE guardedalloc, Uses WITH_CXX_GUARDEDALLOC but gives a string to MEM_mallocN for better tracking memory usage. 2009-08-18 15:37:31 +00:00
SCA_IActuator.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_IActuator.h Merge of itasc branch. Project files, scons and cmake should be working. Makefile updated but not tested. Comes with Eigen2 2.0.6 C++ matrix library. 2009-09-24 21:22:24 +00:00
SCA_IController.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_IController.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_IInputDevice.cpp Patch from GSR that a) fixes a whole bunch of GPL/BL license 2008-04-16 22:40:48 +00:00
SCA_IInputDevice.h BGE guardedalloc, Uses WITH_CXX_GUARDEDALLOC but gives a string to MEM_mallocN for better tracking memory usage. 2009-08-18 15:37:31 +00:00
SCA_ILogicBrick.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_ILogicBrick.h BGE: dynamic loading patch commited. API and demo files available here: https://projects.blender.org/tracker/?func=detail&aid=19492&group_id=9&atid=127 2009-11-15 23:58:56 +00:00
SCA_IObject.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_IObject.h - rather then passing the python namespace dictionary to the controller function get the namespace from the converter. 2009-09-29 22:49:33 +00:00
SCA_IScene.cpp 2.50: 2009-06-08 20:08:19 +00:00
SCA_IScene.h BGE guardedalloc, Uses WITH_CXX_GUARDEDALLOC but gives a string to MEM_mallocN for better tracking memory usage. 2009-08-18 15:37:31 +00:00
SCA_ISensor.cpp BGE: dynamic loading patch commited. API and demo files available here: https://projects.blender.org/tracker/?func=detail&aid=19492&group_id=9&atid=127 2009-11-15 23:58:56 +00:00
SCA_ISensor.h BGE: dynamic loading patch commited. API and demo files available here: https://projects.blender.org/tracker/?func=detail&aid=19492&group_id=9&atid=127 2009-11-15 23:58:56 +00:00
SCA_JoystickManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_JoystickManager.h almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_JoystickSensor.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_JoystickSensor.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_KeyboardManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_KeyboardManager.h almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_KeyboardSensor.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_KeyboardSensor.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_LogicManager.cpp BGE: Removing OB prefix from object names - This will break scripts !!!! (also removing AC and ME :: internal changes only) 2009-11-22 00:01:52 +00:00
SCA_LogicManager.h BGE: dynamic loading patch commited. API and demo files available here: https://projects.blender.org/tracker/?func=detail&aid=19492&group_id=9&atid=127 2009-11-15 23:58:56 +00:00
SCA_MouseManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_MouseManager.h almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_MouseSensor.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_MouseSensor.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_NANDController.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_NANDController.h BGE Python API 2009-06-28 11:22:26 +00:00
SCA_NORController.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_NORController.h BGE Python API 2009-06-28 11:22:26 +00:00
SCA_ORController.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_ORController.h BGE Python API 2009-06-28 11:22:26 +00:00
SCA_PropertyActuator.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_PropertyActuator.h remove all python api functions deprecated in 2.49 2009-08-25 22:51:18 +00:00
SCA_PropertyEventManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_PropertyEventManager.h almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_PropertySensor.cpp patch from Dave Plater which fixes some problems building the BGE with cmake 2009-11-21 13:47:16 +00:00
SCA_PropertySensor.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_PythonController.cpp [#19258] [patch] Adding drawing capabilities to BGE Python 2009-11-22 14:42:22 +00:00
SCA_PythonController.h - rather then passing the python namespace dictionary to the controller function get the namespace from the converter. 2009-09-29 22:49:33 +00:00
SCA_RandomActuator.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_RandomActuator.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_RandomEventManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_RandomEventManager.h almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_RandomNumberGenerator.cpp 2.50: 2009-06-08 20:08:19 +00:00
SCA_RandomNumberGenerator.h BGE guardedalloc, Uses WITH_CXX_GUARDEDALLOC but gives a string to MEM_mallocN for better tracking memory usage. 2009-08-18 15:37:31 +00:00
SCA_RandomSensor.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_RandomSensor.h option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_TimeEventManager.cpp almost all event managers stored a pointer back to the logic manager, easier if this pointer is in the base class - SCA_EventManager 2009-09-25 16:30:15 +00:00
SCA_TimeEventManager.h BGE guardedalloc, Uses WITH_CXX_GUARDEDALLOC but gives a string to MEM_mallocN for better tracking memory usage. 2009-08-18 15:37:31 +00:00
SCA_XNORController.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_XNORController.h BGE Python API 2009-06-28 11:22:26 +00:00
SCA_XORController.cpp option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00
SCA_XORController.h BGE Python API 2009-06-28 11:22:26 +00:00
SConscript option to build the BGE without python, uses existing python check (cmake and scons) 2009-09-29 21:42:40 +00:00