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

Function d3d_DrawPolygon

legacy/renderer/Direct3D.cpp:2173–2338  ·  view source on GitHub ↗

Takes nv vertices anddraws the polygon defined by those vertices. Uses bitmap "handle" as a texture

Source from the content-addressed store, hash-verified

2171// Takes nv vertices anddraws the polygon defined by those vertices. Uses bitmap "handle"
2172// as a texture
2173void d3d_DrawPolygon(int handle, g3Point **p, int nv, int map_type) {
2174 HRESULT ddrval;
2175 TextureVertex *tvert_ptr;
2176 int i;
2177
2178 if (d3d_CanBumpmap && Bumpmap_ready) {
2179 ASSERT(Overlay_type == OT_NONE);
2180
2181 if (!d3d_DrawBumpmappedPolygon(p, nv, handle)) {
2182 mprintf(0, "error in d3d_DrawBumpmappedPolygon\n");
2183 }
2184
2185 rend_SetBumpmapReadyState(0, 0);
2186
2187 return;
2188 }
2189
2190 if (d3d_CanBumpmap && D3D_bumpmap_state)
2191 d3d_SetBumpmappingBlendModes(0);
2192
2193 if ((!D3D_state.cur_texture_quality)) {
2194 if (D3D_state.cur_alpha_type == AT_SPECULAR) {
2195 if (!d3d_MakeBitmapCurrent(handle, map_type, 0))
2196 return;
2197 }
2198
2199 if (d3d_MultiTexture) // If this device can do multitexture, clear it so it won't
2200 d3d_SetMultiTextureBlendMode(false);
2201
2202 d3d_DrawFlatPolygon(p, nv);
2203
2204 return;
2205 }
2206
2207 // Figure out subpixel correction for UVs
2208 if (d3d_SubpixelCorrect) {
2209 if (map_type == MAP_TYPE_BITMAP) {
2210 UV_diff = (1.0 / (float)bm_w(handle, 0)) / 2.0;
2211 } else if (map_type == MAP_TYPE_LIGHTMAP) {
2212 UV_diff = (1.0 / (float)lm_w(handle)) / 2.0;
2213 } else
2214 UV_diff = 0;
2215 } else
2216 UV_diff = 0;
2217
2218 if (Overlay_type != OT_NONE && d3d_MultiTexture) {
2219 d3d_DrawMultiTexturePolygon(p, nv, handle, map_type);
2220
2221 return;
2222 }
2223
2224 int alpha = Alpha_multiplier * d3d_Alpha_factor;
2225
2226 for (i = 0; i < nv; i++) {
2227 int r, g, b;
2228
2229 g3Point *pnt = p[i];
2230 tvert_ptr = &TVerts[i];

Callers 1

rend_DrawPolygonFunction · 0.85

Calls 14

d3d_MakeBitmapCurrentFunction · 0.85
d3d_DrawFlatPolygonFunction · 0.85
bm_wFunction · 0.85
lm_wFunction · 0.85
GR_COLOR_REDFunction · 0.85
GR_COLOR_GREENFunction · 0.85
GR_COLOR_BLUEFunction · 0.85
d3d_SetAlphaTypeFunction · 0.85

Tested by

no test coverage detected