PAINTING: fullx = screen->width * num_viewports_w; fully = screen->height * num_viewports_h; calculate a screen transformation where the whole area [0..fullx][0..fully] can be displayed apply screen transformation save the matrix for all viewports { pushmatrix gltranslate(s->x,s-y,0); paint viewport; popmatrix // this will paint viewport 1 at [0..s->width][0..s->height] and viewport 2 at [s->width..2*s-width][0..s->height] ... } MOUSETRANSFORMATION: mx/my = mouse position unproject p1(mx,my,0) and p2(mx,my,-1) calulate the vector v = p2' - p1' find the there the line l = p1' + alpha v hits the plane at z = 0; this will result in correct coordinates for the mouse and viewport