J6/OpenGL/Utils

From J Wiki
Jump to navigation Jump to search
J6/OpenGL  | Class  | API  | Utils   Movement   Viewing


Load

The jzopengl class is the essential class for OpenGL, and the jzopenglutil class has additional utilities. Load both and coinsert the jzopenglutil class with:

load 'opengl'
coinsert 'jzopenglutil'

Example

Form create and run, see Class:

WGL=: 0 : 0
pc wgl;
xywh 0 0 200 150;cc g isigraph opengl rightmove bottommove;
pas 0 0;
rem form end;
)

wgl_run=: 3 : 0
wd WGL
ogl=: ''conew'jzopengl'
wd'pshow;'
)

An isigraph control is drawn in its paint event handler. When using the OpenGL utilities, this must begin with gsinit, and end with gsfini. In between these are the graphics definitions, in this case to draw a dodecahedron.

wgl_g_paint=: 3 : 0
gsinit ''
gsdrawdodecahedron''
gsfini ''
)

Handle standard movement keys, see Movement:

wgl_g_char=: gschar      NB. standard character event handling
wgl_default=: gsdefault  NB. standard handlers for the function keys.

Nouns

All nouns in class jzopenglutil have names beginning GS_, for example:

GS_AXISCOLOR        axis color
GS_CLEARCOLOR       clear color
GS_COLOR            color
GS_DISPLAYMODE      GLU_ FILL/OUTLINE_POLYGON/OUTLINE_PATH
...

For a complete list, see script defs.ijs.

Verbs

All verbs in class jzopenglutil have names beginning gs, for example:

gsdrawaxes color                    draw axes
gsdrawlines vertices;size;color     draw lines
gsdrawpolygon points;normal;color   draw polygon
gsdrawtubes vertices;size;color     draw tubes
...

For a complete list, see source in glutil scripts.