문제

I was trying to get a tiled renderer working (the idea is to render one large view frustum by breaking it down into chunks and rendering individually).

I had code that transforms a standard perspective projection with a viewing angle into left, right, top, and bottom clipping planes that can then be passed into glFrustum.

I was stuck on properly breaking this down.

도움이 되었습니까?

해결책

After several missteps, I produced the following:

//"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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top