예제 #1
0
BOOL InitD3D(HWND hwnd)
{
	HRESULT hr;
	D3DDISPLAYMODE disp_mode;
	D3DPRESENT_PARAMETERS pp;

	if (g_bSetupOK) return TRUE;

	if (g_pD3D) return FALSE;

	g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
	if (!g_pD3D) return FALSE;
	
	hr = g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &disp_mode);
	if (FAILED(hr)) 
	{
		g_pD3D->Release();
		g_pD3D = NULL;
		return FALSE;
	}
	
	ZeroMemory(&pp, sizeof(D3DPRESENT_PARAMETERS));
	pp.Windowed = true;
	pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	pp.BackBufferFormat = disp_mode.Format;
	pp.EnableAutoDepthStencil = TRUE;
	pp.AutoDepthStencilFormat = D3DFMT_D16;
    pp.BackBufferCount = 1;

	BOOL flgSoft = GetPrivateProfileInt("GENERIC","LEVEL",1,".\\TDWGame.ini");

	char buff[256];
	wsprintf(buff,"%d",flgSoft);
	WritePrivateProfileString("GENERIC","LEVEL",buff,".\\TDWGame.ini");

	hr = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&pp,&g_pD3DDevice);
	if (FAILED(hr))
	{
		hr = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pp,&g_pD3DDevice);
		if (FAILED(hr)) 
		{
			hr = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pp,&g_pD3DDevice);
			if (FAILED(hr)) 
			{
				g_pD3D->Release();
				g_pD3D = NULL;
				return FALSE;
			}
		}
	}

	D3DCAPS9 DX9DCaps;
	g_pD3DDevice->GetDeviceCaps(&DX9DCaps);
	g_bSetupOK = TRUE;
	return TRUE;	
}
예제 #2
0
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
}
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_pD3DDevice )
	{
		g_pD3DDevice->Release();
	}

	if ( NULL != g_pD3D )
	{
		g_pD3D->Release();
	}
}
/**-----------------------------------------------------------------------------
 * 초기화 객체들 소거
 *------------------------------------------------------------------------------
 */
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;
}
예제 #5
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int cmdShow)
{
    gui.reset(new GUI::GuiWrapper());
    simulation.reset(new Simulation());

    runSimulation = 
        InitialiseWindow(&hInstance) && 
        InitialiseDirectX() &&  
        simulation->CreateSimulation(hInstance, hWnd, d3ddev) &&
        InitialiseGUI();

    while(runSimulation && gui->Update())
    {
        simulation->Update();
        simulation->Render();
    }

    d3ddev->Release();
    d3d->Release();
    backBuffer->Release();

    #ifdef _DEBUG
    OutputDebugString("Exiting Simulation\n");
    #endif
}
/**-----------------------------------------------------------------------------
 * 초기화 객체들 소거
 *------------------------------------------------------------------------------
 */
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();
    }
}
예제 #7
0
//-----------------------------------------------------------------------------
// Desc: 释放创建的对象
//-----------------------------------------------------------------------------
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();
		}
		delete[] g_pMeshTextures;
	}

	//释放网格模型对象
	if( g_pMesh != NULL )
		g_pMesh->Release();

	//释放Direct3D设备对象
	if( g_pd3dDevice != NULL )
		g_pd3dDevice->Release();

	//释放Direct3D对象
	if( g_pD3D != NULL )
		g_pD3D->Release();
}
예제 #8
0
void Direct3D_Shutdown()
{
    if (spriteobj) spriteobj->Release();

    if (d3ddev) d3ddev->Release();
    if (d3d) d3d->Release();
}
예제 #9
0
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();
}
예제 #10
0
파일: main.cpp 프로젝트: m3lawren/ClothDemo
// 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
}
예제 #11
0
// リソースの解放
void CleanupD3D()
{
	for (int i = 0; i < MAXMODEL; i = i + 1)
	{
		if (g_models[i].used == TRUE)
		{
			if (g_models[i].pmaterials != NULL)
			{
				delete[] g_models[i].pmaterials;
			}
			if (g_models[i].ptextures != NULL)
			{
				for (DWORD j = 0; j < g_models[i].nummaterials; j = j + 1)
				{
					g_models[i].ptextures[j]->Release();
				}
				delete[] g_models[i].ptextures;
			}
			if (g_models[i].pmesh != NULL)
			{
				g_models[i].pmesh->Release();
			}
		}
	}
	if (g_pd3dDevice != NULL) g_pd3dDevice->Release();
	if (g_pD3D != NULL) g_pD3D->Release();

	if (g_pDIDevice != NULL)
	{
		g_pDIDevice->Unacquire();
		g_pDIDevice->Release();
	}
	if (g_pDI != NULL) g_pDI->Release();
}
예제 #12
0
RageDisplay_D3D::~RageDisplay_D3D()
{
	LOG->Trace( "RageDisplay_D3D::~RageDisplay()" );

	GraphicsWindow::Shutdown();

	if( g_pd3dDevice )
	{
		g_pd3dDevice->Release();
		g_pd3dDevice = NULL;
	}

	if( g_pd3d )
	{
		g_pd3d->Release();
		g_pd3d = NULL;
	}

	/* Even after we call Release(), D3D may still affect our window. It seems
	 * to subclass the window, and never release it. Free the DLL after
	 * destroying the window. */
	if( g_D3D9_Module )
	{
		FreeLibrary( g_D3D9_Module );
		g_D3D9_Module = 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_pd3dDevice != NULL )
	{
		g_pd3dDevice->Release();
	}

	if ( g_pD3D != NULL )
	{
		g_pD3D->Release();
	}
}
예제 #14
0
//------------------------------------------------------------------------------
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; }
}
예제 #15
0
파일: winsetup.cpp 프로젝트: Thyfate/melax
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
static void Cleanup()
{
    if( g_pd3dDevice != NULL )
        g_pd3dDevice->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}
예제 #16
0
VOID cleanup(){
	if(g_pVB != NULL)
		g_pVB->Release();
	if(g_pDevice != NULL)
		g_pDevice->Release();
	if(g_pD3D != NULL)
		g_pD3D->Release();
}
예제 #17
0
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
    if( g_pd3dDevice != NULL )
        g_pd3dDevice->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}
예제 #18
0
파일: Main.cpp 프로젝트: bafory/DTX
void shutDown( void )
{
    if( g_pd3dDevice != NULL )
        g_pd3dDevice->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}
예제 #19
0
파일: direct3d.cpp 프로젝트: ppeschke/hexar
// Close the Device and Direct3D
void CloseDirect3D()
{
	dxfont->Release();
	dxfontpeschkes->Release();
    d3ddev->Release();
    d3d->Release();

    return;
}
예제 #20
0
파일: main.cpp 프로젝트: Xekep/Legacy-Code
//151.
// this is the function that cleans up Direct3D and COM
// 152.
void cleanD3D(void)
// 153.
{
// 154.
    d3ddev->Release(); // close and release the 3D device
// 155.
    d3d->Release(); // close and release Direct3D

}
예제 #21
0
파일: d3dwm.cpp 프로젝트: Hrnchamd/MGE-XE
int D3DWMClose(void)
{
    if (D3DWMContext)
    {
        D3DWMContext->Release();
        D3DWMContext = NULL;
    }

    return 0;
}
예제 #22
0
//==================================
//  函数:D3DRelease()
//  目的:释放Direct3D及Direct3D设备对象
//
VOID D3DRelease()
{
	ReleaseVertex();

    if( g_pd3dD != NULL )
        g_pd3dD->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}
예제 #23
0
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;
	}
}
예제 #24
0
파일: main.cpp 프로젝트: JueSungMun/TOK
//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
	if (sprite != NULL)
		sprite->Release();
	if( renderDevice != NULL ) 
		renderDevice->Release();
	if( g_pD3D != NULL )       
		g_pD3D->Release();
	if( bg != NULL)
		delete bg;
}
예제 #25
0
	void ShutdownGraphics() {
		if(spriteHandler) {
			spriteHandler->Release();
		}
		if(device) {
			device->Release();
		}
		if(d3d) {
			d3d->Release();
		}
	}
예제 #26
0
//-----------------------------------------------------------------------------
// Name: shutDown()
// Desc:
//-----------------------------------------------------------------------------
void shutDown_0( void )
{
    if( g_pTeapotMesh_0 != NULL )
        g_pTeapotMesh_0->Release();

    if( g_pd3dDevice_0 != NULL )
        g_pd3dDevice_0->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}
예제 #27
0
// Uninitialise D3D
void D3DShutdown()
{
	// Release D3D interfaces
	if (g_pFont != NULL)
		g_pFont->Release();

    if( g_pd3dDevice != NULL )
        g_pd3dDevice->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}
예제 #28
0
void Game_End()
{
	if (d3ddev)
	{
		d3ddev->Release();
		d3ddev=NULL;
	}
	if (d3d)
	{
		d3d->Release();
		d3d=NULL;
	}
}
예제 #29
0
    /**
     * Halts the DirectX application.
     */
    void halt()
    {
        delete globals::gui;

        delete imageLoader;
        delete input;
        delete graphics;

        d3ddev->Release();
        d3d->Release();

        //UnregisterClass("MY_WINDOWS_CLASS", winClass.hInstance);
    }
예제 #30
0
//-----------------------------------------------------------------------------
// 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();
}