B32 in_rect(V2 pos, V2 start, V2 end) { B32 res; res = ((pos.x > start.x) && (pos.x < end.x) && (pos.y > start.y) && (pos.y < end.y)); return res; } B32 button(Window *wnd, U32 shader, Input *input, Arena *arena, Str8 name, V2 center, F32 w, F32 h) { B32 res; Mesh *quad; V2 start, end; MAT4 model; Str8 info; res = 0; quad = mesh_gen_quad(arena, v3fromv2(center), V3_ZERO, w, h); shader_set_4fv(shader, "color", v4(1.0f, 0.0f, 0.0f, 1.0f)); start = v2(center.x-w/2.0f, center.y-h/2.0f); end = v2(center.x+w/2.0f, center.y+h/2.0f); if (in_rect(input->mouse_pos, start, end) && !input->capture_mouse) { shader_set_4fv(shader, "color", v4(0.0f, 0.0f, 1.0f, 1.0f)); if (key_first_press(input->mouse_left)) res = 1; } model = mat4transl(MAT4_IDENTITY, v3(center.x, wnd->height-center.y, 0.0f)); shader_set_mat4fv(shader, "model", model); mesh_draw(quad); mesh_clear(quad); return res; }