diff options
author | Luca Bonavita <mindrones@gmail.com> | 2010-10-13 14:42:33 +0400 |
---|---|---|
committer | Luca Bonavita <mindrones@gmail.com> | 2010-10-13 14:42:33 +0400 |
commit | 996efebbe36a06ba45b9a79328a0dadc87ea2ff9 (patch) | |
tree | dd5a64d001a8e482d538effd94f60a593e6ef56e /doc/python_api/epy/testbgl.py | |
parent | d058a9c8c3d5481fa0c82c8118d207fda6b56830 (diff) |
== python api doc ==
First commit to make some structure in doc/ directory.
- moved source/blender/python/doc -> doc/python_api
- moved source/gameengine/PyDoc/*.rst -> doc/python_api/rst
- modified accordingly sphinx_doc_gen.py and sphinx_doc_gen.sh
(later on I'll try alternative/ scripts by neXyon as promised :)
- source/gameengine/PyDoc/ is still there because contains epydoc stuff for the bge, will ask more and look into it later
Diffstat (limited to 'doc/python_api/epy/testbgl.py')
-rw-r--r-- | doc/python_api/epy/testbgl.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/doc/python_api/epy/testbgl.py b/doc/python_api/epy/testbgl.py new file mode 100644 index 00000000000..e895d01df69 --- /dev/null +++ b/doc/python_api/epy/testbgl.py @@ -0,0 +1,45 @@ +# Testing the BGL module + +import Blender +from Blender.BGL import * +from Blender import Draw + +R = G = B = 0 +A = 1 + +instructions = "Hold mouse buttons to change the background color." +quitting = " Press ESC or q to quit." + +def show_win(): + glClearColor(R,G,B,A) # define color used to clear buffers + glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer + glColor3f(1,1,1) # change default color + glRasterPos2i(50,100) # move cursor to x = 50, y = 100 + Draw.Text("Testing BGL + Draw") # draw this text there + glRasterPos2i(350,20) # move cursor again + Draw.Text(instructions + quitting) # draw another msg + glBegin(GL_LINE_LOOP) # begin a vertex-data list + glVertex2i(46,92) + glVertex2i(120,92) + glVertex2i(120,115) + glVertex2i(46,115) + glEnd() # close this list + glColor3f(0.35,0.18,0.92) # change default color again + glBegin(GL_POLYGON) # another list, for a polygon + glVertex2i(315, 292) + glVertex2i(412, 200) + glVertex2i(264, 256) + glEnd() + Draw.Redraw(1) # make changes visible. + +def ev(evt, val): # this is a callback for Draw.Register() + global R,G,B,A # it handles input events + if evt == Draw.ESCKEY or evt == Draw.QKEY: + Draw.Exit() # this quits the script + elif evt == Draw.LEFTMOUSE: R = 1 - R + elif evt == Draw.MIDDLEMOUSE: G = 1 - G + elif evt == Draw.RIGHTMOUSE: B = 1 - B + else: + Draw.Register(show_win, ev, None) + +Draw.Register(show_win, ev, None) # start the main loop |