Skip to content

Commit 4b9fc3d

Browse files
authored
Document the GPU rendering built-ins (#102)
1 parent 5e7b128 commit 4b9fc3d

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

docs/built_ins.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3213,7 +3213,22 @@ For clarity, the table of functions will be broken up into broad categories, and
32133213

32143214
### GPU rendering-related functions
32153215

3216-
TODO
3216+
| Name | Type | Description |
3217+
| :---------------- | :--------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3218+
| `window` | `(Mut{(Mut{Window}) -> ()}, Mut{(Mut{Window}) -> u32[]}, Frame -> GPGPU[]) -> ()!` | A special function that takes three callback functions, the first is for initially configuring the window to render, the second is run on each frame getting the current state of the window and generating the contents of a context buffer, and the third takes the rendering frame and returns a list of GPGPU shaders to execute and populate the framebuffer |
3219+
| `width` | `Window -> u32` | Returns the width (in pixels) of the rendering portion of the window (not including window decorations, if applicable) |
3220+
| `height` | `Window -> u32` | Returns the height (in pixels) of the rendering portion of the window (not including window decorations, if applicable) |
3221+
| `bufferWidth` | `Window -> u32` | Returns the width (in pixels) of the framebuffer backing the rendering portion of the window. This is usually *slightly* larger than the actual width, to reach a fixed interval of 64-bytes and make the buffer a valid GPU texture |
3222+
| `mouseX` | `Window -> u32` | The current X position (in pixels) of the mouse relative to the window's top-left corner, increasing from left to right |
3223+
| `mouseY` | `Window -> u32` | The current Y position (in pixels) of the mouse relative to the window's top-left corner, increasing from top to bottom |
3224+
| `cursorVisible` | `Mut{Window} -> ()` | A side-effect function that makes the mouse cursor visible when over the window |
3225+
| `cursorInvisible` | `Mut{Window} -> ()` | A side-effect function that makes the mouse cursor invisible when over the window |
3226+
| `transparent` | `Mut{Window} -> ()` | A side-effect function that makes the window rendering area transparent. Only safely callable during the initial configuration callback, but will work on *some* platforms in the per-frame window state callback function |
3227+
| `opaque` | `Mut{Window} -> ()` | A side-effect function that makes the window rendering area opaque. Pointless on most platforms since this is the default, but for platforms where this state can be updated per-frame, it can be used to disable transparency |
3228+
| `runtime` | `Window -> u32` | Returns the total amount of time the window has been running, in `f32` seconds, but given as a `u32` for convenience in inserting into the context array |
3229+
| `context` | `Frame -> GBuffer` | Returns the GPU buffer holding the context for the current frame as set up by the prior callback function on the CPU side |
3230+
| `framebuffer` | `Frame -> GBuffer` | Returns the GPU buffer that will be copied to the window. Actual rendering work goes here. Each pixel is a `u32` of packed 8-bit integers in BGRA order (at least on all hardware that has been tested so far; making this both efficient and easier is planned for the future) |
3231+
| `pixel` | `Frame -> `gu32` | Returns a representation of the current pixel X, Y coordinates the third callback is being required to render. For now properly assigning the right framebuffer index based on the pixel X, Y values is an exercise for the reader |
32173232

32183233
### Process Exit-related functions
32193234

0 commit comments

Comments
 (0)