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

font-menu.l (1419B)


      1 # 03apr08jk
      2 
      3 (load "@simul/gl/lib.l")
      4 
      5 (setq *FontNum 5)
      6 (setq *Message "Right-click to activate menu")
      7 (setq *MenuItems (list
      8 	"9 by 15" "8 by 13" "Times Roman 10" "Times Roman 24"
      9 	"Helvetica 10" "Helvetica 12" "Helvetica 18") )
     10 
     11 (de drawBitmapString (FontNum String)
     12 	(gl:RasterPos2f 0 0)
     13 	(for Chr (chop String)
     14 		(glut:BitmapCharacter FontNum (char Chr)) ) )
     15 
     16 (glut:Init)
     17 (glut:InitDisplayMode (| GLUT_DOUBLE GLUT_RGBA))
     18 (glut:InitWindowSize 350 150)
     19 (glut:CreateWindow "Bitmap Font Menu")
     20 
     21 (displayFunc ()
     22 	#(println "displayFunc" *Message)
     23 	(gl:Clear GL_COLOR_BUFFER_BIT)
     24 	(gl:LoadIdentity)
     25 	(gl:Color3f 0.75 0.0 0.0)
     26 	(gl:Translatef 20.0 80.0 0)
     27 	(drawBitmapString *FontNum *Message)
     28 	(gl:Translatef 0.0 -40.0 0)
     29 	(drawBitmapString *FontNum "Sample: æøå ÆØÅ äö ÄÖ éè")
     30 	(gl:Flush)
     31 	(glut:SwapBuffers) )
     32 
     33 (reshapeFunc (Width Height)
     34 	(gl:Viewport 0 0 Width Height)
     35 	(gl:MatrixMode GL_PROJECTION)
     36 	(gl:LoadIdentity)
     37 	(glu:Ortho2D 0 (* Width 1.0) 0 (* Height 1.0))
     38 	(gl:MatrixMode GL_MODELVIEW)
     39 	(gl:LoadIdentity)
     40 	(gl:ClearColor 0.8 0.9 0.8 1.0) )
     41 
     42 (createMenu (ItemNo)
     43 	(setq *FontNum (inc ItemNo))
     44 	(setq *Message (pack (inc ItemNo) ": " (get *MenuItems ItemNo)))
     45 	(glut:PostRedisplay) )
     46 
     47 (for (N . Item) *MenuItems
     48 	(glut:AddMenuEntry Item N) )
     49 
     50 (glut:AttachMenu GLUT_RIGHT_BUTTON)
     51 
     52 (gl:Enable GL_LINE_SMOOTH)
     53 (gl:Enable GL_BLEND)
     54 (gl:BlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA)
     55 (glut:MainLoop)