OpenGL World

Jay McCarthy <>

OpenGL World is like world, but the rendering functions are in a GL context.

 (require (planet jaymccarthy/gl-world))

(big-bang world/c    
  #:height height    
  #:width width    
  #:on-tick on-tick    
  #:tick-rate tick-rate    
  #:on-key on-key    
  #:draw-init draw-init    
  #:on-draw on-draw    
  #:stop-when stop-when    
  #:stop-timer stop-timer)  void
  world/c : contract?
  init : world/c
  height : (integer-in 0 10000)
  width : (integer-in 0 10000)
  on-tick : (world/c . -> . world/c)
  tick-rate : (integer-in 0 1000000000)
  on-key : (world/c (is-a?/c key-event%) . -> . world/c)
  draw-init : (-> void)
  on-draw : (world/c . -> . void)
  stop-when : (world/c . -> . boolean?)
  stop-timer : (world/c . -> . boolean?)

Creates a width x height window with an OpenGL canvas and calls draw-init in its context to initialize it. Next on-draw is called in the GL context with init to show the render the first scene. init becomes the current world.

big-bang starts a timer that rings every tick-rate milliseconds (when stop-timer returns false) and calls on-tick with the current world and expects a new world. When there is user input in the canvas, big-bang calls on-key with the key-event% and expects a new world. In either of these cases, if the returned world is not equal? to the current world then it becomes the current world and on-draw is called to redisplay the scene.

These events occur until stop-when returns #t on the current world.