diff options
| author | quou <quou@disroot.org> | 2024-10-01 18:34:07 +1000 | 
|---|---|---|
| committer | quou <quou@disroot.org> | 2024-10-01 18:34:07 +1000 | 
| commit | 20311c69d2fd4315e3fecf731819d7eba3152871 (patch) | |
| tree | ceb0776ac26f7f6f4683c5ec8ccfdb1d8661dfba | |
| parent | fbc6770df9234bf89b5e4fe3ae07af6f3ab96281 (diff) | |
debug rectangle drawing
| -rw-r--r-- | plat.c | 41 | ||||
| -rw-r--r-- | plat.h | 8 | 
2 files changed, 49 insertions, 0 deletions
| @@ -15,6 +15,31 @@ int btn_just_released(const App* a, Btn btn) {  	return a->btn_states[btn] & btn_state_just_released;  } +typedef struct { +	int x, y, w, h; +	unsigned col; +} Debug_Rect; + +#define max_debug_rects 128 +Debug_Rect debug_rects[max_debug_rects]; +int debug_rect_count; + +void ren_debug_rect( +	int x, +	int y, +	int w, +	int h, +	unsigned colour +) { +	Debug_Rect* r = &debug_rects[debug_rect_count++]; +	assert(debug_rect_count < max_debug_rects); +	r->x = x; +	r->y = y; +	r->w = w; +	r->h = h; +	r->col = colour; +} +  #ifdef plat_posix  #define _POSIX_SOURCE  #define _GNU_SOURCE @@ -419,6 +444,22 @@ void app_rencpy(  		sx, sy,  		w,  h  	); +#ifdef DEBUG +	for (sj = 0; sj < debug_rect_count; sj++) { +		const Debug_Rect* dr = &debug_rects[sj]; +		XSetForeground(i->d, i->gc, dr->col); +		XFillRectangle( +			i->d, +			i->wi, +			i->gc, +			dr->x * s, +			dr->y * s, +		  dr->w * s, +		  dr->h * s +		 ); +	} +#endif +	debug_rect_count = 0;  }  void app_end(App* a) { @@ -85,4 +85,12 @@ int btn_pressed(const App* a, Btn btn);  int btn_just_pressed(const App* a, Btn btn);  int btn_just_released(const App* a, Btn btn); +void ren_debug_rect( +	int x, +	int y, +	int w, +	int h, +	unsigned colour +); +  #endif |