Files
libraries/grogs/README.md
2025-09-21 16:03:19 +10:00

1.6 KiB

grogs (Ground graphics) library

This library uses SDL3 to add graphics support to Ground.

Compiling

First, ensure SDL3 is installed on your system. Then:

g++ -shared -fPIC -lSDL3 -o grogs.so grogs.cpp

Functions

fun -int !initSDL -string &windowTitle -int &width -int &height

This function initialises SDL for use in Grogs. This must be run before trying to run any other Grogs functions!

First argument is the window title, second and third are width and height of the window, respectively.

If everything goes fine, returns 0.

If SDL couldn't create the window, returns 1. If already initialized, returns 2.

Example:

pusharg "My Awesome Window" 640 480
!grogs:initSDL &result

fun -int !pollEvent

Returns a code for an event that has been polled. For now, only window closing is supported, which will return 0. Anything else for now will return -1.

fun -int !clearRenderer

Clears the renderer of any pixels to be rendered. Returns 0, unless SDL is not initialized.

fun -int !renderFrame

Renders frame on the screen. Whichever pixels have been set will be displayed. Returns 0, unless SDL is not initialized.

fun -int !setPixel -int &xpos -int &ypos -int &red -int &green -int &blue

Sets a pixel at the desired location to the desired colour. Returns 0, unless SDL is not initialized.

First argument: xpos Second argument: ypos Third argument: red value (0 to 255) Fourth argument: green value (0 to 255) Fifth argument: blue value (0 to 255)

This example sets the pixel at (10, 10) to white (RGB(255, 255, 255)):

pusharg 10 10 255 255 255
call !grogs:setPixel &result