Add gl_drawbox to util.c

This commit is contained in:
8dcc 2023-07-23 01:47:52 +02:00
parent 5aa85bc274
commit fba031944e
2 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,7 @@ char* get_name(int ent_idx);
vec3_t vec3(float x, float y, float z); vec3_t vec3(float x, float y, float z);
bool vec_is_zero(vec3_t v); bool vec_is_zero(vec3_t v);
bool world_to_screen(vec3_t vec, vec2_t screen); bool world_to_screen(vec3_t vec, vec2_t screen);
void gl_drawbox(int x, int y, int w, int h, rgb_t c);
void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col); void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col);
#endif /* UTIL_H_ */ #endif /* UTIL_H_ */

View File

@ -57,6 +57,24 @@ bool world_to_screen(vec3_t vec, vec2_t screen) {
return false; return false;
} }
void gl_drawbox(int x, int y, int w, int h, rgb_t c) {
/* Line width */
const int lw = 1;
/*
* 1
* +----+
* 2 | | 3
* | |
* +----+
* 4
*/
gl_drawline(x, y, x + w, y, lw, c); /* 1 */
gl_drawline(x, y, x, y + h, lw, c); /* 2 */
gl_drawline(x + w, y, x + w, y + h, lw, c); /* 3 */
gl_drawline(x, y + h, x + w, y + h, lw, c); /* 4 */
}
void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col) { void gl_drawline(int x0, int y0, int x1, int y1, float w, rgb_t col) {
const int alpha = 255; const int alpha = 255;