jit.gl.render Render Open GL

The jit.gl.render object requires a single argument -- a name that will be attached to its OpenGL context. The OpenGL drawing can be sent to any named jit.window, jit.pwindow or jit.matrix object. Use the drawto destination message to change the destination on which the drawing results will be visible. When drawing to a jit.matrix object, the matrix must be sent to a pwindow or otherwise made visible in order to view the drawing.

There are two ways of drawing things with jit.gl.render: creating Jitter OpenGL objects such as the jit.gl.plato object, and sending drawing commands directly to the jit.gl.render object. When you create new jit.gl objects, they appear automatically in the OpenGL scene and are redrawn each time a bang is sent to the jit.gl.render object. This provides an easy way to begin drawing 3D scenes. When you use drawing commands directly to a jit.gl.render object, you must create a patch which sends the desired sequence of drawing messages for each frame. This method of drawing offers lots of flexibility.

The most commonly used drawing command is jit_matrix. Matrices sent using this command are drawn as 2D or 3D geometry, according to the currently set graphics primitive or one set explicitly in the command. Other drawing commands include draw_pixels, which draws the matrix contents as a 2D picture, and test, which draw standard SMPTE color bars.

OpenGL is a standard for 3D drawing based on a complex virtual machine with commands for viewing, lighting, texturing, 2D imaging, and frame buffer control. A full discussion of OpenGL is beyond the scope of this reference. A valuable starter reference is the OpenGL "Red Book". please see www.opengl.org for more information.

GL Group

Attributes:
Name Type Description
camera float list[3] The camera position in 3D space (default = 0. 0. 2.) Camera position is specified as a set of floating point numbers that correspond to a camera position with respect to the x, y, and z axes.
erase_color float list[4] Color and opacity with which image is overdrawn on receipt of erase message in the form red green blue opacity (default = 0. 0. 0. 1. (opaque black)) All values should be in the range 0.-1.
far_clip float The far clipping plane distance in 3D world (default = 100.)
geom_rows int Vertex connection mode (default = 0 (connect along columns))
0 = connect vertices in 2D geometry matrix along columns
1 = connect vertices in 2D geometry matrix along rows
lens_angle float The lens angle of the OpenGL camera (default = 45.)
light_ambient float list[4] The color and opacity of the ambient light component in the form red green blue opacity (default = 0. 0. 0. 1. (opaque black)) All values should be in the range 0.-1.
light_diffuse float list[4] The color and opacity of the diffuse light component in the form red green blue opacity (default = 1. 1. 1. 1. (opaque white)) All values should be in the range 0.-1.
light_global_ambient float list[4] The color and opacity of the global ambient light component in the form red green blue opacity (default = 0.2 0.2 0.2 1.) All values should be in the range 0.-1.
light_position float list[4] The position of the light source in XYZ coordinates and the light type (default = 1. 1. 1. 0.)
When the last number is 0., t The light is treated as a directional source if 0. is the final number. Otherwise, diffuse and specular lighting calculations are based on the actual location of the light in eye coordinates, and attenuation is enabled.
light_specular float list[4] Color and opacity of specular light component (default = 1. 1. 1. 1. (opaque white)) The first three floats in the range 0.-1. specify the RGB components of the specular light color. The fourth float (also in the range 0.-1.) specifies opacity.
lookat float list[3] 3D position at which the camera is pointed (default = 0. 0. 0.)
near_clip float The near clipping plane distance in 3D world (default = 0.1)
primitive symbol The currentg drawing primitive (default = tri_grid)
quality int Quality flag when using software renderer (default = 0). (Mac only) Slower than normal SW renderer, but supports larger rendering, shaders, and other advanced features.
up float list[3] The 3D vector towards which the top of the camera points (default = 0. 1. 0.)

Messages:
deletetexture [texture-name (symbol)]
Followed by a texture name, delete the named texture.

draw_pixels
Followed by a jit.matrix, draw the matrix data as a 2D image filling the screen.

drawto [destination (symbol)]
Select the drawing destination for output. Must be a named jit.window, jit.pwindow or jit.matrix.

erase
Overwrites the image buffer with the color and opacity selected by the erase_color attribute.

interp [0/1 (int)]
Toggles interpolation for the currently selected named texture (default = 0)

jit_matrix
Draw the geometry specified in the matrix. The matrix can have up to 13 planes. The planes are divided into groups representing different vector data. If enough planes are present to complete a group, that group is used in drawing the geometry. The order of groups is: vertex(xyz), texture coordinate(st), normal(uvw), color(rgba), and edge flag(e). Here is how matrices are interpreted according to number of planes:
2 planes: vertex(xy)
3-4 planes: vertex(xyz)
5-7 planes: vertex(xyz), texture coordinate(st)
8-11 planes: vertex(xyz), texture coordinate(st), normal(uvw)
12 planes: vertex(xyz), texture coordinate(st), normal(uvw), color(rgba)
13 planes: vertex(xyz), texture coordinate(st), normal(uvw), color(rgba), edge flag(e)

line_loop
Sets the draw primitive to draw the matrix geometry as a loop of lines connecting each vertex and then returning to the first.

line_strip
Sets the draw primitive to draw the matrix geometry as a strip of lines connecting each vertex.

lines
Sets the draw primitive to draw the matrix geometry as unconnected lines between each pair of vertices.

points
Sets the draw primitive to draw the matrix geometry as points.

polygon
Sets the draw primitive to draw the matrix geometry as vertices of one simple polygon.

quad_grid
Sets the draw primitive to draw the matrix geometry as a grid connecting neighboring matrix elements. Each vertex in the matrix is connected to the vertices next to it in the x and y directions. Each square of vertices ((x,y), (x+1,y), (x,y+1),(x+1,y+1)) is then drawn as one quadrilateral.

quad_strip
Sets the draw primitive to draw the matrix geometry as a strip of connected quadrilaterals.

quads
Sets the draw primitive to draw the matrix geometry as unconnected quadrilaterals.

swap
Copy the rendered image to the destination jit.window, jit.pwindow or jit.matrix.

test
Draws a set of SMPTE standard color bars to the output.

texture [texture-name (symbol)]
Create or replace a named texture.
If the texture name is followed by the name of a jit.matrix object, create a texture containing the matrix data. if the texture already exists, replace its image data with the given matrix.
If the texture name is followed by dimensions (x y), a new texture is generated of the given dimension, and filled with a checkerboard pattern. If a texture already exists with the given name, the dimensions form of the message generates a warning and has no effect.

All texture sizes are rounded up the next-highest power of two in each dimension.

to_texture
Copy the previously drawn frame to the named texture. Useful for feedback effects.

tri_fan
Sets the draw primitive to draw the matrix geometry as a fan of connected triangles.

tri_grid
Sets the draw primitive to draw the matrix geometry as a grid connecting neighboring matrix elements. Each vertex in the matrix is connected to the vertices next to it in the x and y directions. Each square of vertices ((x,y), (x+1,y), (x,y+1),(x+1,y+1)) is then drawn as two triangles.

tri_strip
Sets the draw primitive to draw the matrix geometry as a strip of connected triangles.

triangles
Sets the draw primitive to draw the matrix geometry as unconnected triangles.

usetexture [texture-name (symbol)]
Use the named texture for drawing primitives.

sendtexture [message (list)]
Sends the internal jit.gl.texture object, currently selected with the usetexture method, the corresponding message.

Example:

See Also:
jit.gl.graph, jit.gl.gridshape, jit.gl.handle, jit.gl.isosurf, jit.gl.mesh, jit.gl.model, jit.gl.nurbs, jit.gl.plato, jit.gl.shader, jit.gl.sketch, jit.gl.slab, jit.gl.text2d, jit.gl.text3d, jit.gl.texture, jit.gl.videoplane, jit.gl.volume