0

我试图让一个平铺渲染器工作(这个想法是通过将它分解成块并单独渲染来渲染一个大视图平截头体)。

我有代码可以将具有视角的标准透视投影转换为左、右、上和下剪切平面,然后可以将其传递给 glFrustum。

我被困在正确地打破这一点。

4

1 回答 1

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;
于 2013-03-15T18:00:27.420 回答