我试图让平铺的渲染器工作(想法是通过将其分解成块并单独渲染来渲染一个大视锥体。)
我有一些代码可以将带有视角的标准透视投影转换为左,右,上和下剪裁平面,然后可以将其传递到glFrustum。
我被迫坚决打破了这一点。
答案 0 :(得分:0)
经过几次失误后,我制作了以下内容:
//"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;