/ / टाइलिंग रेंडरिंग glFrustum कतरन योजना की गणना - opengl, frum, tutorialcamera

टाइल रेंडरिंग ग्लफ्रस्टम क्लिपिंग प्लेन कैलकुलेशन - ओपनगल, फ्रस्टम, परिप्रेक्ष्य कैमरा

मैं एक टाइलर रेंडरर को काम करने की कोशिश कर रहा था (विचार यह है कि एक बड़े दृश्य को रद्दी में तोड़कर अलग-अलग करके रेंडर किया जाए)

मेरे पास कोड था जो एक मानक परिप्रेक्ष्य प्रक्षेपण को एक देखने के कोण के साथ बाएं, दाएं, ऊपर, और नीचे की कतरन वाले विमानों में बदल देता है जिन्हें तब ग्लेफ़स्ट्रम में पारित किया जा सकता है।

मैं इसे ठीक से तोड़ने पर अटक गया था।

उत्तर:

जवाब के लिए 0 № 1

कई गलत कामों के बाद, मैंने निम्नलिखित उत्पादन किया:

//"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;