2013-03-15 32 views
0

我試圖讓一個平鋪的渲染器工作(這個想法是通過將它分解成塊並渲染一個來渲染一個大的視錐體)。平鋪渲染glFrustum剪切平面計算

我將代碼轉換成可視角度的標準透視投影到左,右,頂部和底部剪裁平面,然後可以傳遞到glFrustum。

我被困在正確地打破這一點。

+0

難道['libtr'(http://www.mesa3d.org/brianp/TR.html)無法正常工作? – genpfault 2013-03-15 18:37:46

+0

這是我能找到的主題上唯一的參考,但我正在尋找更一般的東西。 – imallett 2013-03-15 22:04:07

回答

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;