Changeset 20457 in project


Ignore:
Timestamp:
09/23/10 09:50:55 (9 years ago)
Author:
felix winkelmann
Message:

added example to 3viewer docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/3viewer

    r19766 r20457  
    332332  glut:PassiveMotionFunc
    333333  glut:ReshapeFunc
     334
     335
     336=== Examples
     337
     338<enscript hightlight=scheme>
     339;;; shows a spinning red cube
     340
     341(use gl glut 3viewer)
     342
     343(define a 0)
     344
     345(define (spin id)
     346  (set! a (modulo (+ a 0.25) 360)))
     347
     348(define (colorize id col)
     349  (gl:Materialfv
     350   gl:FRONT_AND_BACK gl:AMBIENT_AND_DIFFUSE
     351   (if (object-highlighted? id)
     352       '#f32(1 1 0 1)
     353       col)))
     354
     355(define (draw-cube id)
     356  (colorize id '#f32(1 0 0 1))
     357  (gl:Rotatef a 1 0 0)
     358  (gl:Rotatef a 0 1 0)
     359  (gl:Rotatef (- a) 0 0 1)
     360  (glut:SolidCube 1))
     361
     362(add-object draw-cube animate: spin select: (lambda _ (print "oink!")))
     363(start-viewer)
     364</enscript>
    334365
    335366
Note: See TracChangeset for help on using the changeset viewer.