|
Gama C Library
Gama C API Documentation
|
Functions for drawing shapes, text, and images. More...
Go to the source code of this file.
Functions | |
| int32_t | gm_draw_line (double x1, double y1, double x2, double y2, double thickness, gmColor c) |
| Draws a line segment. | |
| int32_t | gm_draw_rectangle (double x, double y, double w, double h, gmColor c) |
| Draws a rectangle. | |
| int32_t | gm_draw_rounded_rectangle (double x, double y, double w, double h, double r, gmColor c) |
| Draws a rectangle with rounded corners. | |
| int32_t | gm_draw_circle (double center_x, double center_y, double radius, gmColor c) |
| Draws a circle. | |
| int32_t | gm_draw_ellipse (double x, double y, double w, double h, gmColor c) |
| Draws an ellipse. | |
| int32_t | gm_draw_triangle (double x1, double y1, double x2, double y2, double x3, double y3, gmColor c) |
| Draws a triangle. | |
| int32_t | gm_draw_image (gmImage img, double x, double y, double w, double h) |
| Draws an image. | |
| int32_t | gm_draw_text (double x, double y, const char *text, const char *font, double font_size, gmColor c) |
| Draws text. | |
| void | gm_draw_body (const gmBody *body, gmColor c) |
| Draws a physics body based on its collider type. | |
| void | gm_draw_rect_body (const gmBody *body, gmColor c) |
| Draws a rectangular physics body. | |
| void | gm_draw_rect_bodies (const gmBody *bodies, size_t number, gmColor c) |
| Draws an array of rectangular physics bodies. | |
| void | gm_draw_round_rect_body (const gmBody *body, double radius, gmColor c) |
| Draws a rectangular physics body with rounded corners. | |
| void | gm_draw_circle_body (const gmBody *body, gmColor c) |
| Draws a circular physics body. | |
| void | gm_draw_circle_bodies (const gmBody *bodies, size_t number, gmColor c) |
| Draws an array of circular physics bodies. | |
| void | gm_draw_ellipse_body (const gmBody *body, gmColor c) |
| Draws an elliptical physics body. | |
| void | gm_draw_ellipse_bodies (const gmBody *bodies, size_t number, gmColor c) |
| Draws an array of elliptical physics bodies. | |
| void | gm_draw_triangle_body (const gmBody *body, double x2_offset, double y2_offset, double x3_offset, double y3_offset, gmColor c) |
| Draws a triangular physics body. | |
| void | gm_draw_triangle_bodies (const gmBody *bodies, size_t number, double x2_offset, double y2_offset, double x3_offset, double y3_offset, gmColor c) |
| Draws an array of triangular physics bodies. | |
| void | gm_draw_image_body (const gmBody *body, gmImage img) |
| Draws an image at a physics body's position. | |
| void | gm_draw_image_bodies (const gmBody *bodies, size_t number, gmImage img) |
| Draws the same image for an array of physics bodies. | |
| void | gm_draw_text_body (const gmBody *body, const char *text, const char *font, double font_size, gmColor c) |
| Draws text at a physics body's position. | |
| void | gm_draw_text_bodies (const gmBody *bodies, size_t number, const char *text, const char *font, double font_size, gmColor c) |
| Draws the same text for an array of physics bodies. | |
Functions for drawing shapes, text, and images.
This file provides a set of functions for immediate-mode rendering of various primitives, as well as helper functions to draw physics bodies (gmBody). All coordinates are in world space.
Draws a physics body based on its collider type.
This function checks the body's collider type and calls the appropriate drawing function (e.g., gm_draw_rectangle for GM_COLLIDER_RECT).
| body | A pointer to the body to draw. |
| c | The color to draw the body. |
| int32_t gm_draw_circle | ( | double | center_x, |
| double | center_y, | ||
| double | radius, | ||
| gmColor | c ) |
Draws a circle.
| 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. |
| c | The color of the circle. |
Draws an array of circular physics bodies.
| bodies | A pointer to the array of bodies. |
| number | The number of bodies in the array. |
| c | The color to draw the bodies. |
Draws a circular physics body.
If the body is not a circle collider, it approximates the radius.
| body | A pointer to the body to draw. |
| c | The color to draw the body. |
| int32_t gm_draw_ellipse | ( | double | x, |
| double | y, | ||
| double | w, | ||
| double | h, | ||
| gmColor | c ) |
Draws an ellipse.
| x | The x-coordinate of the top-left corner of the bounding box. |
| y | The y-coordinate of the top-left corner of the bounding box. |
| w | The width of the ellipse. |
| h | The height of the ellipse. |
| c | The color of the ellipse. |
Draws an array of elliptical physics bodies.
| bodies | A pointer to the array of bodies. |
| number | The number of bodies in the array. |
| c | The color to draw the bodies. |
Draws an elliptical physics body.
| body | A pointer to the body to draw. |
| c | The color to draw the body. |
| int32_t gm_draw_image | ( | gmImage | img, |
| double | x, | ||
| double | y, | ||
| double | w, | ||
| double | h ) |
Draws an image.
| img | The image to draw. |
| x | The x-coordinate of the top-left corner. |
| y | The y-coordinate of the top-left corner. |
| w | The width to draw the image. |
| h | The height to draw the image. |
Draws the same image for an array of physics bodies.
| bodies | A pointer to the array of bodies. |
| number | The number of bodies in the array. |
| img | The image to draw. |
Draws an image at a physics body's position.
| body | A pointer to the body. |
| img | The image to draw. |
| int32_t gm_draw_line | ( | double | x1, |
| double | y1, | ||
| double | x2, | ||
| double | y2, | ||
| double | thickness, | ||
| gmColor | c ) |
Draws a line segment.
| x1 | The x-coordinate of the starting point. |
| y1 | The y-coordinate of the starting point. |
| x2 | The x-coordinate of the ending point. |
| y2 | The y-coordinate of the ending point. |
| thickness | The thickness of the line in pixels. |
| c | The color of the line. |
Draws an array of rectangular physics bodies.
| bodies | A pointer to the array of bodies. |
| number | The number of bodies in the array. |
| c | The color to draw the bodies. |
Draws a rectangular physics body.
| body | A pointer to the body to draw. |
| c | The color to draw the body. |
| int32_t gm_draw_rectangle | ( | double | x, |
| double | y, | ||
| double | w, | ||
| double | h, | ||
| gmColor | c ) |
Draws a rectangle.
| x | The x-coordinate of the top-left corner. |
| y | The y-coordinate of the top-left corner. |
| w | The width of the rectangle. |
| h | The height of the rectangle. |
| c | The color of the rectangle. |
Draws a rectangular physics body with rounded corners.
| body | A pointer to the body to draw. |
| radius | The corner radius. |
| c | The color to draw the body. |
| int32_t gm_draw_rounded_rectangle | ( | double | x, |
| double | y, | ||
| double | w, | ||
| double | h, | ||
| double | r, | ||
| gmColor | c ) |
Draws a rectangle with rounded corners.
| x | The x-coordinate of the top-left corner. |
| y | The y-coordinate of the top-left corner. |
| w | The width of the rectangle. |
| h | The height of the rectangle. |
| r | The corner radius. |
| c | The color of the rectangle. |
| int32_t gm_draw_text | ( | double | x, |
| double | y, | ||
| const char * | text, | ||
| const char * | font, | ||
| double | font_size, | ||
| gmColor | c ) |
Draws text.
| x | The x-coordinate for the text position. |
| y | The y-coordinate for the text position. |
| text | The null-terminated string to draw. |
| font | The null-terminated font name to use. |
| font_size | The size of the font. |
| c | The color of the text. |
| void gm_draw_text_bodies | ( | const gmBody * | bodies, |
| size_t | number, | ||
| const char * | text, | ||
| const char * | font, | ||
| double | font_size, | ||
| gmColor | c ) |
Draws the same text for an array of physics bodies.
| bodies | A pointer to the array of bodies. |
| number | The number of bodies in the array. |
| text | The null-terminated string to draw. |
| font_size | The size of the font. |
| c | The color of the text. |
| void gm_draw_text_body | ( | const gmBody * | body, |
| const char * | text, | ||
| const char * | font, | ||
| double | font_size, | ||
| gmColor | c ) |
Draws text at a physics body's position.
| body | A pointer to the body. |
| text | The null-terminated string to draw. |
| font_size | The size of the font. |
| c | The color of the text. |
| int32_t gm_draw_triangle | ( | double | x1, |
| double | y1, | ||
| double | x2, | ||
| double | y2, | ||
| double | x3, | ||
| double | y3, | ||
| gmColor | c ) |
Draws a triangle.
| 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. |
| c | The color of the triangle. |
| void gm_draw_triangle_bodies | ( | const gmBody * | bodies, |
| size_t | number, | ||
| double | x2_offset, | ||
| double | y2_offset, | ||
| double | x3_offset, | ||
| double | y3_offset, | ||
| gmColor | c ) |
Draws an array of triangular physics bodies.
| bodies | A pointer to the array of bodies. |
| number | The number of bodies in the array. |
| x2_offset | The x-offset of the second vertex for all triangles. |
| y2_offset | The y-offset of the second vertex for all triangles. |
| x3_offset | The x-offset of the third vertex for all triangles. |
| y3_offset | The y-offset of the third vertex for all triangles. |
| c | The color to draw the bodies. |
| void gm_draw_triangle_body | ( | const gmBody * | body, |
| double | x2_offset, | ||
| double | y2_offset, | ||
| double | x3_offset, | ||
| double | y3_offset, | ||
| gmColor | c ) |
Draws a triangular physics body.
The body's position is the first vertex. The other two vertices are specified as offsets from the first.
| body | A pointer to the body to draw. |
| x2_offset | The x-offset of the second vertex. |
| y2_offset | The y-offset of the second vertex. |
| x3_offset | The x-offset of the third vertex. |
| y3_offset | The y-offset of the third vertex. |
| c | The color to draw the body. |