// Platform implementation of 40250 GameLib/MapOutdoorCharacterShadow.cpp. The render-target lifecycle is // the 40250 code as is; the shadow-map pass is not run (BeginRenderCharacterShadowToTexture reports it // cannot render) because the terrain that samples the map is drawn by Godot, which casts its own // character shadows (PORT-PLAN ยง3). #include "GameLib/StdAfx.h" #include "EterLib/StateManager.h" #include "EterLib/Camera.h" #include "GameLib/MapOutdoor.h" static int recreate = false; void CMapOutdoor::SetShadowTextureSize(WORD size) { if (m_wShadowMapSize != size) { recreate = true; Tracenf("ShadowTextureSize changed %d -> %d", m_wShadowMapSize, size); } m_wShadowMapSize = size; } void CMapOutdoor::CreateCharacterShadowTexture() { extern bool GRAPHICS_CAPS_CAN_NOT_DRAW_SHADOW; if (GRAPHICS_CAPS_CAN_NOT_DRAW_SHADOW) return; ReleaseCharacterShadowTexture(); if (IsLowTextureMemory()) SetShadowTextureSize(128); m_ShadowMapViewport.X = 1; m_ShadowMapViewport.Y = 1; m_ShadowMapViewport.Width = m_wShadowMapSize - 2; m_ShadowMapViewport.Height = m_wShadowMapSize - 2; m_ShadowMapViewport.MinZ = 0.0f; m_ShadowMapViewport.MaxZ = 1.0f; if (FAILED(ms_lpd3dDevice->CreateTexture(m_wShadowMapSize, m_wShadowMapSize, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &m_lpCharacterShadowMapTexture))) { TraceError("CMapOutdoor Unable to create Character Shadow render target texture\n"); return; } if (FAILED(m_lpCharacterShadowMapTexture->GetSurfaceLevel(0, &m_lpCharacterShadowMapRenderTargetSurface))) { TraceError("CMapOutdoor Unable to GetSurfaceLevel Character Shadow render target texture\n"); return; } if (FAILED(ms_lpd3dDevice->CreateDepthStencilSurface(m_wShadowMapSize, m_wShadowMapSize, D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_lpCharacterShadowMapDepthSurface))) { TraceError("CMapOutdoor Unable to create Character Shadow depth Surface\n"); return; } } void CMapOutdoor::ReleaseCharacterShadowTexture() { SAFE_RELEASE(m_lpCharacterShadowMapRenderTargetSurface); SAFE_RELEASE(m_lpCharacterShadowMapDepthSurface); SAFE_RELEASE(m_lpCharacterShadowMapTexture); } // PORT: no shadow-map pass (see the file comment); CPythonBackground::RenderCharacterShadowToTexture // then skips the shadow instances. bool CMapOutdoor::BeginRenderCharacterShadowToTexture() { return false; } // PORT: nothing to restore when the pass did not begin. void CMapOutdoor::EndRenderCharacterShadowToTexture() { }