2025-08-03 10:07:35 -04:00
|
|
|
#ifndef _UTIL_H_
|
|
|
|
|
#define _UTIL_H_
|
|
|
|
|
|
2026-01-05 08:58:06 -05:00
|
|
|
#include <akerror.h>
|
2025-08-03 10:07:35 -04:00
|
|
|
|
|
|
|
|
typedef struct point {
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
int z;
|
|
|
|
|
} point;
|
|
|
|
|
|
|
|
|
|
typedef struct RectanglePoints {
|
|
|
|
|
point topleft;
|
|
|
|
|
point topright;
|
|
|
|
|
point bottomleft;
|
|
|
|
|
point bottomright;
|
|
|
|
|
} RectanglePoints;
|
|
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
#define AKGL_COLLIDE_RECTANGLES(r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h) ((r1x < (r2x + r2w)) || ((r1x + r1w) > r2x)
|
2025-08-03 10:07:35 -04:00
|
|
|
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_rectangle_points(RectanglePoints *dest, SDL_FRect *rect);
|
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_collide_point_rectangle(point *p, RectanglePoints *r, bool *collide);
|
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_collide_rectangles(SDL_FRect *r1, SDL_FRect *r2, bool *collide);
|
2025-08-03 10:07:35 -04:00
|
|
|
|
|
|
|
|
// These are REALLY slow routines that are only useful in testing harnesses
|
2026-05-06 23:18:42 -04:00
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_compare_sdl_surfaces(SDL_Surface *s1, SDL_Surface *s2);
|
|
|
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_render_and_compare(SDL_Texture *t1, SDL_Texture *t2, int x, int y, int w, int h, char *writeout);
|
2025-08-03 10:07:35 -04:00
|
|
|
|
|
|
|
|
#endif // _UTIL_H_
|