Skip to content

Commit

Permalink
Document the GPU rendering built-ins (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfellis authored Jan 23, 2025
1 parent 5e7b128 commit 4b9fc3d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docs/built_ins.md
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,22 @@ For clarity, the table of functions will be broken up into broad categories, and

### GPU rendering-related functions

TODO
| Name | Type | Description |
| :---------------- | :--------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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 |
| `width` | `Window -> u32` | Returns the width (in pixels) of the rendering portion of the window (not including window decorations, if applicable) |
| `height` | `Window -> u32` | Returns the height (in pixels) of the rendering portion of the window (not including window decorations, if applicable) |
| `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 |
| `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 |
| `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 |
| `cursorVisible` | `Mut{Window} -> ()` | A side-effect function that makes the mouse cursor visible when over the window |
| `cursorInvisible` | `Mut{Window} -> ()` | A side-effect function that makes the mouse cursor invisible when over the window |
| `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 |
| `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 |
| `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 |
| `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 |
| `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) |
| `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 |

### Process Exit-related functions

Expand Down

0 comments on commit 4b9fc3d

Please sign in to comment.