// This function is invoked, when the mouse button is released and the
// selection box had been drawn.
// Hint: Alternatively you can use ent_pvs() and omit the if statement.
ENTITY *ent;
for (ent = ent_next(NULL); ent != NULL; ent = ent_next(ent)) {
if (!(my.eflags & CLIPPED)) {
VECTOR ent_screen_pos;
vec_set(&ent_screen_pos, &(ent->x));
vec_to_screen(&ent_screen_pos, camera);
if ((ent_screen_pos.x >= minv(selectionbox_from.x, selectionbox_to.x)) &&
(ent_screen_pos.x <= maxv(selectionbox_from.x, selectionbox_to.x)) &&
(ent_screen_pos.y >= minv(selectionbox_from.y, selectionbox_to.y)) &&
(ent_screen_pos.y <= maxv(selectionbox_from.y, selectionbox_to.y)))
{
// add entity to selection
}
}
}