Add readme

This commit is contained in:
2025-09-21 16:03:19 +10:00
parent 7fd2f3c8b0
commit 52e95e987f
2 changed files with 60 additions and 1 deletions

59
grogs/README.md Normal file
View File

@@ -0,0 +1,59 @@
# grogs (Ground graphics) library
This library uses SDL3 to add graphics support to Ground.
## Compiling
First, ensure SDL3 is installed on your system. Then:
```bash
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
```

View File

@@ -57,7 +57,7 @@ GroundValue renderFrame(GroundValue* args, int arg_count) {
return GROUND_INT_VAL(-1);
}
SDL_RenderPresent(renderer);
return GROUND_BOOL_VAL(true);
return GROUND_INT_VAL(0);
}
GroundValue setPixel(GroundValue* args, int arg_count) {