|
Gama C Library
Gama C API Documentation
|
Graphics API (GAPI) abstraction layer for Gama. More...
Go to the source code of this file.
Functions | |
| void | gapi_set_title (const char *title) |
| Sets the title of the application window. | |
| void | gapi_resize (const int32_t width, const int32_t height) |
| Resizes the application window. | |
| void | gapi_set_background_color (const gmColor background) |
| Sets the background color of the application window. | |
| void | gapi_fullscreen (const int32_t fullscreen) |
| Toggles fullscreen mode for the application window. | |
| void | gapi_log (const char *message) |
| Logs a message to the platform's console. | |
| int32_t | gapi_init (const int32_t width, const int32_t height, const char *title) |
| Initializes the Graphics API and the application window. | |
| int32_t | gapi_yield (double *dt) |
| Yields control to the platform, processes events, and updates timing. | |
| void | gapi_quit () |
| Requests the application to quit. | |
| int32_t | gapi_runs () |
| Checks if the application is still running. | |
| int32_t | gapi_draw_line (double x1, double y1, double x2, double y2, double thickness, gmColor col) |
| Draws a line segment on the screen. | |
| int32_t | gapi_draw_rect (double x, double y, double w, double h, gmColor col) |
| Draws a filled rectangle on the screen. | |
| int32_t | gapi_draw_rounded_rect (double x, double y, double w, double h, double r, gmColor col) |
| Draws a filled rectangle with rounded corners on the screen. | |
| int32_t | gapi_draw_circle (double center_x, double center_y, double radius, gmColor col) |
| Draws a filled circle on the screen. | |
| int32_t | gapi_draw_ellipse (double x, double y, double w, double h, gmColor col) |
| Draws a filled ellipse on the screen. | |
| int32_t | gapi_draw_triangle (double x1, double y1, double x2, double y2, double x3, double y3, gmColor col) |
| Draws a filled triangle on the screen. | |
| int32_t | gapi_draw_triangles (uint32_t n_triangles, double *points, gmColor *colors) |
| Draws a batch of triangles on the screen. | |
| uint32_t | gapi_create_image (const unsigned char *data, uint32_t width, uint32_t height) |
| Creates a platform-specific image handle from raw pixel data. | |
| int32_t | gapi_draw_image (uint32_t handle, double x, double y, double width, double height) |
| Draws an image referenced by its handle on the screen. | |
| int32_t | gapi_draw_image_part (uint32_t handle, uint32_t slice_x, uint32_t slice_y, uint32_t slice_width, uint32_t slice_height, double x, double y, double width, double height) |
| Draws a part of an image referenced by its handle on the screen. | |
| int32_t | gapi_draw_text (double x, double y, double height, const char *txt, const char *font, uint8_t style, gmColor col) |
| Draws text on the screen. | |
| int32_t | gapi_key_down (char t, char k) |
| Checks if a specific key is currently pressed. | |
| int32_t | gapi_mouse_down () |
| Checks if the mouse button is currently pressed. | |
| int32_t | gapi_mouse_get (double *x, double *y) |
| Retrieves the current mouse cursor position. | |
Variables | |
| double | _gm_dt = 0 |
| double | _gm_t = 0 |
Graphics API (GAPI) abstraction layer for Gama.
This file declares the interface for platform-specific graphics operations. It provides a set of gapi_ prefixed functions that are implemented differently for each target platform (e.g., native desktop, WebAssembly). This abstraction allows the core Gama engine code to remain platform-agnostic.
|
extern |
Creates a platform-specific image handle from raw pixel data.
This function is used to upload image data to the GPU or create a drawable surface that can be used by gapi_draw_image functions.
| data | A pointer to the raw RGBA pixel data. |
| width | The width of the image. |
| height | The height of the image. |
|
extern |
Draws a filled circle on the screen.
| center_x | The x-coordinate of the center of the circle. |
| center_y | The y-coordinate of the center of the circle. |
| radius | The radius of the circle. |
| col | The gmColor of the circle. |
|
extern |
Draws a filled ellipse on the screen.
| x | The x-coordinate of the center of the ellipse. |
| y | The y-coordinate of the center of the ellipse. |
| w | The width of the ellipse. |
| h | The height of the ellipse. |
| col | The gmColor of the ellipse. |
|
extern |
Draws an image referenced by its handle on the screen.
| handle | The handle of the image to draw, obtained from gapi_create_image. |
| x | The x-coordinate of the center of the image. |
| y | The y-coordinate of the center of the image. |
| width | The width to draw the image. |
| height | The height to draw the image. |
|
extern |
Draws a part of an image referenced by its handle on the screen.
| handle | The handle of the image to draw from. |
| slice_x | The x-coordinate of the top-left corner of the source slice. |
| slice_y | The y-coordinate of the top-left corner of the source slice. |
| slice_width | The width of the source slice. |
| slice_height | The height of the source slice. |
| x | The x-coordinate of the center of the destination rectangle. |
| y | The y-coordinate of the center of the destination rectangle. |
| width | The width to draw the slice. |
| height | The height to draw the slice. |
|
extern |
Draws a line segment on the screen.
| x1 | The x-coordinate of the start point. |
| y1 | The y-coordinate of the start point. |
| x2 | The x-coordinate of the end point. |
| y2 | The y-coordinate of the end point. |
| thickness | The thickness of the line. |
| col | The gmColor of the line. |
|
extern |
Draws a filled rectangle on the screen.
| x | The x-coordinate of the center of the rectangle. |
| y | The y-coordinate of the center of the rectangle. |
| w | The width of the rectangle. |
| h | The height of the rectangle. |
| col | The gmColor of the rectangle. |
|
extern |
Draws a filled rectangle with rounded corners on the screen.
| x | The x-coordinate of the center of the rectangle. |
| y | The y-coordinate of the center of the rectangle. |
| w | The width of the rectangle. |
| h | The height of the rectangle. |
| r | The corner radius. |
| col | The gmColor of the rectangle. |
|
extern |
Draws text on the screen.
| x | The x-coordinate of the center of the text. |
| y | The y-coordinate of the center of the text. |
| height | The height/size of the text. |
| txt | The null-terminated string to draw. |
| font | The null-terminated font name to use. |
| style | A bitmask for text style (e.g., bold, italic). |
| col | The gmColor of the text. |
|
extern |
Draws a filled triangle on the screen.
| x1 | The x-coordinate of the first vertex. |
| y1 | The y-coordinate of the first vertex. |
| x2 | The x-coordinate of the second vertex. |
| y2 | The y-coordinate of the second vertex. |
| x3 | The x-coordinate of the third vertex. |
| y3 | The y-coordinate of the third vertex. |
| col | The gmColor of the triangle. |
|
extern |
Draws a batch of triangles on the screen.
| n_triangles | The number of triangles in the batch. |
| points | An array of doubles representing the vertices (x1,y1, x2,y2, x3,y3 for each triangle). |
| colors | An array of gmColors, one for each triangle. |
|
extern |
Toggles fullscreen mode for the application window.
| fullscreen | 1 to enable fullscreen, 0 to disable. |
|
extern |
Initializes the Graphics API and the application window.
This function must be called once at the start of the application.
| width | The desired width of the window. |
| height | The desired height of the window. |
| title | The title of the window. |
|
extern |
Checks if a specific key is currently pressed.
| t | The type of key ('c' for character, 'a' for arrow, 's' for special). |
| k | The key code. |
|
extern |
Logs a message to the platform's console.
| message | The null-terminated string to log. |
|
extern |
Checks if the mouse button is currently pressed.
|
extern |
Retrieves the current mouse cursor position.
| x | A pointer to a double to store the x-coordinate. |
| y | A pointer to a double to store the y-coordinate. |
|
extern |
Requests the application to quit.
|
extern |
Resizes the application window.
| width | The new width of the window in pixels. |
| height | The new height of the window in pixels. |
|
extern |
Checks if the application is still running.
|
extern |
Sets the background color of the application window.
| background | The gmColor to set as the background. |
|
extern |
Sets the title of the application window.
| title | The null-terminated string for the new window title. |
|
extern |
Yields control to the platform, processes events, and updates timing.
This function should be called at the end of each frame. It handles window events, updates input states, swaps buffers, and calculates _gm_dt.
| dt | A pointer to a double where the calculated delta time will be stored. |
| double _gm_dt = 0 |
| double _gm_t = 0 |