global-state

Description

Global state is really anything that controls the renderer globally, so it affects all primitives or controls the renderer directly - ie camera control or full screen effects like blurring.

(clear-engine)

Returns void

Clears the renderer, and physics system. This command should not be called directly, use clear instead, as this clears a few other things, and calls clear-engine itself.

Example

 (clear-engine) ; woo hoo!

(blur amount-number)

Returns void

Sets the full screen blur setting. Less is more, but if you set it too low it will make the on screen editing impossible to read, so save your script first :)

Example

 (blur 0.1) ; for nice trails

(fog fogcolour-vector amount-number begin-number end-number)

Returns void

Sets the fogging parameters to give a visual depth cue (aerial perspective in painter's jargon). This can obscure the on screen editing, so keep the amount small.

Example

 (clear-colour (vector 0 0 1))   ; looks nice if the background matches
 (fog (vector 0 0 1) 0.01 1 100) ; blue fog

(show-axis show-number)

Returns void

Shows the worldspace origin axis used.

Example

 (show-axis 1)

(show-fps show-number)

Returns void

Shows an fps count in the lower left of the screen. used.

Example

 (show-fps 1)

(lock-camera primitiveid-number)

Returns void

Locks the camera transform onto the specified primitive's transform. It's like parenting the camera to the object. This is the easiest way to procedurally drive the camera. Use an id number of 0 to unlock the camera.

Example

 (clear)
 (define obj (build-cube)) ; make a cube for the camera to lock to

 (with-state ; make a background cube so we can tell what's happening
     (hint-wire)
     (hint-unlit)
     (texture (load-texture "test.png"))
     (colour (vector 0.5 0.5 0.5))
     (scale (vector -20 -10 -10))
     (build-cube))

 (lock-camera obj) ; lock the camera to our first cube
 (camera-lag 0.1)  ; set the lag amount, this will smooth out the cube jittery movement

 (define (animate)
     (with-primitive obj
         (identity)
         (translate (vector (fmod (time) 5) 0 0)))) ; make a jittery movement

 (every-frame (animate))

(camera-lag amount-number)

Returns void

The camera locking has an inbuilt lagging which means it will smoothly blend the movement relative to the primitive it's locked to.

Example

 (clear)
 (define obj (build-cube)) ; make a cube for the camera to lock to

 (with-state ; make a background cube so we can tell what's happening
     (hint-wire)
     (hint-unlit)
     (texture (load-texture "test.png"))
     (colour (vector 0.5 0.5 0.5))
     (scale (vector -20 -10 -10))
     (build-cube))

 (lock-camera obj) ; lock the camera to our first cube
 (camera-lag 0.1)  ; set the lag amount, this will smooth out the cube jittery movement

 (define (animate)
     (with-primitive obj
         (identity)
         (translate (vector (fmod (time) 5) 0 0)))) ; make a jittery movement

 (every-frame (animate))

(load-texture pngfilename-string optional-create-params-list)

Returns textureid-number

Loads a texture from disk, converts it to a texture, and returns the id number. The texture loading is memory cached, so repeatedly calling this will not cause it to load again. The cache can be cleared with clear-texture-cache. The png may be RGB or RGBA to use alpha transparency. To get more control how your texture is created you can use a list of parameters. See the example for more explanation. Use id for adding more texture data to existing textures as mipmap levels, or cube map faces. Note: if turning mipmapping off and only specifing one texture it should be set to mip level 0, and you'll need to turn the min and mag filter settings to linear or nearest (see texture-params).

Example

 ; simple usage:
 (texture (load-texture "mytexture.png"))
 (build-cube) ; the cube will be texture mapped with the image

 ; complex usages:

 ; the options list can contain the following keys and values:
 ; id: texture-id-number (for adding images to existing textures - for mipmapping and cubemapping)
 ; type: [texture-2d cube-map-positive-x cube-map-negative-x cube-map-positive-y
 ;         cube-map-negative-y cube-map-positive-z cube-map-negative-z]
 ; generate-mipmaps: exact integer, 0 or 1
 ; mip-level: exact integer
 ; border: exact integer
 ; compress: exact integer, 0 or 1

 ; setup an environment cube map
 (define t (load-texture "cube-left.png" (list 'type 'cube-map-positive-x)))
 (load-texture "cube-right.png" (list 'id t 'type 'cube-map-negative-x))
 (load-texture "cube-top.png" (list 'id t 'type 'cube-map-positive-y))
 (load-texture "cube-bottom.png" (list 'id t 'type 'cube-map-negative-y))
 (load-texture "cube-front.png" (list 'id t 'type 'cube-map-positive-z))
 (load-texture "cube-back.png" (list 'id t 'type 'cube-map-negative-z))
 (texture t)

 ; setup a mipmapped texture with our own images
 ; you need as many levels as it takes you to get to 1X1 pixels from your
 ; level 0 texture size
 (define t2 (load-texture "m0.png" (list 'generate-mipmaps 0 'mip-level 0)))
 (load-texture "m1.png" (list 'id t2 'generate-mipmaps 0 'mip-level 1))
 (load-texture "m2.png" (list 'id t2 'generate-mipmaps 0 'mip-level 2))
 (load-texture "m3.png" (list 'id t2 'generate-mipmaps 0 'mip-level 3))
 (texture (load-texture "mytexture.png"
        (list
          'generate-mipmaps 0  ; turn mipmapping off
              'border 2)))          ; add a border to the texture

 (build-cube) ; the cube will be texture mapped with the image

(clear-texture-cache)

Returns void

Clears the texture cache, meaning changed textures on disk are reloaded.

Example

 (clear-texture-cache)

(frustum left-number right-number bottom-number top-number)

Returns void

Sets the camera frustum, and thus the aspect ratio of the frame.

Example

 (frustum -1 1 -0.75 0.75) ; default settings

(clip front-number back-number)

Returns void

Sets the front & back clipping planes for the camera frustum, and thus the viewing angle. Change the front clipping distance to alter the perspective from telephoto to fisheye.

Example

 (clip 1 10000) ; default settings

(ortho)

Returns void

Sets orthographic projection - i.e. no perspective.

Example

 (ortho)

(persp)

Returns void

Sets perspective projection (the default) after ortho has been set.

Example

 (persp)

(set-ortho-zoom amount-number)

Returns void

Sets the zoom level for the orthographic projection.

Example

 (set-ortho-zoom 2)

(clear-colour colour-vector)

Returns void

Sets the colour we clear the renderer with, this forms the background colour for the scene.

Example

 (clear-colour (vector 1 0 0)) ; RED!!!

(clear-frame setting-number)

Returns void

Sets the frame clearing on or off.

Example

 (clear-frame 0)
 (clear-frame 1)

(clear-zbuffer setting-number)

Returns void

Sets the zbuffer clearing on or off.

Example

 (clear-zbuffer 0)
 (clear-zbuffer 1)

(clear-accum setting-number)

Returns void

Sets the accumulation buffer clearing on or off.

Example

 (clear-accum 1)

(build-camera)

Returns cameraid-number

Adds a new camera/view and returns it's id

Example

 (clear)
 (viewport 0 0.5 0.5 0.5)

 (define cam2 (build-camera))
 (current-camera cam2)
 (viewport 0.5 0 0.5 1)

 (define cam3 (build-camera))
 (current-camera cam3)
 (set-camera (mmul (mtranslate (vector 0 0 -5))
         (mrotate (vector 0 45 0))))
 (viewport 0 0 0.5 0.5)

 ; render a primitive in one view only
 (define t (with-state
     (translate (vector 3 0 0))
     (scale 0.3)
     (colour (vector 1 0 0))
     (build-torus 1 2 10 10)))

 (with-primitive t
     (hide 1) ; hide in all
     (camera-hide 0)) ; unhide in current camera


 (current-camera 0)

 (define c (with-state
         (hint-cull-ccw)
         (hint-unlit)
         (hint-wire)
         (line-width 2)
         (colour (vector 0.4 0.3 0.2))
         (wire-colour (vector 0 0 0))
         (scale 10)
         (build-cube)))

 (define p (with-state
         (scale 3)
         (load-primitive "widget.obj")))

 (every-frame
     (with-primitive p
         (rotate (vector 0 1 0))))

(current-camera cameraid-number)

Returns void

Sets the current camera to use

Example

 (clear)
 (viewport 0 0.5 0.5 0.5)

 (define cam2 (build-camera))
 (current-camera cam2)
 (viewport 0.5 0 0.5 1)

 (define cam3 (build-camera))
 (current-camera cam3)
 (set-camera (mmul (mtranslate (vector 0 0 -5))
         (mrotate (vector 0 45 0))))
 (viewport 0 0 0.5 0.5)

 ; render a primitive in one view only
 (define t (with-state
     (translate (vector 3 0 0))
     (scale 0.3)
     (colour (vector 1 0 0))
     (build-torus 1 2 10 10)))

 (with-primitive t
     (hide 1) ; hide in all
     (camera-hide 0)) ; unhide in current camera


 (current-camera 0)

 (define c (with-state
         (hint-cull-ccw)
         (hint-unlit)
         (hint-wire)
         (line-width 2)
         (colour (vector 0.4 0.3 0.2))
         (wire-colour (vector 0 0 0))
         (scale 10)
         (build-cube)))

 (define p (with-state
         (scale 3)
         (load-primitive "widget.obj")))

 (every-frame
     (with-primitive p
         (rotate (vector 0 1 0))))

(viewport x-number y-number width-number height-number)

Returns void

Sets the viewport on the current camera. This is the area of the window the camera renders to, where 0,0 is the bottom left and 1,1 is the top right.

Example

 (clear)
 (viewport 0 0.5 0.5 0.5)

 (define cam2 (build-camera))
 (current-camera cam2)
 (viewport 0.5 0 0.5 1)

 (define cam3 (build-camera))
 (current-camera cam3)
 (set-camera (mmul (mtranslate (vector 0 0 -5))
         (mrotate (vector 0 45 0))))
 (viewport 0 0 0.5 0.5)

 ; render a primitive in one view only
 (define t (with-state
     (translate (vector 3 0 0))
     (scale 0.3)
     (colour (vector 1 0 0))
     (build-torus 1 2 10 10)))

 (with-primitive t
     (hide 1) ; hide in all
     (camera-hide 0)) ; unhide in current camera


 (current-camera 0)

 (define c (with-state
         (hint-cull-ccw)
         (hint-unlit)
         (hint-wire)
         (line-width 2)
         (colour (vector 0.4 0.3 0.2))
         (wire-colour (vector 0 0 0))
         (scale 10)
         (build-cube)))

 (define p (with-state
         (scale 3)
         (load-primitive "widget.obj")))

 (every-frame
     (with-primitive p
         (rotate (vector 0 1 0))))

(get-camera)

Returns matrix-vector

Gets the current camera transform matrix. This is the low level function, use get-camera-transform instead.

Example

 (get-camera)

(get-locked-matrix)

Returns matrix-vector

Gets the current camera lock transform matrix. Takes the lag into account

Example

 (get-locked-matrix)

(set-camera)

Returns void

Sets the camera transform matrix. This is the low level interface used by set-camera-transform, which you should generally use instead.

Example

 (set-camera (mtranslate (vector 0 0 -10)))

(get-projection-transform)

Returns projection-matrix

Gets the current projection matrix.

Example

 (get-projection-transform)

(set-projection-transform matrix-vector)

Returns void

Sets the projection matrix directly.

Example

 (set-projection-transform (vector 1 0 0 0 0 4/3 0 0 0 0 -1 -1 0 0 -2 -0))

(get-screen-size)

Returns size-vector

Returns a vector containing the current width and height of the window.

Example

 (get-screen-size)

(set-screen-size size-vector)

Returns void

Sets the window width and height.

Example

 (set-screen-size (vector 10 10)) ; small window time :)
 (set-screen-size (vector 720 576)) ; and back again!

(select screenxpos-number screenypos-number pixelssize-number)

Returns primitiveid-number

Looks in the region specified and returns the id of the closest primitive to the camera rendered there, or 0 if none exist.

Example

 (display (select 10 10 2))(newline)

(select-all screenxpos-number screenypos-number pixelssize-number)

Returns list of primitiveid-numbers

Looks in the region specified and returns all ids rendered there in a list, or '() if none exist.

Example

 (display (select-all 10 10 2))(newline)

(desiredfps fps-number)

Returns void

Throttles the renderer so as to not take 100% cpu. This gives an upper limit on the fps rate, which doesn't quite match the given number, but I'm working on it...

Example

 (desiredfps 100000) ; makes fluxus render as fast as it can, and take 100% cpu.

(draw-buffer buffer_name)

Returns void

Select which buffer to draw in for stereo mode you'd do 'back-right and 'back-left

Example

 (draw-buffer 'back)

(read-buffer buffer_name)

Returns void

Select which buffer to read from

Example

 (read-buffer 'back)

(set-stereo-mode mode)

Returns bool

select which stereo mode to use currently only 'crystal-eyes and 'no-stereo are supported the return indicates if the operation was successful or not 'crystal-eyes will return false if you don't have a stereo window

Example

 (set-stereo-mode 'crystal-eyes)

(set-colour-mask vector)

Returns void

sets the colour mask give it a quat of booleans which correspond to the red, green, blue and alpha channels respectively after this operation you'll only see those colour which you set to true (this is useful for stereo with red-blue glasses)

Example

 (set-colour-mask #(#t #f #f #t))

(shadow-light number-setting)

Returns void

Sets the light to use for generating shadows, set to 0 to disable shadow rendering.

Example

 (shadow-light 1)

(shadow-length number-setting)

Returns void

Sets the length of the shadow volume rendering.

Example

 (shadow-length 10)

(shadow-debug number-setting)

Returns void

Turns on debug rendering of the shadow volume rendering.

Example

 (shadow-debug 1)

(accum mode-symbol value-number)

Returns void

Controls the accumulation buffer (just calls glAccum under the hood). Possible symbols are: accum load return add mult

Example

 (accum 'add 1)

(print-info)

Returns void

Prints out a load of renderer information

Example

 (print-info)

(set-cursor image-name-symbol)

Returns void

Changes the mouse cursor. Cursor image name symbols can consist of: 'right-arrow, 'left-arrow, 'info, 'destroy, 'help, 'cycle, 'spray, 'wait, 'text, 'crosshair, 'up-down, 'left-right, 'top-side, 'bottom-side, 'left-side, 'right-side, 'top-left-corner, 'top-right-corner, 'bottom-right-corner, 'bottom-left-corner, 'full-crosshair, 'none, 'inherit The default cursor image symbol when the window is created is 'inherit.

Example

 (set-cursor 'crosshair)

(set-full-screen)

Returns void

Requests that the current fluxus window be made full screen.

Example

 (set-full-screen)