Version: | 0.1.11 |
---|---|
Date: | 2011-02-23 |
Boron-GL extends the Boron scripting language with datatypes and functions for working with OpenGL 2.1.
Features include:
- Garbage collected GL datatypes.
- Texture-based fonts loaded from TrueType files.
- Loading PNG images.
- Plays audio from WAV and OGG formats.
This manual is largely incomplete.
There is a separate function reference available online at http://urlan.sourceforge.net/boron.
The first line of a script may be a UNIX shell sha-bang (#!) command.
#!/usr/bin/boron-gl
Usage:
boron-gl [options] [script] [arguments]
-a | Disable audio |
-e "exp" | Evaluate expression |
-h | Show help and exit |
-s | Disable security |
If the interpreter is invoked with a script then the args word will be set to either a block of strings, or none if no script arguments were given.
So this command:
boron-gl -e "probe args" file1 -p 2
Will print this:
["file1" "-p" "2"]
Type Name | Description |
---|---|
draw-prog! | Compiled draw program |
raster! | Pixel image in main memory |
texture! | OpenGL texture |
font! | Texture-based font |
shader! | OpenGL shader |
fbo! | OpenGL frame buffer object |
vbo! | OpenGL vertex buffer object |
quat! | Quaternion |
widget! | Widget |
A draw program is a list of display operations compiled to byte-code. It is reminiscent of the GL display list (now deprecated in OpenGL 3.0).
Note
The terms "draw program" and "draw list" are used interchangeably.
The simplest way to make textures is to use the load-texture function.
load-texture %skin.png
Full specification:
make texture! [ raster!/coord!/int! binary! 'mipmap 'nearest 'linear 'repeat 'clamp 'gray 'rgb' 'rgba ]
A texture-based font.
make font! [%font-file.ttf 20] make font! [%font-file.ttf 20 "characters" 256,128] make font! [raster! binary!] make font! [texture! binary!]
make shader! [ vertex {...} fragment {...} default [] ]
A framebuffer object is a render target.
Vertex buffers hold arrays of geometry vertex attributes.
A unit-length quaternion.
Multiply a quat! by -1.0 to conjugate (invert) it. Multiplying a quat! by a vec3! will return a transformed vec3!.
Examples quaternions:
to-quat none ; Identity to-quat 10,0,240 ; From euler x,y,z angles
In addition to the following instructions, any paren! value will be evaluated as Boron code at that point in the draw list.
Some instructions accept a get-word! argument. When this is used, the word value is read each time program is run rather than using a fixed value.
Draws a box given minimum and maximum extents. Internally, a vertex buffer with normals & texture coordinates is created.
box vec3! vec3!
Sets the blending mode using glBlendFunc.
blend on/off/add/burn/trans
Mode | Function |
---|---|
on | glEnable( GL_BLEND ) |
off | glDisable( GL_BLEND ) |
add | glBlendFunc( GL_SRC_ALPHA, GL_ONE ) |
burn | glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) |
trans | glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) |
Calls glBindBuffer and sets pointer offsets using glVertexPointer, glNormalPointer, etc.
Sets the camera context. glViewport is called and the GL_PROJECTION and GL_MODELVIEW matrices are set.
camera context!
Calling a none! value does nothing and can be used to disable the display of an item.
call none!/draw-prog!/widget! call get-word!
Sets the gl_Color for shaders.
color int!/coord!/vec3! color get-word!
The following all set the color to red:
color 0xff0000 color 255,0,0 color 1.0,0.0,0.0
Sets the font for text instructions. This only provides the glyph metrics needed to generate quads; it does not actually emit any data into the compiled draw-prog. The shader instruction must be used to specify the texture.
font font!
Display image at 1:1 texel to pixel scale. An optional X,Y position can be specified.
image texture! image coord!/vec3! texture!
Controls lights.
Calls glPopMatrix.
point-size on/off
point-sprite on/off
Calls glPushMatrix.
Rotate around axis or by quaternion.
rotate x/y/z decimal! rotate x/y/z get-word! rotate get-word!
scale decimal! scale get-word!
Calls glUseProgram, binds and enables any textures used, and calls glUniform for any variables.
shader shader!
Draws a sphere. Internally, a vertex buffer with normals & texture coordinates is created.
sphere radius slices,stacks
translate get-word!
Calls glBindFramebuffer().