/**----------------------------------------------------------------------------- * 초기화 객체들 소거 *------------------------------------------------------------------------------ */ 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_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(); } }
void Game_End() { if (imgShip) imgShip->Release(); if (imgAsteroid) imgAsteroid->Release(); DirectInput_Shutdown(); Direct3D_Shutdown(); }
void freeTexture() { if (hmap_o) delete[] hmap_o; hmap_o = NULL; if (dmap ) delete[] dmap ; dmap = NULL; if (tnrm) tnrm->Release(); tnrm = NULL; if (thgt) thgt->Release(); thgt = NULL; if (tcol) tcol->Release(); tcol = NULL; }
void Cleanup() { // 폰트를 release 한다. if (gpFont) { gpFont->Release(); gpFont = NULL; } // 모델을 release 한다. if (gpSphere) { gpSphere->Release(); gpSphere = NULL; } // 쉐이더를 release 한다. if (gpNormalMappingShader) { gpNormalMappingShader->Release(); gpNormalMappingShader = NULL; } // 텍스처를 release 한다. if (gpStoneDM) { gpStoneDM->Release(); gpStoneDM = NULL; } if (gpStoneSM) { gpStoneSM->Release(); gpStoneSM = NULL; } if (gpStoneNM) { gpStoneNM->Release(); gpStoneNM = NULL; } // D3D를 release 한다. if (gpD3DDevice) { gpD3DDevice->Release(); gpD3DDevice = NULL; } if (gpD3D) { gpD3D->Release(); gpD3D = NULL; } }
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(); } }
// this is the function that cleans up Direct3D and COM void cleanD3D(void) { v_buffer->Release(); // close and release the vertex buffer pTexture->Release(); d3ddev->Release(); // close and release the 3D device d3d->Release(); // close and release Direct3D }
void CD3DCG::ensureTextureSize(LPDIRECT3DTEXTURE9 &tex, D3DXVECTOR2 &texSize, D3DXVECTOR2 wantedSize,bool renderTarget) { HRESULT hr; if(!tex || texSize != wantedSize) { if(tex) tex->Release(); hr = pDevice->CreateTexture( wantedSize.x, wantedSize.y, 1, // 1 level, no mipmaps renderTarget?D3DUSAGE_RENDERTARGET:0, renderTarget?D3DFMT_X8R8G8B8:D3DFMT_R5G6B5, renderTarget?D3DPOOL_DEFAULT:D3DPOOL_MANAGED, // render targets cannot be managed &tex, NULL ); texSize = wantedSize; if(FAILED(hr)) { DXTRACE_ERR_MSGBOX(TEXT("Error while creating texture"), hr); return; } } }
void Renderer::ReleaseTexture( LPDIRECT3DTEXTURE9 pTexture ) { if ( pTexture ) { pTexture->Release(); } }
//============================================================ // 終了処理 //============================================================ void UninitFade(void){ if(g_pTextureFade != NULL){ //テクスチャの開放 g_pTextureFade->Release(); g_pTextureFade = NULL; } }
void dx9vid_shutdown() { g_screenSprite->Release(); // release the screen sprite g_screenTex->Release(); // release the screen texture d3ddev->Release(); // close and release the 3D device d3d->Release(); // close and release Direct3D }
lpta::LptaTexture::DATA LptaD3DTextureManager::GenerateDefaultData(void) { LPDIRECT3DTEXTURE9 textureData = nullptr; D3DLOCKED_RECT d3dLockedRect; HRESULT result = d3ddev->CreateTexture( DEFAULT_TEXTURE_WIDTH, DEFAULT_TEXTURE_HEIGHT, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &textureData, nullptr ); if (FAILED(result)) { throw TextureD3DFailure("could not obtain texture object for default"); } result = textureData->LockRect(0, &d3dLockedRect, nullptr, 0); if (FAILED(result)) { textureData->Release(); throw TextureD3DFailure("failed to lock rectangle to set default texture color"); } unsigned long *rawData = (unsigned long *)d3dLockedRect.pBits; for (unsigned long *pixel = rawData; pixel < rawData + (DEFAULT_TEXTURE_WIDTH * DEFAULT_TEXTURE_HEIGHT); ++pixel) { *pixel = DEFAULT_TEXTURE_COLOR; } textureData->UnlockRect(0); return (lpta::LptaTexture::DATA)textureData; }
void cleanup() // it's a dirty job.. but some function has to do it... { if (myRect1) delete myRect1; if (myRect2) delete myRect2; if (myRect3) delete myRect3; if (myRect4) delete myRect4; if (myRect5) delete myRect5; if ( lpD3DDevice9 != NULL ) lpD3DDevice9->Release(); if ( lpD3D9 != NULL ) lpD3D9->Release(); if ( lpD3DXFont != NULL ) lpD3DXFont->Release(); if ( lpD3DTex1 != NULL ) lpD3DTex1->Release(); }
int l_Image_Load( lua_State* L ) { D3DXIMAGE_INFO imgInfo; const char* fileName = lua_tostring( L, 1 ); bool dxtCompression = false; D3DFORMAT d3dfmt = D3DFMT_UNKNOWN; //check for dds format { if( _strcmpi( "dds", fileName + strlen( fileName ) - 3 ) == 0 ) { DDSHEAD header; FILE* f; if(fopen_s( &f, fileName, "rb" ) == 0) { if( fread( &header, sizeof(header), 1, f ) == 1 ) { if( strncmp( (const char*)header.Signature, "DDS ", 4 ) == 0 && ( header.FourCC == D3DFMT_DXT1 || header.FourCC == D3DFMT_DXT3 || header.FourCC == D3DFMT_DXT5 ) ) { d3dfmt = D3DFMT_A8R8G8B8; } } fclose(f); } } } LPDIRECT3DTEXTURE9 texture; HRESULT hr = D3DXCreateTextureFromFileEx( g_pd3dDevice, fileName, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, D3DX_FROM_FILE, 0, d3dfmt, D3DPOOL_SCRATCH, D3DX_DEFAULT, D3DX_DEFAULT, 0, &imgInfo, 0, &texture ); if( FAILED( hr ) ) { return 0; } ImageData* imgData = createImage(); imgData->width = imgInfo.Width; imgData->height = imgInfo.Height; imgData->format = getFormatByD3D( imgInfo.Format ); imgData->imgData = malloc( imgData->width * imgData->height * imgData->format->bytesPerPixel ); D3DLOCKED_RECT rect; texture->LockRect(0, &rect, 0, 0 ); memcpy( imgData->imgData, rect.pBits, imgData->width * imgData->height * imgData->format->bytesPerPixel ); texture->UnlockRect( 0 ); texture->Release(); //lua_pushlightuserdata( L, imgData ); ImageData** luaData = lua_pushimage( L ); *luaData = imgData; return 1; }
void Game_End() { //free memory and shut down paladin->Release(); DirectInput_Shutdown(); Direct3D_Shutdown(); }
void DevState::releaseData() { ods("D3D9: Release Data"); if (texTexture) { texTexture->Release(); texTexture = NULL; } }
int l_Image_Save( lua_State* L ) { ImageData* imgData = lua_checkimage( L, 1 ); const char* fileName = lua_tostring( L, 2 ); if( !imgData || !fileName ) { lua_pushstring( L, "Wrong parameters to Image_Save functions" ); lua_error( L ); return 0; } LPDIRECT3DTEXTURE9 texture; D3DLOCKED_RECT rect; D3DFORMAT dxFormat = (D3DFORMAT)imgData->format->d3dformat; if( dxFormat == D3DFMT_DXT1 || dxFormat == D3DFMT_DXT3 || dxFormat == D3DFMT_DXT5 ) dxFormat = D3DFMT_A8R8G8B8; g_pd3dDevice->CreateTexture( imgData->width, imgData->height, 1, 0, dxFormat, D3DPOOL_MANAGED, &texture, 0 ); texture->LockRect(0, &rect, 0, 0 ); memcpy( rect.pBits, imgData->imgData, imgData->width * imgData->height * imgData->format->bytesPerPixel ); texture->UnlockRect( 0 ); if( imgData->format->d3dformat == D3DFMT_DXT1 || imgData->format->d3dformat == D3DFMT_DXT3 || imgData->format->d3dformat == D3DFMT_DXT5 ) { ID3DXBuffer* dxBuffer; LPDIRECT3DTEXTURE9 outTexture; D3DXSaveTextureToFileInMemory( &dxBuffer, D3DXIFF_BMP, texture, 0 ); D3DXCreateTextureFromFileInMemoryEx( g_pd3dDevice, dxBuffer->GetBufferPointer(), dxBuffer->GetBufferSize(), imgData->width, imgData->height, 0, 0, (D3DFORMAT)imgData->format->d3dformat, D3DPOOL_SCRATCH, D3DX_DEFAULT, D3DX_DEFAULT, 0, 0, 0, &outTexture ); D3DXSaveTextureToFile( fileName, extToFormat(fileName), outTexture, 0 ); outTexture->Release(); }else { D3DXSaveTextureToFile( fileName, extToFormat(fileName), texture, 0 ); } texture->Release(); return 0; }
static void resetAdditions() { if(imagetex) imagetex->Release(); imagetex = NULL; if(sprite) sprite->Release(); sprite = 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 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; }
void SetD3DResourcePrivateData(LPDIRECT3DRESOURCE9 res, const char* FName) { #if R3D_SET_DEBUG_D3D_NAMES DWORD sz = strlen(FName); res->SetPrivateData(WKPDID_D3DDebugObjectName, FName, sz, 0); void* p = 0; res->QueryInterface(IID_IDirect3DTexture9, &p); if(p) { LPDIRECT3DTEXTURE9 t = (LPDIRECT3DTEXTURE9)p; int mipsCount = t->GetLevelCount(); for (int i = 0; i < mipsCount; ++i) { LPDIRECT3DSURFACE9 surf; t->GetSurfaceLevel(i, &surf); surf->SetPrivateData(WKPDID_D3DDebugObjectName, FName, sz, 0); surf->Release(); } t->Release(); return; } p = 0; res->QueryInterface(IID_IDirect3DCubeTexture9, &p); if(p) { LPDIRECT3DCUBETEXTURE9 t = (LPDIRECT3DCUBETEXTURE9)p; int mipsCount = t->GetLevelCount(); for (int i = 0; i < mipsCount; ++i) { for (int j = D3DCUBEMAP_FACE_POSITIVE_X; j <= D3DCUBEMAP_FACE_NEGATIVE_Z; ++j) { LPDIRECT3DSURFACE9 surf; t->GetCubeMapSurface((D3DCUBEMAP_FACES)j, i, &surf); surf->SetPrivateData(WKPDID_D3DDebugObjectName, FName, sz, 0); surf->Release(); } } t->Release(); return; } #endif }
/******************************************************************************* * UninitGameName *******************************************************************************/ void UninitTitleGameName(void) { if(g_pTextureTitleGameName != NULL) { g_pTextureTitleGameName->Release(); g_pTextureTitleGameName = NULL; } if(g_pVtxBufferTitleGameName != NULL) { g_pVtxBufferTitleGameName->Release(); g_pVtxBufferTitleGameName = NULL; } }
//----------------------------------------------------------------------------- // Desc: 释放除创建的对象 //----------------------------------------------------------------------------- VOID Cleanup() { //释放纹理对象1 if( g_pTexture1 != NULL ) g_pTexture1->Release(); //释放纹理对象2 if( g_pTexture2 != NULL ) g_pTexture2->Release(); //释放顶点缓冲区对象 if( g_pVB != NULL ) g_pVB->Release(); //释放Direct3D设备对象 if( g_pd3dDevice != NULL ) g_pd3dDevice->Release(); //释放Direct3D对象 if( g_pD3D != NULL ) g_pD3D->Release(); }
/******************************************************************************* * UninitGameStart *******************************************************************************/ void UninitTitleGameStart(void) { if(g_pTextureTitleGameStart != NULL) { g_pTextureTitleGameStart->Release(); g_pTextureTitleGameStart = NULL; } if(g_pVtxBufferTitleGameStart != NULL) { g_pVtxBufferTitleGameStart->Release(); g_pVtxBufferTitleGameStart = NULL; } }
//============================================================================= // 終了処理 //============================================================================= 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; } }
//----------------------------------------------------------------------------- // 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_pd3dDevice != NULL ) g_pd3dDevice->Release(); if( g_pD3D != NULL ) g_pD3D->Release(); }
//============================================================================= // 終了処理 //============================================================================= void UninitEffect(void) { if(g_pD3DTextureEffect != NULL) {// テクスチャの開放 g_pD3DTextureEffect->Release(); g_pD3DTextureEffect = NULL; } if(g_pD3DVtxBuffEffect != NULL) {// 頂点バッファの開放 g_pD3DVtxBuffEffect->Release(); g_pD3DVtxBuffEffect = NULL; } }
//----------------------------------------------------------------------------- // Name: Cleanup() // Desc: Releases all previously initialized objects //----------------------------------------------------------------------------- VOID Cleanup() { // release all textures used if ( g_pTexture != NULL ) g_pTexture->Release(); if ( g_pTexture2 != NULL ) g_pTexture2->Release(); if ( marbleTexture != NULL ) marbleTexture->Release(); if ( backgroundTexture != NULL ) backgroundTexture->Release(); 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_pd3dDevice != NULL ) g_pd3dDevice->Release(); if( g_pD3D != NULL ) g_pD3D->Release(); }