-
Notifications
You must be signed in to change notification settings - Fork 110
Graphics
At boot, the following video modes are tried:
Mode | Resolution | Colors |
---|---|---|
0x118 | 1024x768 | 16M |
0x115 | 800x600 | 16M |
0x112 | 640x480 | 16M |
0x111 | 640x480 | 64K |
Note that the 0x111
video mode is nearly unusable, and only exists so that VMWare Player can boot.
In the future, selecting a video mode from the list of available modes is probably preferable to simply trying
a number of different, potentially unsupported, modes.
At boot, the root graphics window is opened. This window contains the entire visible screen, and will never close.
Each process has an array of up to five windows. When a process is created,
it inherits the windows of its parent, except for the initial process which has the root window open.
A process may create new windows through the draw_create
system call, which creates a new window that is a subset of a window
already open by the process. In this way, a process' windows are sandboxed - a process cannot create a window larger than
what its parent has passed on to it. Windows are reference-counted, and when all processes owning a window are dead,
the window is freed.
Draws are issued to the window through the draw_write
system call. The draw_write
system call sends a null-terminated buffer of
graphics_command
s to the kernel, which then performs all of the draw operations through one system call. There is a standard
buffer for the graphics_command
s provided in user-io
, which also provides functions for filling the buffer.
The draw_write
call is stateful, and within a call the window being drawn to is set by a command, and which window
is being drawn to persists until either a command switches which window is being drawn to or it reaches the end
of the graphics_command
buffer. The current foreground drawing color is persistent through even calls to draw_write
, and
will only change when a command is issued to change it.
Each graphics_command
is a struct containing an integer identifying the type of command followed by an array of four integers
providing the arguments for the command. Not every command uses all four arguments, and those that don't simply ignore the
extra arguments. The list of valid commands is as follows:
Command Name | Arguments | Description |
---|---|---|
GRAPHICS_WINDOW |
W | sets the draw window to W |
GRAPHICS_COLOR |
R G B | sets the draw color to (R, G, B) |
GRAPHICS_RECT |
X Y W H | draws a rectangle with width W and height H at (X, Y) |
GRAPHICS_CLEAR |
X Y W H | clears a rectangle with width W and height H at (X, Y) |
GRAPHICS_LINE |
X Y W H | draws a line starting at (X, Y) that travels W pixels horizontally and H pixels vertically |
GRAPHICS_TEXT |
X Y S | draws a string S at (X, Y) (note that S is a char*, so strings are passed by reference) |