mplisp

miniPicoLisp with FFI and modules for Buddy BDD library, OpenGL, Gtk and GMP
git clone https://logand.com/git/mplisp.git/
Log | Files | Refs

cube.l (1654B)


      1 # 03mar08jk
      2 
      3 # Based on cube.io by Mike Austin
      4 
      5 (load "@simul/gl/lib.l")
      6 
      7 (setq *AngleX -26.0 *AngleY 74.0)
      8 (setq *LastX 0 *LastY 0)
      9 
     10 (glut:Init)
     11 (glut:InitDisplayMode (| GLUT_RGBA GLUT_DOUBLE GLUT_DEPTH))
     12 (glut:InitWindowSize 512 512)
     13 (glut:InitWindowPosition 10 50)
     14 (glut:CreateWindow "Pico Lisp Cube")
     15 
     16 (gl:ClearColor 1.0 1.0 1.0 1.0)	# the background color
     17 (gl:Enable GL_DEPTH_TEST)
     18 (gl:Enable GL_LIGHTING)
     19 (gl:Enable GL_LIGHT0)
     20 (gl:Disable GL_CULL_FACE)
     21 
     22 (gl:Enable GL_BLEND)
     23 (gl:BlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA)
     24 (gl:Enable GL_LINE_SMOOTH)
     25 (gl:Hint GL_LINE_SMOOTH_HINT GL_NICEST)
     26 (gl:LineWidth 2.0)
     27 
     28 (de myMouse (Btn State X Y)
     29 	#(println "myMouse" Btn State X Y)
     30 	(setq *LastX X *LastY Y) )
     31 
     32 (de myMotion (X Y)
     33 	#(println "myMotion" X Y)
     34 	(inc '*AngleX (* (- Y *LastY) 1.0))
     35 	(inc '*AngleY (* (- X *LastX) 1.0))
     36 	(setq *LastX X *LastY Y)
     37    (glut:PostRedisplay) )
     38 
     39 (de myReshape (Width Height)
     40 	#(println "myReshape" Width Height)
     41 	(gl:MatrixMode GL_PROJECTION)
     42 	(gl:LoadIdentity)
     43 	(glu:Perspective 45.0 (*/ Width 1.0 Height) 1.0 10.0)
     44 	(gl:MatrixMode GL_MODELVIEW)
     45 	(gl:Viewport 0 0 Width Height) )
     46 
     47 (displayFunc ()
     48 	#(println "displayFunc")
     49 	(gl:Clear (| GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))
     50 	(gl:LoadIdentity)
     51 	(gl:Translatef 0.0 0.0 -3.0)
     52 	(gl:Rotatef *AngleX 1 0 0)
     53 	(gl:Rotatef *AngleY 0 1 0)
     54 	(glut:SolidCube 1.0)
     55 	
     56 	(gl:Disable GL_LIGHTING)
     57 	(gl:Color4f 0.4 0.4 0.4 1.0)
     58 	(glut:WireCube 1.002)
     59 	(gl:Enable GL_LIGHTING)
     60 	
     61 	(gl:Flush)
     62 	(glut:SwapBuffers) )
     63 
     64 (mouseFunc (Btn State X Y)
     65 	(myMouse Btn State X Y) )
     66 
     67 (motionFunc (X Y)
     68 	(myMotion X Y) )
     69 
     70 (reshapeFunc (Width Height)
     71 	(myReshape Width Height) )
     72 
     73 (glut:MainLoop)