75static inline void gm3_image_reset(
gm3Image *i) {
122static inline int gm3_image_ensure_cap(
gm3Image *img,
size_t new_v,
128 new_cap = new_v + 128;
141 new_cap = new_t + 128;
145 void *d_ptr =
realloc(img->
depths, new_cap *
sizeof(
double));
147 if (!t_ptr || !c_ptr || !d_ptr)
187 else if (rb->
z > ra->
z)
226 sort_arr[i].
z = img->
depths[i];
256 size_t tidx = sort_arr[i].
tri_idx;
257 size_t idx_base = tidx * 3;
260 for (
size_t j = 0; j < 3; j++) {
262 verts[indices[idx_base + j]].
x * scale + x;
264 verts[indices[idx_base + j]].
y * scale + y;
void gm3_image_free(gm3Image *i)
Definition image.h:86
int gm3_draw_image(gm3Image *img, double x, double y, double scale)
Draws the projected 3D scene contained within a gm3Image onto the screen.
Definition image.h:206
int _gm3_depth_compare(const void *a, const void *b)
Definition image.h:181
uint32_t gmColor
Type definition for color values, stored as a 32-bit unsigned integer. The color components are packe...
Definition color.h:13
Graphics API (GAPI) abstraction layer for Gama.
int32_t gapi_draw_triangles(uint32_t n_triangles, double *points, gmColor *colors)
Draws a batch of triangles on the screen.
void * malloc(size_t size)
Custom implementation of malloc using a static memory pool.
Definition malloc.h:144
void * realloc(void *ptr, size_t size)
Custom implementation of realloc for memory allocated by malloc (this custom version).
Definition malloc.h:236
void free(void *ptr)
Custom implementation of free for memory allocated by malloc (this custom version).
Definition malloc.h:189
size_t tri_idx
Definition image.h:167
double z
Definition image.h:168
Structure representing the 2D projected output of a 3D scene.
Definition image.h:22
size_t cap_depths
Definition image.h:38
size_t cap_sort
Definition image.h:48
size_t cap_colors
Definition image.h:36
void * sort_buf
Definition image.h:47
gmColor * cols
Definition image.h:51
size_t n_colors
Definition image.h:31
double * depths
Definition image.h:27
gmColor * colors
Definition image.h:25
double * tri
Definition image.h:50
size_t cap_triangles
Definition image.h:37
gmPos * vertices
Definition image.h:24
size_t * triangles
Definition image.h:26
size_t n_vertices
Definition image.h:30
size_t cap_vertices
Definition image.h:35
size_t cap_world
Definition image.h:45
gm3Pos * world_verts
Definition image.h:44
size_t n_triangles
Definition image.h:32
struct gm3Image::@171174116104107177311324262265324115365007060225 _internal
size_t cap_tri
Definition image.h:52
Represents a 3D position or vector.
Definition position.h:11
Represents a 2D position or vector.
Definition position.h:8
double x
Definition position.h:9
double y
Definition position.h:9