diff --git a/contrib/x11/examples/lindenmayer/README b/contrib/x11/examples/lindenmayer/README new file mode 100644 index 0000000000..56ceaf57e3 --- /dev/null +++ b/contrib/x11/examples/lindenmayer/README @@ -0,0 +1,74 @@ + +---------------------------------------------------------------------- +Install +---------------------------------------------------------------------- + +Load, compile and save your image: + + "load.factor" run-file save + +---------------------------------------------------------------------- +Usage +---------------------------------------------------------------------- + + USE: lindenmayer setup-window + +Towards the end of the "lindenmayer.factor" file, there are words for +various L-systems. Let's pick abop-1, which is an example from the +book The Algorithmic Beauty of Plants + + abop-1 + +Look at the axiom + + axiom get . + +And the productions + + rules get . + +The string to be interpreted is stored in the result variable. Start +off by calling init to copy the axiom to result + + init + +Look at result + + result get . + +It's just the axiom. Now iterate the string + + iterate + +You should see a branch and a leaf. Look at the result again: + + result get . + +Call iterate as many times as you want. :-) After about 4 iterations +the tree starts to grow beyond the edge of the window. Change the +point that the camera is looking at: + + { 0 0 3 } camera-focus set-global display + +You can also change where the camera is located: + + { 0 0 10 } camera-position set-global display + +Happy gardening + +---------------------------------------------------------------------- +See also +---------------------------------------------------------------------- + +The Algorithmic Beauty of Plants +by Przemyslaw Prusinkiewicz and Aristid Lindenmayer +Available online: http://algorithmicbotany.org/papers/abop/abop.pdf + +The Computational Beauty of Nature +Gary William Flake + +Algorithmic Botany at the University of Calgary +http://algorithmicbotany.org/ + +Laurens Lapre's Lparser +http://home.wanadoo.nl/laurens.lapre/lparser.html \ No newline at end of file diff --git a/contrib/x11/examples/lindenmayer/lindenmayer.factor b/contrib/x11/examples/lindenmayer/lindenmayer.factor index 6036ce135a..49975d6afc 100644 --- a/contrib/x11/examples/lindenmayer/lindenmayer.factor +++ b/contrib/x11/examples/lindenmayer/lindenmayer.factor @@ -36,9 +36,6 @@ SYMBOL: orientation : step ( length -- ) >r position get orientation get 0 0 r> 3array m.v v+ position set-global ; -! : step ( length -- ) -! >r position get orientation get r> 0 0 3array m.v v+ position set-global ; - ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : record-vertex ( -- ) position get first3 glVertex3f ; diff --git a/contrib/x11/examples/lindenmayer/viewer.factor b/contrib/x11/examples/lindenmayer/viewer.factor index 4048d6d2a9..3b7e20d267 100644 --- a/contrib/x11/examples/lindenmayer/viewer.factor +++ b/contrib/x11/examples/lindenmayer/viewer.factor @@ -28,7 +28,8 @@ lparser-dialect "" result set-global : display ( -- ) GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear glLoadIdentity -camera-position get first3 camera-focus get first3 camera-up get first3 gluLookAt +camera-position get first3 camera-focus get first3 camera-up get first3 +gluLookAt reset result get save-state interpret restore-state glFlush ; : reshape ( { width height } -- ) @@ -40,7 +41,7 @@ display ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: init ( -- ) axiom get result set ; +: init ( -- ) axiom get result set display ; : iterate ( -- ) result [ rewrite ] change display ; diff --git a/contrib/x11/gl.factor b/contrib/x11/gl.factor index 679b92cdb9..1f7d7f4753 100644 --- a/contrib/x11/gl.factor +++ b/contrib/x11/gl.factor @@ -1,9 +1,5 @@ IN: gl USING: kernel words sequences alien arrays namespaces x xlib x11 ; -! : >int-array ( seq -- ) -! dup length "int-array" swap dup length >array -! [ pick set-int-nth ] 2each ; - : >int-array ( seq -- ) dup length "int" swap dup length >array [ pick set-int-nth ] 2each ; @@ -16,6 +12,6 @@ dup length "int" swap dup length >array [ pick set-int-nth ] 2each ; : create-context ( XVisualInfo* -- GLXContext ) >r dpy get r> 0 True glXCreateContext ; -: make-current ( GLXContext -- Bool ) >r dpy get win get r> glXMakeCurrent ; +: make-current ( GLXContext -- ) >r dpy get win get r> glXMakeCurrent drop ; : swap-buffers ( -- ) dpy get win get glXSwapBuffers ;