MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / g3_DrawPoly

Function g3_DrawPoly

renderer/HardwareDraw.cpp:145–232  ·  view source on GitHub ↗

draw a polygon Parameters: nv - the number of verts in the poly pointlist - a pointer to a list of pointers to points bm - the bitmap handle if texturing. ignored if flat shading Returns 0 if clipped away

Source from the content-addressed store, hash-verified

143// bm - the bitmap handle if texturing. ignored if flat shading
144// Returns 0 if clipped away
145int g3_DrawPoly(int nv, g3Point **pointlist, int bm, int map_type, g3Codes *clip_codes) {
146 rend_DrawPolygon3D(bm, pointlist, nv, map_type);
147 return 1;
148
149 /*
150 int i;
151 g3Codes cc;
152 bool was_clipped=0;
153
154 if( Triangulate_test && (nv > 3) )
155 {
156 g3Point *tripoints[3];
157 int sum=0;
158
159 for (i=0;i<nv-2;i++)
160 {
161 tripoints[0] = pointlist[0];
162 tripoints[1] = pointlist[i+1];
163 tripoints[2] = pointlist[i+2];
164 sum += g3_DrawPoly( 3, tripoints, bm, map_type );
165 }
166
167 return sum;
168 }
169
170 //Initialize or just used the ones passed in
171 if( clip_codes )
172 {
173 cc = *clip_codes;
174 }
175 else
176 {
177 cc.cc_or = 0;
178 cc.cc_and = 0xff;
179
180 //Get codes for this polygon, and copy uvls into points
181 for( i = 0; i < nv; ++i )
182 {
183 uint8_t c = pointlist[i]->p3_codes;
184 cc.cc_and &= c;
185 cc.cc_or |= c;
186 }
187 }
188
189 //All points off screen?
190 if( cc.cc_and )
191 return 0;
192
193 //One or more point off screen, so clip
194 if( cc.cc_or )
195 {
196 //Clip the polygon, getting pointer to new buffer
197 pointlist = g3_ClipPolygon( pointlist, &nv, &cc );
198
199 //Flag as clipped so temp points will be freed
200 was_clipped = 1;
201
202 //Check for polygon clipped away, or clip otherwise failed

Callers 15

g3_CheckAndDrawPolyFunction · 0.85
g3_DrawRotatedBitmapFunction · 0.85
RenderSubmodelFaceFunction · 0.85
RenderSubmodelFaceFoggedFunction · 0.85
DrawSplinterObjectFunction · 0.85
DrawShardObjectFunction · 0.85
DrawFogLayerFunction · 0.85
DrawCloudLayerFunction · 0.85

Calls 1

rend_DrawPolygon3DFunction · 0.85

Tested by

no test coverage detected