GLClient - An OpenGL solution for REBOL

Updated: 29-Jun-2008
Author: John Niclasen

Contents:

1. Client/Server
1.1 GLClient
1.2 GLServer
2. OpenGL Commands
2.1 Restrictions
2.2 Primitives
2.3 Coordinate Transformation
2.4 Coloring and Lighting
2.5 Rasterization
2.6 Pixel Operations
2.7 Texture Mapping
2.8 Fog
2.9 Frame Buffer Operations
2.10 Evaluators
2.11 Selection and Feedback
2.12 Display Lists
2.13 Modes and Execution
2.14 State Queries
2.15 Polygon Offset
2.16 Vertex Array
3. GLU Routines
3.1 Restrictions
3.2 Texture Images
3.3 Coordinate Transformation
3.4 Quadric Objects
3.5 NURBS Curves and Surfaces
4. GLUT Routines
4.1 Restrictions
4.2 Initialization
4.3 Beginning Event Processing
4.4 Window Management
4.5 Menu Management
4.6 Callback Registration
4.7 Game Oriented
4.8 State Retrieval
4.9 Font Rendering
4.10 Geometric Object Rendering
5. GLSRV Routines
5.1 Restrictions
5.2 Texture Mapping
5.3 Data Loading
6. Examples
6.1 To run the examples
6.2 Hello World!
6.3 Lines
6.4 Icosahedron
6.5 Cube
6.6 Smooth
6.7 Torus
6.8 List
6.9 Light
6.10 Checker
6.11 AccPersp
6.12 BezCurve
6.13 BezSurf
6.14 BezMesh
6.15 TextureSurf
6.16 NURBS Surface
6.17 Select
6.18 PickSquare

1. Client/Server

This OpenGL solution for REBOL uses a client/server approach. The OpenGL API written in REBOL is the client, and it communicate with a server program written in C, which will execute the OpenGL commands. The communication is done using a protocol over TCP.

The client and server tasks can be on the same computer or on different computers.

So far, the server task is available for Mac OS X and MS Windows (Win32).

1.1 GLClient

The client task is a REBOL program, which include the GLClient.r script. One of the first things, this script does, is to open a communication port to the server task. If the default port can't be opened, it'll ask for one.

Any TCP port can be choosen.

Get the GLClient here: GLClient.r

1.2 GLServer

The server task is a C executable, and it is started by the client. Make sure, the GLServer executable is somewhere in the path, so it can be found. Put it in e.g.: /usr/local/bin/ (if you run OS X).

1.2.1 Mac OS X

The server executable for Mac OS X (right-click to download): GLServer

1.2.2 Win32

The server executable for Win32 (right-click to download): GLServer.exe

2. OpenGL Commands

Sources for further documentation of OpenGL, GLU and GLUT are:

2.1 Restrictions

Some OpenGL commands take double precision floating points as their parameters. So far only single precision floats are sent to the commands. Benefit is, that less traffic is needed.

So far, the following commands are supported by the API:

2.2 Primitives

glBegin - delimit the vertices of a primitive or a group of like primitives
glEnd - delimit the vertices of a primitive or a group of like primitives
glVertex2f - specify a vertex
glVertex3f, glVertex3fv - specify a vertex
glRecti - draw a rectangle

2.3 Coordinate Transformation

glRotatef - multiply the current matrix by a rotation matrix
glTranslatef - multiply the current matrix by a translation matrix
glScalef - multiply the current matrix by a general scaling matrix
glFrustum - multiply the current matrix by a perspective matrix
glOrtho - multiply the current matrix with an orthographic matrix
glLoadIdentity - replace the current matrix with the identity matrix
glMatrixMode - specify which matrix is the current matrix
glPushMatrix - push and pop the current matrix stack
glPopMatrix - push and pop the current matrix stack
glViewport - set the viewport

2.4 Coloring and Lighting

glColor3f, glColor3fv, glColor3ub - set the current color
glColor4f, glColor4fv, glColor4ub - set the current color and alpha
glNormal3f - set the current normal vector
glLightf, glLightfv - set light source parameters
glMaterialf, glMaterialfv - specify material parameters for the lighting model
glLightModeli, glLightModelfv - set the lighting model parameters
glShadeModel - select flat or smooth shading
glColorMaterial - cause a material color to track the current color

2.5 Rasterization

glRasterPos2f, glRasterPos2i - specify the raster position for pixel operations
glPointSize - specify the diameter of rasterized points
glLineWidth - specify the width of rasterized lines
glLineStipple - specify the line stipple pattern
glCullFace - specify whether front- or back-facing facets can be culled
glPolygonMode - select a polygon rasterization mode

2.6 Pixel Operations

glPixelStorei(, glPixelStoref) - set pixel storage modes

2.7 Texture Mapping

glTexParameterf, glTexParameteri, glTexParameterfv - set texture parameters
glTexEnvi, glTexEnvf, glTexEnvfv - set texture environment parameters
glTexCoord2f, glTexCoord3f - set the current texture coordinates
glTexGeni - control the generation of texture coordinates
glTexImage2D - specify a two-dimensional texture image
glBindTexture - bind a named texture to a texturing target
glGenTextures - generate texture names

2.8 Fog

glFogf, glFogi, glFogfv - specify fog parameters

2.9 Frame Buffer Operations

glDepthFunc - specify the value used for depth buffer comparisons
glBlendFunc - specify pixel arithmetic
glClear - clear buffers to preset values
glClearAccum - specify clear values for the accumulation buffer
glClearColor - specify clear values for the color buffers
glClearDepth - specify the clear value for the depth buffer
glAccum - operate on the accumulation buffer

2.10 Evaluators

glMap1f - define a one-dimensional evaluator
glMap2f - define a two-dimensional evaluator
glMapGrid2f - define a one- or two-dimensional mesh
glEvalMesh2 - compute a one- or two-dimensional grid of points or lines
glEvalCoord1f - evaluate enabled one- and two-dimensional maps
glEvalCoord2f - evaluate enabled one- and two-dimensional maps

2.11 Selection and Feedback

glRenderMode - set rasterization mode
glSelectBuffer - establish a buffer for selection mode values
glInitNames - initialize the name stack
glLoadName - load a name onto the name stack
glPushName - push and pop the name stack
glPopName - push and pop the name stack

2.12 Display Lists

glNewList - create or replace a display list
glEndList - end a display list
glCallList - execute a display list
glCallLists - execute a list of display lists
glGenLists - generate a contiguous set of empty display lists

2.13 Modes and Execution

glEnable - enable server-side GL capabilities
glDisable - disable server-side GL capabilities
glFinish - block until all GL execution is complete
glFlush - force execution of GL commands in finite time
glHint - specify implementation-specific hints

2.14 State Queries

glGetError - return error information
glGetIntegerv - return the value or values of a selected parameter

2.15 Polygon Offset

glPolygonOffset - set the scale and units used to calculate depth values

2.16 Vertex Array

glDrawElements - render primitives from array data
glInterleavedArrays - simultaneously specify and enable several interleaved arrays

3. GLU Routines

3.1 Restrictions

  • It's possible to create 256 Quadric Objects with the GLU functions.
  • It's possible to create 256 NURBS with the GLU functions.

So far, the following commands are supported by the API:

3.2 Texture Images

gluBuild2DMipmaps - builds a two-dimensional mipmap

3.3 Coordinate Transformation

gluOrtho2D - define a 2D orthographic projection matrix
gluPerspective - set up a perspective projection matrix
gluPickMatrix - define a picking region
gluLookAt - define a viewing transformation

3.4 Quadric Objects

gluNewQuadric - create a quadrics object
gluQuadricNormals - specify what kind of normals are desired for quadrics
gluQuadricTexture - specify if texturing is desired for quadrics
gluCylinder - draw a cylinder
gluDisk - draw a disk
gluPartialDisk - draw an arc of a disk
gluSphere - draw a sphere

3.5 NURBS Curves and Surfaces

gluNewNurbsRenderer - create a NURBS object
gluBeginSurface - delimit a NURBS surface definition
gluEndSurface - delimit a NURBS surface definition
gluNurbsSurface - define the shape of a NURBS surface
gluNurbsProperty - set a NURBS property

4. GLUT Routines

4.1 Restrictions

There is a limit of 32 characters in the names of the functions passsed to these commands:

  • glutDisplayFunc
  • glutIdleFunc
  • glutKeyboardFunc
  • glutMotionFunc
  • glutMouseFunc
  • glutPassiveMotionFunc
  • glutReshapeFunc
  • glutSpecialFunc
  • glutTimerFunc
  • glutVisibilityFunc

The function:
glutInit - initialize the GLUT library
is always called as the first thing by the server program, GLServer. So it's not necessary to include in the REBOL program.

So far, the following commands are supported by the API:

4.2 Initialization

glutInitDisplayMode - sets the initial display mode
glutInitWindowSize - set the initial window size
glutInitWindowPosition - set the initial window position

4.3 Beginning Event Processing

glutMainLoop - enters the GLUT event processing loop

4.4 Window Management

glutCreateWindow - creates a top-level window
glutDestroyWindow - destroys the specified window
glutPostRedisplay - marks the current or specified window as needing to be redisplayed
glutSwapBuffers - swaps the buffers of the current window if double buffered
glutReshapeWindow - requests a change to the size of the current window
glutFullScreen - requests that the current window be made full screen
glutSetWindowTitle - change the window title of the current top-level window

4.5 Menu Management

glutCreateMenu - creates a new pop-up menu
glutSetMenu - set the current menu
glutAddMenuEntry - adds a menu entry to the bottom of the current menu
glutAddSubMenu - adds a sub-menu trigger to the bottom of the current menu
glutAttachMenu, glutDetachMenu - attaches/detaches a mouse button for the current window to the identifier of the current menu

4.6 Callback Registration

glutDisplayFunc - sets the display callback for the current window
glutReshapeFunc - sets the reshape callback for the current window
glutKeyboardFunc - sets the keyboard callback for the current window
glutMouseFunc - sets the mouse callback for the current window
glutMotionFunc - set the motion callback for the current window
glutPassiveMotionFunc - set the passive motion callback for the current window
glutVisibilityFunc - sets the visibility callback for the current window
glutSpecialFunc - sets the special keyboard callback for the current window
glutIdleFunc - sets the global idle callback
glutTimerFunc - registers a timer callback to be triggered in a specified number of milliseconds

4.7 Game Oriented

glutGameModeString - sets the game mode configuration via a string
glutEnterGameMode - enters GLUT's game mode
glutLeaveGameMode - leaves GLUT's game mode
glutGameModeGet - retrieves GLUT game mode information represented by integers
glutSetKeyRepeat - sets the key repeat mode
glutIgnoreKeyRepeat - determines if auto repeat keystrokes are reported to the current window
glutKeyboardUpFunc - sets the keyboard up (key release) callback for the current window
glutSpecialUpFunc - sets the special keyboard up (key release) callback for the current window

4.8 State Retrieval

glutGetModifiers - returns the modifier key state when certain callbacks were generated

4.9 Font Rendering

glutBitmapCharacter - renders a bitmap character using OpenGL

4.10 Geometric Object Rendering

glutSolidSphere - render a solid sphere
glutWireSphere - render a wireframe sphere
glutSolidCube - render a solid cube
glutWireCube - render a wireframe cube
glutSolidCone - render a solid cone
glutWireCone - render a wireframe cone
glutSolidTorus - render a solid torus (doughnut)
glutWireTorus - render a wireframe torus (doughnut)
glutSolidDodecahedron - render a solid dodecahedron (12-sided regular solid)
glutWireDodecahedron - render a wireframe dodecahedron (12-sided regular solid)
glutSolidOctahedron - render a solid octahedron (8-sided regular solid)
glutWireOctahedron - render a wireframe octahedron (8-sided regular solid)
glutSolidTetrahedron - render a solid tetrahedron (4-sided regular solid)
glutWireTetrahedron - render a wireframe tetrahedron (4-sided regular solid)
glutSolidIcosahedron - render a solid icosahedron (20-sided regular solid)
glutWireIcosahedron - render a wireframe icosahedron (20-sided regular solid)
glutSolidTeapot - render a solid teapot
glutWireTeapot - render a wireframe teapot

5. GLSRV Routines

5.1 Restrictions

It's possible to load 256 images with the GLSRV functions.

5.2 Texture Mapping

glsrvRAWLoad2D - load a 2D raw texture into GLServer
glsrvTexLoad2D - load a 2D texture into GLServer

5.3 Data Loading

glsrvLoad - load data into GLServer and return unique integer

6. Examples

The following examples are taken from the "OpenGL Programming Guide" or 'The Red Book'. The examples are here to show, how some OpenGL programs using GLUT and programmed in C will look as REBOL programs.

6.1 To run the examples

One way is to:

  • Get the GLServer, and put it in the path, e.g.: /usr/local/bin/
  • DO the example REBOL script from a REBOL prompt

Use the links to "REBOL source" below each image of the examples. Right-click the link and choose "Copy Link". Then go to your REBOL prompt and type:
>> do
followed by a space and then paste the link to the example.

You can also get GLClient.r and change the examples to do your GLClient.r locally.

6.2 Hello World!

This example draws a white square on a black background.
From "Chapter 1: Introduction to OpenGL" in 'The Red Book'.

examples/hello.png

REBOL source: hello.r

6.2.1 C Source

#include <GLUT/glut.h>

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);

glColor3f (1.0, 1.0, 1.0);
glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd ();

glFlush ();
}

void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);

glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main (int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc (display);
glutMainLoop ();
return 0;
}

6.2.2 REBOL Source

do %GLClient.r

display: does [
glClear GL_COLOR_BUFFER_BIT

glColor3f 1.0 1.0 1.0
glBegin GL_POLYGON
glVertex3f 0.25 0.25 0.0
glVertex3f 0.75 0.25 0.0
glVertex3f 0.75 0.75 0.0
glVertex3f 0.25 0.75 0.0
glEnd

glFlush
]

init: does [
glClearColor 0.0 0.0 0.0 0.0

glMatrixMode GL_PROJECTION
glLoadIdentity
glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGB
glutInitWindowSize 250 250
glutInitWindowPosition 100 100
glutCreateWindow "hello"
init
glutDisplayFunc 'display
glutMainLoop

6.3 Lines

Dotted and dashed lines.
From "Chapter 2: State Management and Drawing Geometric Objects" in 'The Red Book'.

examples/lines.png

REBOL source: lines.r

6.3.1 C Source

#include "GLUT/GLUT.h"

#define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \
glVertex2f ((x1),(y1)); glVertex2f ((x2),(y2)); glEnd();

void myinit (void) {
/* background to be cleared to black */
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}

void display(void)
{
int i;

glClear (GL_COLOR_BUFFER_BIT);
/* draw all lines in white */
glColor3f (1.0, 1.0, 1.0);


/* in 1st row, 3 lines, each with a different stipple */
glEnable (GL_LINE_STIPPLE);
glLineStipple (1, 0x0101); /* dotted */
drawOneLine (50.0, 125.0, 150.0, 125.0);
glLineStipple (1, 0x00FF); /* dashed */
drawOneLine (150.0, 125.0, 250.0, 125.0);
glLineStipple (1, 0x1C47); /* dash/dot/dash */
drawOneLine (250.0, 125.0, 350.0, 125.0);

/* in 2nd row, 3 wide lines, each with different stipple */
glLineWidth (5.0);
glLineStipple (1, 0x0101);
drawOneLine (50.0, 100.0, 150.0, 100.0);
glLineStipple (1, 0x00FF);
drawOneLine (150.0, 100.0, 250.0, 100.0);
glLineStipple (1, 0x1C47);
drawOneLine (250.0, 100.0, 350.0, 100.0);
glLineWidth (1.0);

/* in 3rd row, 6 lines, with dash/dot/dash stipple, */
/* as part of a single connected line strip */
glLineStipple (1, 0x1C47);
glBegin (GL_LINE_STRIP);
for (i = 0; i < 7; i++)
glVertex2f (50.0 + ((GLfloat) i * 50.0), 75.0);
glEnd ();

/* in 4th row, 6 independent lines, */
/* with dash/dot/dash stipple */
for (i = 0; i < 6; i++) {
drawOneLine (50.0 + ((GLfloat) i * 50.0),
50.0, 50.0 + ((GLfloat)(i+1) * 50.0), 50.0);
}

/* in 5th row, 1 line, with dash/dot/dash stipple */
/* and repeat factor of 5 */
glLineStipple (5, 0x1C47);
drawOneLine (50.0, 25.0, 350.0, 25.0);
glFlush ();
}


void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h);
}

int main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (400, 150);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
myinit ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;
}

6.3.2 REBOL Source

do %GLClient.r

drawOneLine: func [x1 y1 x2 y2] [
glBegin GL_LINES
glVertex2f x1 y1
glVertex2f x2 y2
glEnd
]

myinit: does [
; background to be cleared to black
glClearColor 0.0 0.0 0.0 0.0
glShadeModel GL_FLAT
]

display: does [
glClear GL_COLOR_BUFFER_BIT
; draw all lines in white
glColor3f 1.0 1.0 1.0


; in 1st row, 3 lines, each with a different stipple
glEnable GL_LINE_STIPPLE
glLineStipple 1 #{0101} ; dotted
drawOneLine 50.0 125.0 150.0 125.0
glLineStipple 1 #{00FF} ; dashed
drawOneLine 150.0 125.0 250.0 125.0
glLineStipple 1 #{1C47} ; dash/dot/dash
drawOneLine 250.0 125.0 350.0 125.0

; in 2nd row, 3 wide lines, each with different stipple
glLineWidth 5.0
glLineStipple 1 #{0101}
drawOneLine 50.0 100.0 150.0 100.0
glLineStipple 1 #{00FF}
drawOneLine 150.0 100.0 250.0 100.0
glLineStipple 1 #{1C47}
drawOneLine 250.0 100.0 350.0 100.0
glLineWidth 1.0

; in 3rd row, 6 lines, with dash/dot/dash stipple,
; as part of a single connected line strip
glLineStipple 1 #{1C47}
glBegin GL_LINE_STRIP
repeat i 7 [
glVertex2f i * 50.0 75.0
]
glEnd

; in 4th row, 6 independent lines,
; with dash/dot/dash stipple
repeat i 6 [
drawOneLine i * 50.0 50.0 i + 1 * 50.0 50.0
]

; in 5th row, 1 line, with dash/dot/dash stipple
; and repeat factor of 5
glLineStipple 5 #{1C47}
drawOneLine 50.0 25.0 350.0 25.0
glFlush
]

reshape: func [w h] [
glViewport 0 0 w h
glMatrixMode GL_PROJECTION
glLoadIdentity
gluOrtho2D 0.0 w 0.0 h
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGB
glutInitWindowSize 400 150
glutInitWindowPosition 100 100
glutCreateWindow "lines"
myinit
glutDisplayFunc 'display
glutReshapeFunc 'reshape
glutMainLoop

6.4 Icosahedron

A geometric shape called an icosahedron.
From "Chapter 2: State Management and Drawing Geometric Objects" in 'The Red Book'.

examples/icosahedron.png

REBOL source: icosahedron.r

6.4.1 C Source

#include <GLUT/glut.h>

#define X .525731112119133606
#define Z .850650808352039932

static GLfloat vdata[12][3] = {
{-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z},
{0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X},
{Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0}
};

static GLint tindices[20][3] = {
{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},
{8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3},
{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
{6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} };

void display(void)
{
int i;

glClear (GL_COLOR_BUFFER_BIT);

glColor3f (1.0, 1.0, 1.0);

for (i = 0; i < 20; i++) {
/* color information here */
glBegin(GL_TRIANGLES);
glVertex3fv(&vdata[tindices[i][0]][0]);
glVertex3fv(&vdata[tindices[i][1]][0]);
glVertex3fv(&vdata[tindices[i][2]][0]);
glEnd();
}

glFlush ();
}

void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);

glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
}

int main (int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Icosahedron");
init ();
glutDisplayFunc (display);
glutMainLoop ();
return 0;
}

6.4.2 REBOL Source

do %GLClient.r

X: .525731112119133606
Z: .850650808352039932

vdata: [
[(- X) 0.0 Z] [X 0.0 Z] [(- X) 0.0 (- Z)] [X 0.0 (- Z)]
[0.0 Z X] [0.0 Z (- X)] [0.0 (- Z) X] [0.0 (- Z) (- X)]
[Z X 0.0] [(- Z) X 0.0] [Z (- X) 0.0] [(- Z) (- X) 0.0]
]

tindices: [
[0 4 1] [0 9 4] [9 5 4] [4 5 8] [4 8 1]
[8 10 1] [8 3 10] [5 3 8] [5 2 3] [2 7 3]
[7 10 3] [7 6 10] [7 11 6] [11 0 6] [0 1 6]
[6 1 10] [9 0 11] [9 11 2] [9 2 5] [7 2 11]
]

display: does [
glClear GL_COLOR_BUFFER_BIT

glColor3f 1.0 1.0 1.0

repeat i 20 [
; color information here
glBegin GL_TRIANGLES
glVertex3fv vdata/(tindices/:i/1)
glVertex3fv vdata/(tindices/:i/2)
glVertex3fv vdata/(tindices/:i/3)
glEnd
]

glFlush
]

init: does [
glClearColor 0.0 0.0 0.0 0.0

glMatrixMode GL_PROJECTION
glLoadIdentity
glOrtho -1.0 1.0 -1.0 1.0 -1.0 1.0
glPolygonMode GL_FRONT_AND_BACK GL_LINE
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGB
glutInitWindowSize 250 250
glutInitWindowPosition 100 100
glutCreateWindow "Icosahedron"
init
glutDisplayFunc 'display
glutMainLoop

6.5 Cube

A scaled cube in perspective.
From "Chapter 3: Viewing" in 'The Red Book'.

examples/cube.png

REBOL source: cube.r

6.5.1 C Source

#include <GLUT/glut.h>

void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}

void display (void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity ();
gluLookAt (2.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
//glTranslatef (0.0, 0.0, -5.0);
glScalef (1.0, 2.0, 1.0);
glutWireCube (1.0);
glFlush ();
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
//gluPerspective (60.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
}

int main (int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;
}

6.5.2 REBOL Source

do %GLClient.r

init: does [
glClearColor 0.0 0.0 0.0 0.0
glShadeModel GL_FLAT
]

display: does [
glClear GL_COLOR_BUFFER_BIT
glColor3f 1.0 1.0 1.0
glLoadIdentity
gluLookAt 2.0 0.0 5.0 0.0 0.0 0.0 0.0 1.0 0.0
;glTranslatef 0.0 0.0 -5.0
glScalef 1.0 2.0 1.0
glutWireCube 1.0
glFlush
]

reshape: func [w h] [
glViewport 0 0 w h
glMatrixMode GL_PROJECTION
glLoadIdentity
glFrustum -1.0 1.0 -1.0 1.0 1.5 20.0
;gluPerspective 60.0 1.0 1.5 20.0
glMatrixMode GL_MODELVIEW
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGB
glutInitWindowSize 500 500
glutInitWindowPosition 100 100
glutCreateWindow "Cube"
init
glutDisplayFunc 'display
glutReshapeFunc 'reshape
glutMainLoop

6.6 Smooth

Smooth colors.
From "Chapter 4: Color" in 'The Red Book'.

examples/smooth.png

REBOL source: smooth.r

6.6.1 C Source

#include <GLUT/glut.h>

void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH); /* GL_SMOOTH is the default */
}

void triangle(void)
{
glBegin (GL_TRIANGLES);
glColor3f (1.0, 0.0, 0.0);
glVertex2f (5.0, 5.0);
glColor3f (0.0, 1.0, 0.0);
glVertex2f (25.0, 5.0);
glColor3f (0.0, 0.0, 1.0);
glVertex2f (5.0, 25.0);
glEnd ();
}

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
triangle ();
glFlush ();
}

void reshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
gluOrtho2D (0.0, 30.0, 0.0, 30.0 * (GLfloat) h/(GLfloat) w);
else
gluOrtho2D (0.0, 30.0 * (GLfloat) w/(GLfloat) h, 0.0, 30.0);
glMatrixMode(GL_MODELVIEW);
}


int main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Smooth");
init();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop();
return 0;
}

6.6.2 REBOL Source

do %GLClient.r

init: does [
glClearColor 0.0 0.0 0.0 0.0
glShadeModel GL_SMOOTH ; GL_SMOOTH is the default
]

triangle: does [
glBegin GL_TRIANGLES
glColor3f 1.0 0.0 0.0
glVertex2f 5.0 5.0
glColor3f 0.0 1.0 0.0
glVertex2f 25.0 5.0
glColor3f 0.0 0.0 1.0
glVertex2f 5.0 25.0
glEnd
]

display: does [
glClear GL_COLOR_BUFFER_BIT
triangle
glFlush
]

reshape: func [w h] [
glViewport 0 0 w h
glMatrixMode GL_PROJECTION
glLoadIdentity
either w <= h [
gluOrtho2D 0.0 30.0 0.0 30.0 * h / w
][
gluOrtho2D 0.0 30.0 * w / h 0.0 30.0
]
glMatrixMode GL_MODELVIEW
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGB
glutInitWindowSize 500 500
glutInitWindowPosition 100 100
glutCreateWindow "Smooth"
init
glutDisplayFunc 'display
glutReshapeFunc 'reshape
glutMainLoop

6.7 Torus

Another geometric shape called a torus. This example also shows the use of keyboard input. Use 'x' and 'y' to rotate the torus and 'i' to reset it. It's also possible to reshape the window.
From "Chapter 7: Display Lists" in 'The Red Book'.

examples/torus.png

REBOL source: torus.r

6.7.1 C Source

#include <GLUT/glut.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

GLuint theTorus;

static void torus (int numc, int numt)
{
int i, j, k;
double s, t, x, y, z, twopi;

twopi = 2 * (double)M_PI;
for (i=0; i<numc; i++)
{
glBegin (GL_QUAD_STRIP);
for (j=0; j<=numt; j++)
{
for (k=1; k>=0; k--)
{
s = (i+k) % numc + 0.5;
t = j % numt;

x = (1+.1*cos(s*twopi/numc))*cos(t*twopi/numt);
y = (1+.1*cos(s*twopi/numc))*sin(t*twopi/numt);
z = .1 * sin(s * twopi / numc);
glVertex3f (x, y, z);
}
}
glEnd ();
}
}

static void init (void)
{
theTorus = glGenLists (1);
glNewList (theTorus, GL_COMPILE);
torus (8, 25);
glEndList ();

glShadeModel (GL_FLAT);
glClearColor (0.0, 0.0, 0.0, 0.0);
}

void display (void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glCallList (theTorus);
glFlush ();
}

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (30, (GLfloat) w/(GLfloat) h, 1.0, 100.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
gluLookAt (0, 0, 10, 0, 0, 0, 0, 1, 0);
}

void keyboard (unsigned char key, int x, int y)
{
switch (key)
{
case 'x':
case 'X':
glRotatef (30., 1.0, 0.0, 0.0);
glutPostRedisplay ();
break;
case 'y':
case 'Y':
glRotatef (30., 0.0, 1.0, 0.0);
glutPostRedisplay ();
break;
case 'i':
case 'I':
glLoadIdentity ();
gluLookAt (0, 0, 10, 0, 0, 0, 0, 1, 0);
glutPostRedisplay ();
break;
case 27:
exit (0);
break;
}
}

int main (int argc, char **argv)
{
glutInitWindowSize (200, 200);
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutCreateWindow (argv[0]);
init ();
glutReshapeFunc (reshape);
glutKeyboardFunc (keyboard);
glutDisplayFunc (display);
glutMainLoop ();
return 0;
}

6.7.2 REBOL Source

do %GLClient.r

theTorus: none

torus: func [
numc [integer!]
numt [integer!]
/local s t x y z twopi
][
twopi: 2 * PI

for i 0 (numc - 1) 1 [
glBegin GL_QUAD_STRIP
for j 0 numt 1 [
for k 1 0 -1 [
s: (i + k) // numc + 0.5
t: j // numt

x: (1 + (.1 * cosine/radians (s * twopi / numc))) * cosine/radians (t * twopi / numt)
y: (1 + (.1 * cosine/radians (s * twopi / numc))) * sine/radians (t * twopi / numt)
z: .1 * sine/radians (s * twopi / numc)
glVertex3f x y z
]
]
glEnd
]
]

init: does [
theTorus: glGenLists 1
glNewList theTorus GL_COMPILE
torus 8 25
glEndList

glShadeModel GL_FLAT
glClearColor 0.0 0.0 0.0 0.0
]

display: does [
glClear GL_COLOR_BUFFER_BIT
glColor3f 1.0 1.0 1.0
glCallList theTorus
glFlush
]

reshape: func [w h] [
glViewport 0 0 w h
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 30 w / h 1.0 100.0
glMatrixMode GL_MODELVIEW
glLoadIdentity
gluLookAt 0 0 10 0 0 0 0 1 0
]

keyboard: func [key x y] [
switch key [
#"x" [
glRotatef 30. 1.0 0.0 0.0
glutPostRedisplay
]
#"y" [
glRotatef 30. 0.0 1.0 0.0
glutPostRedisplay
]
#"i" [
glLoadIdentity
gluLookAt 0 0 10 0 0 0 0 1 0
glutPostRedisplay
]
#"^[" [
OpenGL/cleanUp
halt
]
]
]

glutInitWindowSize 200 200
glutInitDisplayMode GLUT_SINGLE or GLUT_RGB
glutCreateWindow "Torus"
init
glutReshapeFunc 'reshape
glutKeyboardFunc 'keyboard
glutDisplayFunc 'display
glutMainLoop

6.8 List

An example showing the use of display lists.
From "Chapter 7: Display Lists" in 'The Red Book'.

examples/list.png

REBOL source: list.r

6.8.1 C Source

#include <GLUT/glut.h>
#include <stdlib.h>

GLuint listName;

void init (void)
{
listName = glGenLists (1);
glNewList (listName, GL_COMPILE);
glColor3f(1.0, 0.0, 0.0);
glBegin (GL_TRIANGLES);
glVertex2f (0.0, 0.0);
glVertex2f (1.0, 0.0);
glVertex2f (0.0, 1.0);
glEnd ();
glTranslatef (1.5, 0.0, 0.0);
glEndList ();
glShadeModel (GL_FLAT);
}

void drawLine (void)
{
glBegin (GL_LINES);
glVertex2f (0.0, 0.5);
glVertex2f (15.0, 0.5);
glEnd ();
}

void display(void)
{
GLuint i;
glClear (GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
for (i = 0; i < 10; i++)
glCallList (listName);
drawLine ();
glFlush ();
}

void reshape(GLsizei w, GLsizei h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
gluOrtho2D (0.0, 2.0, -0.5 * (GLfloat) h/(GLfloat) w,
1.5 * (GLfloat) h/(GLfloat) w);
else
gluOrtho2D (0.0, 2.0 * (GLfloat) w/(GLfloat) h, -0.5,
1.5);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void keyboard (unsigned char key, int x, int y)
{
switch (key)
{
case 27:
exit (0);
}
}

int main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (650, 50);
glutCreateWindow (argv[0]);
init ();
glutReshapeFunc (reshape);
glutKeyboardFunc (keyboard);
glutDisplayFunc (display);
glutMainLoop ();
return 0;
}

6.8.2 REBOL Source

do %GLClient.r

listName: none

init: does [
listName: glGenLists 1
glNewList listName GL_COMPILE
glColor3f 1.0 0.0 0.0
glBegin GL_TRIANGLES
glVertex2f 0.0 0.0
glVertex2f 1.0 0.0
glVertex2f 0.0 1.0
glEnd
glTranslatef 1.5 0.0 0.0
glEndList
glShadeModel GL_FLAT
]

drawLine: does [
glBegin GL_LINES
glVertex2f 0.0 0.5
glVertex2f 15.0 0.5
glEnd
]

display: does [
glClear GL_COLOR_BUFFER_BIT
glColor3f 0.0 1.0 0.0
loop 10 [
glCallList listName
]
drawLine
glFlush
]

reshape: func [w h] [
glViewport 0 0 w h
glMatrixMode GL_PROJECTION
glLoadIdentity
either w <= h [
gluOrtho2D 0.0 2.0 -0.5 * h / w 1.5 * h / w
][
gluOrtho2D 0.0 2.0 * w / h -0.5 1.5
]
glMatrixMode GL_MODELVIEW
glLoadIdentity
]

keyboard: func [key x y] [
switch key [
#"^[" [
OpenGL/cleanUp
halt
]
]
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGB
glutInitWindowSize 650 50
glutCreateWindow "List"
init
glutReshapeFunc 'reshape
glutKeyboardFunc 'keyboard
glutDisplayFunc 'display
glutMainLoop

6.9 Light

Let there be light!
From "Chapter 5: Lighting" in 'The Red Book'.

examples/light.png

REBOL source: light.r

6.9.1 C Source

#include <GLUT/glut.h>

void init(void)
{
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);

glMaterialfv (GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv (GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv (GL_LIGHT0, GL_POSITION, light_position);

glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glEnable (GL_DEPTH_TEST);
}

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSolidSphere (1.0, 20, 16);
glFlush();
}

void reshape(int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
if (w <= h)
glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
else
glOrtho (-1.5*(GLfloat)w/(GLfloat)h,
1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}


int main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Light");
init();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;
}

6.9.2 REBOL Source

do %GLClient.r

init: does [
mat_specular: [ 1.0 1.0 1.0 1.0 ]
mat_shininess: [ 50.0 ]
light_position: [ 1.0 1.0 1.0 0.0 ]
glClearColor 0.0 0.0 0.0 0.0
glShadeModel GL_SMOOTH

glMaterialfv GL_FRONT GL_SPECULAR mat_specular
glMaterialfv GL_FRONT GL_SHININESS mat_shininess
glLightfv GL_LIGHT0 GL_POSITION light_position

glEnable GL_LIGHTING
glEnable GL_LIGHT0
glEnable GL_DEPTH_TEST
]

display: does [
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glutSolidSphere 1.0 20 16
glFlush
]

reshape: func [w h] [
glViewport 0 0 w h
glMatrixMode GL_PROJECTION
glLoadIdentity
either w <= h [
glOrtho -1.5 1.5 -1.5 * h / w
1.5 * h / w -10.0 10.0
][
glOrtho -1.5 * w / h
1.5 * w / h -1.5 1.5 -10.0 10.0
]
glMatrixMode GL_MODELVIEW
glLoadIdentity
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGBA or GLUT_DEPTH
glutInitWindowSize 500 500
glutInitWindowPosition 100 100
glutCreateWindow "Light"
init
glutDisplayFunc 'display
glutReshapeFunc 'reshape
glutMainLoop

6.10 Checker

A texture example.
From "Chapter 9: Texture Mapping" in 'The Red Book'.

examples/checker.png

REBOL source: checker.r

6.10.1 C Source

#include <GLUT/glut.h>

/* Create checkerboard texture */
#define checkImageWidth 64
#define checkImageHeight 64
static GLubyte checkImage[checkImageWidth][checkImageHeight][4];

static GLuint texName;

void makeCheckImage(void)
{
int i, j, c;

for (i = 0; i < checkImageHeight; i++) {
for (j = 0; j < checkImageWidth; j++) {
c = ((((i&0x8)==0)^((j&0x8))==0))*255;
checkImage[i][j][0] = (GLubyte) c;
checkImage[i][j][1] = (GLubyte) c;
checkImage[i][j][2] = (GLubyte) c;
checkImage[i][j][3] = (GLubyte) 255;
}
}
}

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);

makeCheckImage();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth,
checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
checkImage);
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glBindTexture(GL_TEXTURE_2D, texName);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0);

glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(2.41421, 1.0, -1.41421);
glTexCoord2f(1.0, 0.0); glVertex3f(2.41421, -1.0,-1.41421);
glEnd();
glFlush();
glDisable(GL_TEXTURE_2D);
}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -3.6);
}


int main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Checker");
init ();
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;
}

6.10.2 REBOL Source

do join system/options/path %libs/GLClient.r

; Create checkerboard texture
checkImageWidth: 64
checkImageHeight: 64
checkImage: make image! as-pair checkImageWidth checkImageHeight

texName: []

makeCheckImage: has [c] [
for i 0 checkImageHeight - 1 1 [
for j 0 checkImageWidth - 1 1 [
c: (to-integer ( ((i and 8) = 0) xor ((j and 8) = 0) ) ) * 255
change at checkImage as-pair i j to-tuple reduce [c c c 255]
]
]
]

init: does [
glClearColor 0.0 0.0 0.0 0.0
glShadeModel GL_FLAT
glEnable GL_DEPTH_TEST

makeCheckImage
glPixelStorei GL_UNPACK_ALIGNMENT 1

glGenTextures 1 texName
glBindTexture GL_TEXTURE_2D texName/1

glTexParameterf GL_TEXTURE_2D GL_TEXTURE_WRAP_S GL_REPEAT
glTexParameterf GL_TEXTURE_2D GL_TEXTURE_WRAP_T GL_REPEAT
glTexParameterf GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER
GL_NEAREST
glTexParameterf GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER
GL_NEAREST
glTexImage2D GL_TEXTURE_2D 0 GL_RGBA checkImageWidth
checkImageHeight 0 GL_RGBA GL_UNSIGNED_BYTE
checkImage
]

display: does [
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glEnable GL_TEXTURE_2D
glTexEnvf GL_TEXTURE_ENV GL_TEXTURE_ENV_MODE GL_DECAL
glBindTexture GL_TEXTURE_2D texName/1
glBegin GL_QUADS
glTexCoord2f 0.0 0.0 glVertex3f -2.0 -1.0 0.0
glTexCoord2f 0.0 1.0 glVertex3f -2.0 1.0 0.0
glTexCoord2f 1.0 1.0 glVertex3f 0.0 1.0 0.0
glTexCoord2f 1.0 0.0 glVertex3f 0.0 -1.0 0.0

glTexCoord2f 0.0 0.0 glVertex3f 1.0 -1.0 0.0
glTexCoord2f 0.0 1.0 glVertex3f 1.0 1.0 0.0
glTexCoord2f 1.0 1.0 glVertex3f 2.41421 1.0 -1.41421
glTexCoord2f 1.0 0.0 glVertex3f 2.41421 -1.0 -1.41421
glEnd
glFlush
glDisable GL_TEXTURE_2D
]

reshape: func [w h] [
glViewport 0 0 w h
glMatrixMode GL_PROJECTION
glLoadIdentity
gluPerspective 60.0 w / h 1.0 30.0
glMatrixMode GL_MODELVIEW
glLoadIdentity
glTranslatef 0.0 0.0 -3.6
]

glutInitDisplayMode GLUT_SINGLE or GLUT_RGB or GLUT_DEPTH
glutInitWindowSize 250 250
glutInitWindowPosition 100 100
glutCreateWindow "Checker"
init
glutDisplayFunc 'display
glutReshapeFunc 'reshape
glutMainLoop

6.11 AccPersp

Anti-aliased solids.
From "Chapter 10: The Framebuffer" in 'The Red Book'.

examples/accpersp.png

REBOL source: accpersp.r
An extra script needed: jitter.r

6.12 BezCurve

A Bezier curve.
From "Chapter 12: Evaluators and NURBS" in 'The Red Book'.

examples/bezcurve.png

REBOL source: bezcurve.r

6.13 BezSurf

A Bezier surface.
From "Chapter 12: Evaluators and NURBS" in 'The Red Book'.

examples/bezsurf.png

REBOL source: bezsurf.r

6.14 BezMesh

A lit, shaded Bezier surface drawn using a mesh.
From "Chapter 12: Evaluators and NURBS" in 'The Red Book'.

examples/bezmesh.png

REBOL source: bezmesh.r

6.15 TextureSurf

Using evaluators for textures.
From "Chapter 12: Evaluators and NURBS" in 'The Red Book'.

examples/texturesurf.png

REBOL source: texturesurf.r

6.16 NURBS Surface

A NURBS surface.
From "Chapter 12: Evaluators and NURBS" in 'The Red Book'.

examples/surface.png

REBOL source: surface.r

6.17 Select

Selection example.
From "Chapter 13: Selection and Feedback" in 'The Red Book'.

examples/select.png

REBOL source: select.r

6.18 PickSquare

Picking example.
From "Chapter 13: Selection and Feedback" in 'The Red Book'.

examples/picksquare.png

REBOL source: picksquare.r


NicomDoc - 29-Jun-2008