void Renderer::Exit() { DeleteObject( g_hFont ); if ( m_pD3DDevice ) { m_pD3DDevice->SetPixelShader( NULL ); m_pD3DDevice->SetVertexShader( NULL ); } if ( g_pPosNormalColUVDeclaration ) g_pPosNormalColUVDeclaration->Release(); if ( g_pPosColUVDeclaration ) g_pPosColUVDeclaration->Release(); if ( g_pPosNormalDeclaration ) g_pPosNormalDeclaration->Release(); Shader::ReleaseAllShaders(); if ( g_pCubeIbuffer ) g_pCubeIbuffer->Release(); if ( g_pCubeVbuffer ) g_pCubeVbuffer->Release(); // if ( g_backBuffer ) // g_backBuffer->Release(); // if ( g_oldDepthBuffer ) // g_oldDepthBuffer->Release(); if ( g_matrixStack ) g_matrixStack->Release(); if ( g_scratchTexture ) { g_scratchTexture->Release(); g_scratchTexture = NULL; } if ( m_pTextureFont ) { m_pTextureFont->Release(); m_pTextureFont = NULL; } if ( g_depthBuffer ) g_depthBuffer->Release(); }
void DXDirectionalLight::CreateShadowMap(LPDIRECT3DDEVICE9 device, DWORD type, DWORD size) { HRESULT hr; DXLight::CreateShadowMap(device, type, size); hr = device->CreateTexture(size, size, 1, D3DUSAGE_RENDERTARGET, D3DFMT_G32R32F, D3DPOOL_DEFAULT, &shadowmap, NULL); if( SUCCEEDED(hr) ) hr = device->CreateTexture(size, size, 1, D3DUSAGE_RENDERTARGET, D3DFMT_G32R32F, D3DPOOL_DEFAULT, &blur, NULL); if( FAILED(hr) ) { if( shadowmap ) shadowmap->Release(); shadowmap = blur = NULL; } if( !blurdeclforpointfordirectional ) { D3DVERTEXELEMENT9 elem[] = { { 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 }, { 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() }; device->CreateVertexDeclaration(elem, &blurdeclforpointfordirectional); } else blurdeclforpointfordirectional->AddRef(); }
DXDirectionalLight::~DXDirectionalLight() { if( shadowmap ) { shadowmap->Release(); shadowmap = 0; } if( blur ) { blur->Release(); blur = 0; } if( blurdeclforpointfordirectional ) { if( 0 == blurdeclforpointfordirectional->Release() ) blurdeclforpointfordirectional = 0; } }
DXPointLight::~DXPointLight() { if( shadowmap ) { shadowmap->Release(); shadowmap = 0; } if( blur ) { blur->Release(); blur = 0; } if( blurdeclforpoint ) { if( 0 == blurdeclforpoint->Release() ) blurdeclforpoint = 0; } }
VOID VertexData::AppendVertexDecl( LPDIRECT3DVERTEXDECLARATION9 pVertexDecl, DWORD dwStreamIndex ) { if( m_pVertexDecl == NULL ) { SetVertexDecl( pVertexDecl ); return; } DWORD dwExistingCount = MAXD3DDECLLENGTH + 1; D3DVERTEXELEMENT9 ExistingElements[MAXD3DDECLLENGTH + 1]; m_pVertexDecl->GetDeclaration( ExistingElements, (UINT*)&dwExistingCount ); DWORD dwNewCount = MAXD3DDECLLENGTH + 1; D3DVERTEXELEMENT9 NewElements[MAXD3DDECLLENGTH + 1]; pVertexDecl->GetDeclaration( NewElements, (UINT*)&dwNewCount ); AppendVertexElements( ExistingElements, dwStreamIndex, NewElements, 0, 0 ); D3DVertexDeclaration* pNewDecl = D3DDevice_CreateVertexDeclaration( ExistingElements ); SetVertexDecl( pNewDecl ); }
void Cleanup() { // release fonts if (gpFont) { gpFont->Release(); gpFont = NULL; } // release models if (gpTeapot) { gpTeapot->Release(); gpTeapot = NULL; } // release shaders if (gpEnvironmentMappingShader) { gpEnvironmentMappingShader->Release(); gpEnvironmentMappingShader = NULL; } if (gpNoEffect) { gpNoEffect->Release(); gpNoEffect = NULL; } if (gpGrayScale) { gpGrayScale->Release(); gpGrayScale = NULL; } if (gpSepia) { gpSepia->Release(); gpSepia = NULL; } // release textures if (gpStoneDM) { gpStoneDM->Release(); gpStoneDM = NULL; } if (gpStoneSM) { gpStoneSM->Release(); gpStoneSM = NULL; } if (gpStoneNM) { gpStoneNM->Release(); gpStoneNM = NULL; } if (gpSnowENV) { gpSnowENV->Release(); gpSnowENV = NULL; } // Release the fullscreen quad if (gpFullscreenQuadDecl) { gpFullscreenQuadDecl->Release(); gpFullscreenQuadDecl = NULL; } if (gpFullscreenQuadVB) { gpFullscreenQuadVB->Release(); gpFullscreenQuadVB = NULL; } if (gpFullscreenQuadIB) { gpFullscreenQuadIB->Release(); gpFullscreenQuadIB = NULL; } // release the render target if (gpSceneRenderTarget) { gpSceneRenderTarget->Release(); gpSceneRenderTarget = NULL; } // release D3D if (gpD3DDevice) { gpD3DDevice->Release(); gpD3DDevice = NULL; } if (gpD3D) { gpD3D->Release(); gpD3D = NULL; } }