Próbowałem uruchomić kafelkowy renderer (chodzi o renderowanie jednego dużego widoku, rozbijając go na kawałki i renderując indywidualnie).
Miałem kod, który przekształca standardowy rzut perspektywiczny z kątem widzenia w lewą, prawą, górną i dolną płaszczyznę obcinania, którą można następnie przekazać do glFrustum.
Utknąłem na tym, żeby to właściwie rozbić.
Odpowiedzi:
0 dla odpowiedzi № 1Po kilku błędach wykonałem następujące czynności:
//"int rect[4]" is the pixel rectangle of the original view
//"int rect2[4]" is the pixel subrectangle within rect corresponding to the new view
//"left", "right", "bottom", and "top" are the left, right, bottom, and top clipping
// planes of the old view, respectively.
float diff_x = right - left;
float diff_y = top - bottom;
result_left = (float)(rect2[0] ) / (float)(rect[2]) * diff_x + left;
result_right = (float)(rect2[0]+rect2[2]) / (float)(rect[2]) * diff_x + left;
result_bottom = (float)(rect2[1] ) / (float)(rect[3]) * diff_y + bottom;
result_top = (float)(rect2[1]+rect2[3]) / (float)(rect[3]) * diff_y + bottom;