[Bf-committers] BGE Python Drawing Patch

Campbell Barton ideasman42 at gmail.com
Mon Oct 19 10:31:00 CEST 2009


+1 in old world blender terms I guess this is a scene scriptlink.
Access to pre/post drawing could be changed a bit to use attributes so
it can do 2 NULL checks per redraw rather then 2 dict lookups, but
thats really a detail and easy to change.

On Mon, Oct 19, 2009 at 2:08 AM, Mitchell Stokes <mitchell at daboys4u.com> wrote:
> Hello Blender Devs!
>
> Over six weeks ago I submitted a patch to the tracker to allow Python
> to draw to the screen in the BGE. I'm posting now to the mailing list
> to see if I could get some feedback on the patch and hopefully get it
> committed sometime. :)
>
> Here is a video demonstrating the patch:
> http://www.youtube.com/watch?v=eWdDDEX6xv0
>
> Here is the link to the tracker post:
> https://projects.blender.org/tracker/?func=detail&aid=19258&group_id=9&atid=306
>
> And here is the message from the tracker post:
>
> "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, or just a single function. Here is
> an example that draws a blue semi-transparent
> square that rotates:
>
> from BGL import *
> import GameLogic as gl
>
> def myFunc():
>        glMatrixMode(GL_PROJECTION)
>        glLoadIdentity();
>        glOrtho(-50.0, 50.0, -25.0, 25.0, -1.0, 1.0)
>        glMatrixMode(GL_MODELVIEW)
>        glLoadIdentity()
>        glDisable(GL_LIGHTING)
>        glPushMatrix()
>        glColor4f(0.0, 0.0, 1.0, 0.8)
>        glRotatef(gl.spin, 0.0, 0.0, 1.0)
>        glRectf(-15.0, -15.0, 15.0, 15.0)
>        gl.spin += 2.0
>        if gl.spin > 360:
>                gl.spin -= 360
>
>        glPopMatrix()
>
> if not hasattr(gl, "spin"):
>        gl.spin = 0.0
>
> gl.getCurrentScene()['post_draw'] = [myFunc]"
>
> Thank you!
> Mitchell Stokes (Moguri)
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>



-- 
- Campbell


More information about the Bf-committers mailing list