Macaw OS C reference

Macaw OS C reference

Every call in Macaw OS’s C headers: what it does, what each of its parameters is for, and what it gives back. The list on the left has every module and its functions, and the box at the top of it finds a function by name. The C chapter of the guide says how a C program fits together.

The window and drawing #include <macaw.h> 94 functions

They open your window, draw into it, and work with pictures, sprites and maps.

The window
window, realtime, windowscale, resizable, redraw, close and more
Drawing
cls, pset, pget, line, rect, rectfill and more
Colours
pal, palreset, drawpal, drawpalreset, nearestcolor
The window's memory
screenmem, screenwidth, screenheight
The screen
display_width, display_height, display_current, display_sizes, display_size, display_request
Pictures
newpicture, loadpicture, freepicture, picturewidth, pictureheight, drawpicture and more
Sprites and the map
spr, sprex, sspr, fget, fset, map and more
Sprites as pictures
sprimage, spritesheet
Maps made elsewhere
importmap, importmapimage, imap_layers, imap_layername, imap_size, imap_get and more

Input, sound and the system #include <macaw.h> 78 functions

These are the calls in #include <macaw.h> for the keyboard and mouse, sound and music, files, the network, the system and saved passwords.

The keyboard and mouse
btn, btnp, mouse, textinput, keysp, keyspname
Sound
sfx, play, tone, note, stop, music
Songs and the music chip
playsong, stopsong, loadsong, playloadedsong, freesong, music_volume and more
Time
now, deltatime
Folders and files
fileexists, isfolder, makefolder, listfolder, fileinfo
Markdown
markdown
The clipboard
getclipboard, setclipboard
The desktop
openpath, getpref, setpref
The network
net_online, net_dial, net_connect, net_send, net_readline, net_read and more
The system
platform, ismac, modkey, memory, sys_version, sys_fps and more
Saved passwords (Nestchain)
nest_set, nest_get, nest_has, nest_remove, nest_list, nest_listitem and more
Handy maths for games
rnd, mid, clamp, sgn, lerp, flr

3D #include <macaw3d.h> 77 functions

Each thing in a scene (a camera, a light, a cube, a terrain) is a number, and 0 means none.

Making things
newcamera, newlight
Shapes, terrain and models
newcube, newsphere, newcylinder, newcone, newplane, newterrain and more
What every thing can do
position3d, move3d, translate3d, rotate3d, turn3d, point3d and more
Cameras
fov3d, clscolor3d, camfog3d, camproject3d, campick3d
The scene
render, updateworld, collisions, resetcollisions, pick, ambient and more
Meshes you draw yourself
clear3d, camera3d, light3d
Lamps, fog and lines
pointlight3d, fog3d, nofog3d, project3d, line3d, stats3d
Making meshes
cube3d, cube3dsides, room3d, loadobj, mesh3d
Drawing meshes
billboard3d, drawmesh, drawmeshm, meshtexture, meshsize, freemesh
Textures
loadtexture
The graphics card
glrpresent, cubemaps, glrvram, glrinfotext, glrinfonumber

The graphics chip #include <macawgpu.h> 61 functions

#include <macawgpu.h> to talk to the 3D hardware from C.

State
gpu_enable, gpu_disable, gpu_isenabled, gpu_depthmask, gpu_cullface, gpu_frontface and more
Matrices
A matrix is a grid of 16 numbers that moves, turns, grows or projects every corner you draw.
Drawing a corner at a time
gpu_begin, gpu_color, gpu_colorex, gpu_texcoord, gpu_normal, gpu_vertex and more
Buffers
A buffer keeps a model's corners, so you send them once and draw them each frame.
Textures, light and fog
gpu_bindtexture, gpu_light, gpu_lightoff, gpu_ambient, gpu_shademodel, gpu_material and more
Reflecting water
To draw water that reflects: draw the scene into a picture from a camera mirrored in the water, draw the main scene, call gpu_mask(1), draw the water's surface, call gpu_mask(0), then call gpu_water.
Baked reflections
A cube map is six views from one place, drawn once, that water can reflect instead of a picture drawn again every frame.

Levels #include <macawlevel.h> 94 functions

They let a C program open, draw, walk round and even build the levels you make in Brushwork, the level editor.

Opening, saving and building
openlevel, loadlevel, newlevel, savelevel, buildlevel, freelevel and more
Drawing
These draw a built level with camera3d's camera, unless they say otherwise.
Bumping into it
These work on a built level.
Water
In Brushwork you can make brushes into water.
Reflection probes
A shiny surface reflects the nearest reflection probe: a point in the level whose view all round is baked into a cube map (six square pictures, one each way).
What's in a level
These read the level's table, so they work before it's built too.
Entities
Each entity has a class, its kind, such as "pickup" or "start", and fields with values.
Kinds of entity
These tell you about the classes a level can have: Macaw OS's own (light, arealight, start, probe), the generic ones (marker, pickup, enemy, trigger, sound, sign) and a game's own, from an entities.lua in the level's folder or a folder above it.
Building from code: brushes
These change a level's table.
Building from code: entities and settings
leveladdentity, levelremoveentity, levelmoveentity, levelentitysetnum, levelentitysettext, levelentitysetbool and more
Skies and textures
levelskies, levelsky, leveltexture, leveltexturename
Baking light and the built level
Baking light works out how the level's lamps, glowing faces and sky light every surface, bounces and shadows included, and keeps the result.

Buttons, lists and dialogs #include <macawui.h> 40 functions

#include <macawui.h> for the toolkit of buttons, sliders, text boxes and lists, and for the dialogs.

The frame and layout
ui_begin, ui_beginex, ui_finish, ui_row, ui_space, ui_group and more
Widgets
ui_label, ui_heading, ui_separator, ui_button, ui_checkbox, ui_radio and more
The keyboard's focus, and where widgets are
ui_focus, ui_setfocus, ui_typing, ui_rect
Dialogs
Dialogs don't pause your program.
Drag and drop
ondrop, canpickfiles, pickfiles, startdrag, putondesktop