VOID Cleanup() { if ( g_pMeshMaterials != NULL ) delete[] g_pMeshMaterials; if ( g_pMeshTextures ) { for ( DWORD i = 0; i < g_dwNumMaterials; ++i ) { if ( g_pMeshTextures[i] ) { g_pMeshTextures[i]->Release(); } } } if ( g_pMesh ) { g_pMesh->Release(); } if ( g_pTexture1 != NULL ) { g_pTexture1->Release(); } if ( g_pTexture2 != NULL ) { g_pTexture2->Release(); } if ( g_pVB1 != NULL ) { g_pVB1->Release(); } if ( g_pVB2 != NULL ) { g_pVB2->Release(); } if ( g_pd3dDevice != NULL ) { g_pd3dDevice->Release(); } if ( g_pD3D != NULL ) { g_pD3D->Release(); } }
VOID Cleanup() { if (NULL != g_pMeshMaterials0) { delete [] g_pMeshMaterials0; } if (g_pMeshTextures0) { for (DWORD i = 0; i < g_dwNumMaterials; ++i) { if (g_pMeshTextures0[i]) { g_pMeshTextures0[i]->Release(); } } delete [] g_pMeshTextures0; } if (NULL != g_pMesh0) { g_pMesh0->Release(); } if (NULL != g_pTexture0) { g_pTexture0->Release(); } if (NULL != g_pTexture1) { g_pTexture1->Release(); } if (NULL != g_pVertexBuffer0) { g_pVertexBuffer0->Release(); } if (NULL != g_pVertexBuffer1) { g_pVertexBuffer1->Release(); } if (NULL != g_pD3DDevice) { g_pD3DDevice->Release(); } if (NULL != g_pD3D) { g_pD3D->Release(); } }
//--------------------------------------------------------------------------------- // Name: ComputeBoundingBox // Desc: // pMin:[out] Pointer to a D3DXVECTOR3 structure, describing the returned lower-left // corner of the bounding box. See Remarks. // pMax:[out] Pointer to a D3DXVECTOR3 structure, describing the returned upper-right // corner of the bounding box. See Remarks. //--------------------------------------------------------------------------------- FLOAT CD3DMesh::ComputeBoundingBox(D3DXVECTOR3 *pMin, D3DXVECTOR3 *pMax ) { HRESULT hr; // Lock the vertex buffer, to generate a simple bounding sphere LPDIRECT3DVERTEXBUFFER9 pMeshVB = NULL; hr = m_pSysMemMesh->GetVertexBuffer( &pMeshVB ); if( SUCCEEDED(hr) ) { VOID * pVertices; hr = pMeshVB->Lock( 0, 0, &pVertices, D3DLOCK_NOSYSLOCK ); if( SUCCEEDED(hr) ) { hr = D3DXComputeBoundingBox( (D3DXVECTOR3 *)pVertices, m_pSysMemMesh->GetNumVertices(), D3DXGetFVFVertexSize(m_pSysMemMesh->GetFVF()), pMin, pMax); pMeshVB->Unlock(); } pMeshVB->Release(); } if( FAILED(hr) ) return 0; return 1; }
// this is the function that cleans up Direct3D and COM void cleanD3D(void) { v_buffer->Release(); // close and release the vertex buffer font->Release(); d3ddev->Release(); // close and release the 3D device d3d->Release(); // close and release Direct3D }
/**----------------------------------------------------------------------------- * 초기화 객체들 소거 *------------------------------------------------------------------------------ */ VOID Cleanup() { if ( g_pTexHeight != NULL ) { g_pTexHeight->Release(); } if ( g_pTexDiffuse != NULL ) { g_pTexDiffuse->Release(); } if ( g_pIB != NULL ) { g_pIB->Release(); } if ( g_pVB != NULL ) { g_pVB->Release(); } if ( g_pd3dDevice != NULL ) { g_pd3dDevice->Release(); } if ( g_pD3D != NULL ) { g_pD3D->Release(); } delete[] g_pvHeightMap; }
//------------------------------------------------------------------------------ VOID Cleanup() { if ( g_pIndexBuff ) { g_pIndexBuff->Release(); g_pIndexBuff = NULL; } if ( g_pVertexBuff ) { g_pVertexBuff->Release(); g_pVertexBuff = NULL; } if ( g_pd3dDevice ) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } if ( g_pD3D ) { g_pD3D->Release(); g_pD3D = NULL; } }
/**----------------------------------------------------------------------------- * 초기화 객체들 소거 *------------------------------------------------------------------------------ */ VOID Cleanup() { if ( g_pTexNormal != NULL ) { g_pTexNormal->Release(); } if ( g_pTexHeight != NULL ) { g_pTexHeight->Release(); } if ( g_pTexDiffuse != NULL ) { g_pTexDiffuse->Release(); } if ( g_pIB != NULL ) { g_pIB->Release(); } if ( g_pVB != NULL ) { g_pVB->Release(); } if ( g_pd3dDevice != NULL ) { g_pd3dDevice->Release(); } if ( g_pD3D != NULL ) { g_pD3D->Release(); } }
//----------------------------------------------------------------------------- // Name: Cleanup() // Desc: Releases all previously initialized objects //----------------------------------------------------------------------------- VOID Cleanup() { if( g_pTexture != NULL ) g_pTexture->Release(); if( g_pVB != NULL ) g_pVB->Release(); if( g_pVB2 != NULL ) g_pVB2->Release(); if( g_pd3dDevice != NULL ) g_pd3dDevice->Release(); if( g_pD3D != NULL ) g_pD3D->Release(); }
VOID cleanup(){ if(g_pVB != NULL) g_pVB->Release(); if(g_pDevice != NULL) g_pDevice->Release(); if(g_pD3D != NULL) g_pD3D->Release(); }
//----------------------------------------------------------------------------- // Name: Cleanup() // Desc: Releases all previously initialized objects //----------------------------------------------------------------------------- VOID CDlg::Cleanup() { if( g_pVB != NULL ) g_pVB->Release(); if( g_pd3dDevice != NULL ) g_pd3dDevice->Release(); if( g_pD3D != NULL ) g_pD3D->Release(); }
//モーフィング処理の実行。 //morphTarget モーフターゲット //rate モーフィングレート。 void Model::Morphing(Model* morphTargetA, Model* morphTargetB, float rate) { //モーフターゲットAのメッシュを取得。 LPD3DXMESH targetMesh_A= morphTargetA->GetMesh(); //モーフターゲットAの頂点バッファを取得する。 LPDIRECT3DVERTEXBUFFER9 targetVertexBuffer_A; targetMesh_A->GetVertexBuffer(&targetVertexBuffer_A); //頂点バッファの定義を取得する。 D3DVERTEXBUFFER_DESC desc; targetVertexBuffer_A->GetDesc(&desc); //頂点ストライドを計算する。 int stride = desc.Size / targetMesh_A->GetNumVertices(); //モーフターゲットBのメッシュを取得する。 LPD3DXMESH targetMesh_B = morphTargetB->GetMesh(); //モーフターゲットBの頂点バッファを取得する。 LPDIRECT3DVERTEXBUFFER9 targetVertexBuffer_B; targetMesh_B->GetVertexBuffer(&targetVertexBuffer_B); //自分の頂点バッファを取得する。 LPDIRECT3DVERTEXBUFFER9 vertexBuffer; mesh->GetVertexBuffer(&vertexBuffer); D3DXVECTOR3* vertexPos; D3DXVECTOR3* targetVertexPos_A; D3DXVECTOR3* targetVertexPos_B; //頂点バッファをロック。 vertexBuffer->Lock(0, desc.Size, (void**)&vertexPos, D3DLOCK_DISCARD); targetVertexBuffer_A->Lock(0, desc.Size, (void**)&targetVertexPos_A, D3DLOCK_DISCARD); targetVertexBuffer_B->Lock(0, desc.Size, (void**)&targetVertexPos_B, D3DLOCK_DISCARD); for (int vertNo = 0; vertNo < targetMesh_A->GetNumVertices(); vertNo++) { /////////////////////////////////////////////////////////////////// //ここに頂点モーフの処理を記述する。 /////////////////////////////////////////////////////////////////// //次の頂点へ。 char* p = (char*)vertexPos; p += stride; vertexPos = (D3DXVECTOR3*)p; p = (char*)targetVertexPos_A; p += stride; targetVertexPos_A = (D3DXVECTOR3*)p; p = (char*)targetVertexPos_B; p += stride; targetVertexPos_B = (D3DXVECTOR3*)p; } //頂点バッファをアンロック。 vertexBuffer->Unlock(); targetVertexBuffer_A->Unlock(); targetVertexBuffer_B->Unlock(); vertexBuffer->Release(); targetVertexBuffer_A->Release(); targetVertexBuffer_B->Release(); }
void cleanD3d(void) { d3d9VertexBuffer1->Release(); d3d9VertexBuffer2->Release(); if (mesh1 != NULL) mesh1->Release(); if (mesh2 != NULL) mesh2->Release(); if (mesh3 != NULL) mesh3->Release(); if (texture1 != NULL) texture1->Release(); if (texture2 != NULL) texture2->Release(); if (texture3 != NULL) texture3->Release(); if (sprite != NULL) sprite->Release(); if (spriteTexture != NULL) spriteTexture->Release(); if (legendSprite != NULL) legendSprite->Release(); if (legendTexture != NULL) legendTexture->Release(); for (DWORD i = 0; i < numMaterials; i++) // customized cause I use textures from resources if ((i != 1) && (i != 3) && (i != 4) && (i != 6) && planeTexture[i] != NULL) planeTexture[i]->Release(); d3d9dev->Release(); d3d9->Release(); return; }
/******************************************************************************* * UninitGameStart *******************************************************************************/ void UninitTitleGameStart(void) { if(g_pTextureTitleGameStart != NULL) { g_pTextureTitleGameStart->Release(); g_pTextureTitleGameStart = NULL; } if(g_pVtxBufferTitleGameStart != NULL) { g_pVtxBufferTitleGameStart->Release(); g_pVtxBufferTitleGameStart = NULL; } }
/******************************************************************************* * UninitGameName *******************************************************************************/ void UninitTitleGameName(void) { if(g_pTextureTitleGameName != NULL) { g_pTextureTitleGameName->Release(); g_pTextureTitleGameName = NULL; } if(g_pVtxBufferTitleGameName != NULL) { g_pVtxBufferTitleGameName->Release(); g_pVtxBufferTitleGameName = NULL; } }
HRESULT initGeometry(){ LPD3DXBUFFER pD3DXMtrlBuffer; if(FAILED(D3DXLoadMeshFromX(L"seafloor.x", D3DXMESH_MANAGED, g_pDevice, NULL, &pD3DXMtrlBuffer, NULL, &g_dwNumMaterials, &g_pMesh))) return E_FAIL; //Extract material & texture D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); g_pMeshMaterials = new D3DMATERIAL9[g_dwNumMaterials]; if(g_pMeshMaterials == NULL) return E_OUTOFMEMORY; g_pMeshTextures = new LPDIRECT3DTEXTURE9[g_dwNumMaterials]; if(g_pMeshTextures == NULL) return E_OUTOFMEMORY; //Extract for(DWORD i=0; i<g_dwNumMaterials; ++i){ g_pMeshMaterials[i] = d3dxMaterials[i].MatD3D; g_pMeshMaterials[i].Ambient = g_pMeshMaterials[i].Diffuse; g_pMeshTextures[i] = NULL; if(d3dxMaterials[i].pTextureFilename != NULL && strlen(d3dxMaterials[i].pTextureFilename) > 0){ WCHAR name[256]; removePathFromFileName(d3dxMaterials[i].pTextureFilename, name); if(FAILED(D3DXCreateTextureFromFile(g_pDevice, name, &g_pMeshTextures[i]))){ MessageBox(NULL, L"Cound not find texture file", L"initGeometry()", MB_OK); } } } pD3DXMtrlBuffer->Release(); //Modify the mesh LPDIRECT3DVERTEXBUFFER9 pVB; if(SUCCEEDED(g_pMesh->GetVertexBuffer(&pVB))){ struct VERTEX{FLOAT x,y,z,tu,tv;}; VERTEX* pVertices; DWORD dwNumVertices = g_pMesh->GetNumVertices(); pVB->Lock(0,0,(void**)&pVertices, 0); for(DWORD i=0; i<dwNumVertices; ++i) pVertices[i].y = heightField(pVertices[i].x, pVertices[i].z); pVB->Unlock(); pVB->Release(); } return S_OK; };
//============================================================================= // 終了処理 //============================================================================= void UninitEffect(void) { if(g_pD3DTextureEffect != NULL) {// テクスチャの開放 g_pD3DTextureEffect->Release(); g_pD3DTextureEffect = NULL; } if(g_pD3DVtxBuffEffect != NULL) {// 頂点バッファの開放 g_pD3DVtxBuffEffect->Release(); g_pD3DVtxBuffEffect = NULL; } }
//----------------------------------------------------------------------------- // Desc: 释放创建的对象 //----------------------------------------------------------------------------- VOID Cleanup() { //释放顶点缓冲区对象 if( g_pVB != NULL ) g_pVB->Release(); //释放Direct3D设备对象 if( g_pd3dDevice != NULL ) g_pd3dDevice->Release(); //释放Direct3D对象 if( g_pD3D != NULL ) g_pD3D->Release(); }
//============================================================================= // 終了処理 //============================================================================= void UninitExplosion(void) { if(g_pD3DTextureExplosion != NULL) {// テクスチャの開放 g_pD3DTextureExplosion->Release(); g_pD3DTextureExplosion = NULL; } if(g_pD3DVtxBuffExplosion != NULL) {// 頂点バッファの開放 g_pD3DVtxBuffExplosion->Release(); g_pD3DVtxBuffExplosion = NULL; } }
//============================================================================= // 終了処理 //============================================================================= void UninitBillboard(void) { if(g_pD3DTextureBillboard != NULL) {// テクスチャの開放 g_pD3DTextureBillboard->Release(); g_pD3DTextureBillboard = NULL; } if(g_pD3DVtxBuffBillboard != NULL) {// 頂点バッファの開放 g_pD3DVtxBuffBillboard->Release(); g_pD3DVtxBuffBillboard = NULL; } }
VOID Cleanup() { if( g_pVB != NULL ) g_pVB->Release(); if( g_pd3dDevice != NULL ) g_pd3dDevice->Release(); if( g_pD3D != NULL ) g_pD3D->Release(); if(Objects != NULL){ Objects->Release(); } }
VOID Cleanup() { // meshes if ( g_pMeshMaterials != NULL ) delete[] g_pMeshMaterials; if ( g_pMeshTextures ) { for ( DWORD i = 0; i < g_dwNumMaterials; ++i ) { if ( g_pMeshTextures[i] ) g_pMeshTextures[i]->Release(); } delete[] g_pMeshTextures; } if ( g_pMesh != NULL ) g_pMesh->Release(); if ( g_pMeshMaterialsSecond != NULL ) delete[] g_pMeshMaterialsSecond; if ( g_pMeshTexturesSecond ) { for ( DWORD i = 0; i < g_dwNumMaterialsSecond; ++i ) { if ( g_pMeshTexturesSecond[i] ) g_pMeshTexturesSecond[i]->Release(); } delete[] g_pMeshTexturesSecond; } if ( g_pMeshSecond != NULL ) g_pMeshSecond->Release(); // cylinder if ( g_pTexture != NULL ) g_pTexture->Release(); if ( g_pVB != NULL ) g_pVB->Release(); if ( g_pd3dDevice != NULL ) g_pd3dDevice->Release(); if ( g_pD3D != NULL ) g_pD3D->Release(); }
//=============================================== //頂点情報のコンバート //=============================================== //[input] // pD3DX9:Direct3Dデバイス //[return] // HREULT値 //=============================================== bool CXMesh::ConvertVertex(LPDIRECT3DDEVICE9 pD3DX9) { LPD3DXBUFFER pD3DXMtrlBuffer = NULL; /*Vertex Bufferにコピーする*/ D3DVERTEX* pSrc; D3DVERTEX* pDest; LPDIRECT3DINDEXBUFFER9 pSrcIndex; WORD* pISrc; WORD* pIDest; /*VertexBuffer情報取得*/ LPDIRECT3DVERTEXBUFFER9 pVB; MeshData.pMesh->GetVertexBuffer(&pVB); D3DVERTEXBUFFER_DESC Desc; pVB->GetDesc( &Desc ); DWORD nMeshVertices = MeshData.pMesh->GetNumVertices(); DWORD nMeshFaces = MeshData.pMesh->GetNumFaces(); /*頂点バッファを作成*/ pD3DX9->CreateVertexBuffer( Desc.Size, 0, MeshData.pMesh->GetFVF(), D3DPOOL_MANAGED, &m_pMeshVB, NULL ); /*インデックスバッファを作成*/ pD3DX9->CreateIndexBuffer( nMeshFaces * 3 * sizeof(WORD), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pMeshIndex, NULL ); /*頂点バッファをコピー*/ pVB->Lock(0,0,(void**)&pSrc,0); m_pMeshVB->Lock(0,0,(void**)&pDest,0); CopyMemory( pDest, pSrc, Desc.Size ); pVB->Unlock(); pVB->Release(); m_pMeshVB->Unlock(); /*インデックスのコピー*/ MeshData.pMesh->GetIndexBuffer( &pSrcIndex ); pSrcIndex->Lock( 0, 0, (void**)&pISrc, 0 ); m_pMeshIndex->Lock( 0, 0, (void**)&pIDest, 0 ); CopyMemory( pIDest, pISrc, nMeshFaces * 3 * sizeof( WORD ) ); pSrcIndex->Unlock(); m_pMeshIndex->Unlock(); pSrcIndex->Release(); return true; }
VOID shutDown() { if (d3dDevice != NULL) { d3dDevice->Release(); d3dDevice = NULL; } if (d3dManager != NULL) { d3dManager->Release(); d3dManager = NULL; } if (d3dVertexBuf != NULL) { d3dVertexBuf->Release(); d3dVertexBuf = NULL; } }
////////////////////////////////////////////////////////////////////////// // 객체 정리 - 순서 주의! ////////////////////////////////////////////////////////////////////////// VOID Cleanup() { if ( g_pVB != NULL ) { g_pVB->Release(); } if ( g_pd3dDevice != NULL ) { g_pd3dDevice->Release(); } if ( g_pD3D != NULL ) { g_pD3D->Release(); } }
// this is the function that cleans up Direct3D and COM void cleanD3D(void) { if (d3ddev != NULL) { d3ddev->Release(); } if (d3ddev != NULL) { d3d->Release(); } if (tx != NULL) { tx->Release(); } if (vb != NULL) { vb->Release(); } if (font != NULL) { font->Release(); } }
//============================================================================= // 終了処理 //============================================================================= void UninitPlaybar(void) { for(int nCntTex = 0; nCntTex < MAX_PLAYBAR; nCntTex++) { if(g_apD3DTexturePlaybar[nCntTex] != NULL) {// テクスチャの開放 g_apD3DTexturePlaybar[nCntTex]->Release(); g_apD3DTexturePlaybar[nCntTex] = NULL; } } if(g_pD3DVtxBuffPlaybar != NULL) {// 頂点バッファの開放 g_pD3DVtxBuffPlaybar->Release(); g_pD3DVtxBuffPlaybar = NULL; } }
void ReleaseD3D() { if (g_pVB) g_pVB->Release(); if(g_pDevice) { g_pDevice->Release(); g_pDevice = NULL; } if(g_pD3D) { g_pD3D->Release(); g_pD3D = NULL; } }
//============================================================================= // 終了処理 //============================================================================= void UninitBotton(void) { for(int nCntTex = 0; nCntTex < MAX_BOTTON; nCntTex++) { if(g_apD3DTextureBotton[nCntTex] != NULL) {// テクスチャの開放 g_apD3DTextureBotton[nCntTex]->Release(); g_apD3DTextureBotton[nCntTex] = NULL; } } if(g_pD3DVtxBuffBotton != NULL) {// 頂点バッファの開放 g_pD3DVtxBuffBotton->Release(); g_pD3DVtxBuffBotton = NULL; } }
//----------------------------------------------------------------------------- // Name: Cleanup() // Desc: Releases all previously initialized objects //----------------------------------------------------------------------------- VOID Cleanup() { if( g_pFont != NULL ) g_pFont->Release(); if( g_pVBCylinder != NULL ) g_pVBCylinder->Release(); if (g_pTexture != NULL ) g_pTexture->Release(); if (g_pTexture2 != NULL ) g_pTexture2->Release(); if( g_pd3dDevice != NULL ) g_pd3dDevice->Release(); if( g_pD3D != NULL ) g_pD3D->Release(); }
void release_objects() { if ( lpsurface ) { lpsurface->Release(); lpsurface = 0; } if ( lptex ) { lptex->Release(); lptex = 0; } if ( lpvbuf ) { lpvbuf->Release(); lpvbuf = 0; } }