-
How is Glk like a forest?
Because it has rocks, streams, and trees. Before proceeding, we need to
get some Glky terms out of the way.
(Heheh. As an animal, I really like this part. Sorry, I just had to say it.)
Glk Geology (Structure)
Objects/Classes
|
Windows (independent screen areas)
|
Streams (text output/input)
|
Sound channels (audio output)
|
File references (pointers to external files)
|
Blorb Resources
|
Images - JPEG (JPG), PNG
|
Sounds - AIFF, MOD
|
|
Events
|
Event Originator
|
Line input
|
Player
|
Character input
|
Player
|
Mouse input
|
Player
|
Hyperlink selection
|
Player
|
Arrange window (resize)
|
Player
|
Redraw graphic window
|
Player/
Internal
|
Timed events (Timer)
|
Author
|
|
Objects
- Glk objects are an instance of a class, as is often the case in regular
Inform. So a window object is an instance of the Window class,
a stream object is an instance of the Stream class, etc. But there the
similarity to regular Inform objects ends. Glk objects
are dynamic -- created at run-time in the interpreter's memory. So,
as an Inform programmer, you cannot code a Glk object directly. Instead, you
declare a global variable that will "point" to it, a reference (point
at its memory
address -- actually point at an entry in a hash table). Using such a global
variable (declared by yourself or the Glulx Inform library), you
can then call Glk functions to
directly affect Glk objects.
Events
- Events are input/output actions. They are trapped by the new built-in Inform
function,
[HandleGlkEvent].
This guide won't cover the Glk timer (the only output
event), which is a timed event handled by Glk. However, note that Glk's timer
is based on actual time passed, while regular Inform's timer routine is based on
the number of turns
passed.
Blorb Resources
- Blorb resources are not PART of Glk -- they are external resources that can
be loaded into Glk objects: graphic images into graphic windows; sound
files into
sound channels. This means that the graphic/sound file formats that blorb
supports can be added onto over time.
Glk Biology (Terminology)
-
Gestalt
(the forest) - The gestalt is essentially Glk's overall
potential
configuration, since not all interpreters support all Glk functions. So when
writing a game, you need to call Glk's gestalt
functions to test if the player's interpreter supports a specific Glk I/O
capability, such as sound, before attempting to play the sound.
-
Rocks
- Rocks are ID numbers that function as anchors for each Glk object.
When creating a new Glk object reference, you need to give it a unique rock
number. This also becomes very important when you
use Glulx Inform's Glk entry
point:
IdentifyGlkObj
(see Part 3,
Glk Entry Points).
Since these rock numbers are already defined as constants in the bi-platform
library, they should be considered "reserved":
GG_MAINWIN_ROCK
201
|
main text window
|
windows
|
GG_STATUSWIN_ROCK
202
|
status line window
|
GG_QUOTEWIN_ROCK
203
|
quote box window
|
GG_SAVESTR_ROCK
301
|
save file
|
streams
(open files)
|
GG_SCRIPTSTR_ROCK
302
|
transcript file
|
GG_COMMANDRSTR_ROCK
303
|
command file
(for debugging)
|
GG_COMMANDRSTR_ROCK
304
|
(ditto)
|
GG_SCRIPTFREF_ROCK
401
|
script file name
|
file references
|
Following this numbering convention, Zarf recommends that when you create new
windows, you should start with a rock number of 210. Start new streams with
310, and new
file references with 410. (Leave some room between the last of the pre-defined
constants and
your numbers, in case new constants are added in the future.)
-
Streams
- A stream is basically a flow of data. All Glk character output is handled by
streams, so each window also has a default stream associated with it for text.
However,
where
they
become crucial is with Glk's file I/O. But we'll cross that stream when we come
to it. :-)
-
Trees
- Glk has trees similar to regular Inform's trees. But these trees are only
associated with windows.
When new windows are created they become branches and leaves of a tree.
So a window can have a parent and a sibling (but, again, no bananas).
Part One
Part Three
Part Four
Top of Page
Appendix One
(infglk Wrapper Reference)
Appendix Two
(Interpreter & Color Charts)
doeadeer3@aol.com
|