/// <summary> /// R_RenderBrushPoly /// </summary> private void RenderBrushPoly(MemorySurface fa) { _BrushPolys++; if ((fa.flags & ( Int32 )Q1SurfaceFlags.Sky) != 0) { // warp texture, no lightmaps WarpableTextures.EmitBothSkyLayers(Host.RealTime, Host.RenderContext.Origin, fa); return; } var t = TextureAnimation(fa.texinfo.texture); t.texture.Bind( ); if ((fa.flags & ( Int32 )Q1SurfaceFlags.Turbulence) != 0) { // warp texture, no lightmaps WarpableTextures.EmitWaterPolys(Host.RealTime, fa); return; } if ((fa.flags & ( Int32 )Q1SurfaceFlags.Underwater) != 0) { Host.Video.Device.Graphics.DrawWaterPoly(fa.polys, Host.RealTime); } else { Host.Video.Device.Graphics.DrawPoly(fa.polys, t.scaleX, t.scaleY); } // add the poly to the proper lightmap chain fa.polys.chain = _LightMapPolys[fa.lightmaptexturenum]; _LightMapPolys[fa.lightmaptexturenum] = fa.polys; // check for lightmap modification var modified = false; for (var maps = 0; maps < BspDef.MAXLIGHTMAPS && fa.styles[maps] != 255; maps++) { if (_LightStyleValue[fa.styles[maps]] != fa.cached_light[maps]) { modified = true; break; } } if (modified || fa.dlightframe == _FrameCount || // dynamic this frame fa.cached_dlight) // dynamic previously { if (Host.Cvars.Dynamic.Get <Boolean>( )) { LightMapTexture.LightMapModified[fa.lightmaptexturenum] = true; UpdateRect(fa, ref LightMapTexture.LightMapRectChange[fa.lightmaptexturenum]); var offset = fa.lightmaptexturenum * _LightMapBytes * RenderDef.BLOCK_WIDTH * RenderDef.BLOCK_HEIGHT; offset += fa.light_t * RenderDef.BLOCK_WIDTH * _LightMapBytes + fa.light_s * _LightMapBytes; BuildLightMap(fa, new ByteArraySegment(_LightMaps, offset), RenderDef.BLOCK_WIDTH * _LightMapBytes); } } }
/// <summary> /// R_DrawSequentialPoly /// Systems that have fast state and texture changes can /// just do everything as it passes with no need to sort /// </summary> private void DrawSequentialPoly(MemorySurface s) { // // normal lightmaped poly // if ((s.flags & (( Int32 )Q1SurfaceFlags.Sky | ( Int32 )Q1SurfaceFlags.Turbulence | ( Int32 )Q1SurfaceFlags.Underwater)) == 0) { RenderDynamicLightmaps(s); var p = s.polys; var t = TextureAnimation(s.texinfo.texture); if (Host.Video.Device.Desc.SupportsMultiTexture) { Host.Video.Device.Graphics.DrawSequentialPolyMultiTexture(t.texture, LightMapTexture, _LightMaps, p, s.lightmaptexturenum); return; } else { Host.Video.Device.Graphics.DrawSequentialPoly(t.texture, LightMapTexture, p, s.lightmaptexturenum); } return; } // // subdivided water surface warp // if ((s.flags & ( Int32 )Q1SurfaceFlags.Turbulence) != 0) { Host.Video.Device.DisableMultitexture( ); s.texinfo.texture.texture.Bind( ); WarpableTextures.EmitWaterPolys(Host.RealTime, s); return; } // // subdivided sky warp // if ((s.flags & ( Int32 )Q1SurfaceFlags.Sky) != 0) { WarpableTextures.EmitBothSkyLayers(Host.RealTime, Host.RenderContext.Origin, s); return; } // // underwater warped with lightmap // RenderDynamicLightmaps(s); if (Host.Video.Device.Desc.SupportsMultiTexture) { var t = TextureAnimation(s.texinfo.texture); Host.DrawingContext.SelectTexture(MTexTarget.TEXTURE0_SGIS); Host.Video.Device.Graphics.DrawWaterPolyMultiTexture(_LightMaps, t.texture, LightMapTexture, s.lightmaptexturenum, s.polys, Host.RealTime); } else { var p = s.polys; var t = TextureAnimation(s.texinfo.texture); t.texture.Bind( ); Host.Video.Device.Graphics.DrawWaterPoly(p, Host.RealTime); LightMapTexture.BindLightmap((( GLTextureDesc )LightMapTexture.Desc).TextureNumber + s.lightmaptexturenum); Host.Video.Device.Graphics.DrawWaterPolyLightmap(p, Host.RealTime, true); } }