Example #1
0
void Game_End()
{
    if (fontArial24) fontArial24->Release(); 
    if (fontGaramond36) fontGaramond36->Release();
    if (fontTimesNewRoman40) fontTimesNewRoman40->Release();

    DirectInput_Shutdown();
    Direct3D_Shutdown();
}
Example #2
0
// Close the Device and Direct3D
void CloseDirect3D()
{
	dxfont->Release();
	dxfontpeschkes->Release();
    d3ddev->Release();
    d3d->Release();

    return;
}
Example #3
0
// 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
}
Example #4
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();
}
Example #5
0
void Game_End()
{
    background->Release();
    font->Release();
    DirectInput_Shutdown();
    Direct3D_Shutdown();
}
Example #6
0
//=============================================================================
// デバッグ表示処理の終了処理
//=============================================================================
void UninitDebugProc(void)
{
	if(g_pD3DXFont != NULL)
	{// 情報表示用フォントの開放
		g_pD3DXFont->Release();
		g_pD3DXFont = NULL;
	}
}
Example #7
0
void DrawString(int x, int y, int FontSize, DWORD color, LPD3DXFONT g_pFont, LPCSTR Message)
{
	D3DXCreateFont(d3ddev, FontSize, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont);

	RECT FontPos = { x, y, x + 120, y + 16 };

	pFont->DrawTextA(NULL, Message, -1, (LPRECT)&FontPos, 0, color);
	pFont->Release();
}
Example #8
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();
}
Example #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 ( lpD3DDevice8 != NULL ) 
        lpD3DDevice8->Release();

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

   if ( lpD3DXFont != NULL )
      lpD3DXFont->Release();
}
Example #10
0
 VOID  JN_DXFontMgr::Release(  VOID  )
{
	FontMapIter		iter = m_FontMap.begin();

	for( ; iter != m_FontMap.end() ; iter++ )
	{
		LPD3DXFONT pFont	= iter->second;

		if( pFont != NULL )
		{
			pFont->Release();
		}
	}

	m_FontMap.clear();
}
Example #11
0
// 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();
	}
}
Example #12
0
VOID Graphics::DrawScore(LPCWSTR TextString, int x, int y, int x1, int y1, D3DCOLOR MyColor)
{
	LPD3DXFONT pFont = NULL;
	RECT Rec;
	HFONT hFont;

	hFont = CreateFont(30,10,0,0,FW_NORMAL,FALSE,FALSE,0,1,0,0,0,DEFAULT_PITCH|FF_MODERN,TEXT("Arial"));

	Rec.left = x;
	Rec.top = y;
	Rec.right = x1;
	Rec.bottom = y1;

	D3DXCreateFont(this->GetDevice(),30,10,FW_NORMAL,0,FALSE,1,0,0,DEFAULT_PITCH|FF_MODERN,TEXT("Times New Roman"),&pFont);
	pFont->DrawText(NULL,TextString,-1,&Rec,DT_WORDBREAK,MyColor);

	DeleteObject(hFont);
	if (pFont != NULL)
		pFont->Release();
}
VOID Cleanup( )
{
	if (NULL != g_pFont)
	{
		g_pFont->Release();
	}

	if (NULL != g_pMesh)
	{
		g_pMesh->Release();
	}

	if ( NULL != g_pD3DDevice )
	{
		g_pD3DDevice->Release();
	}

	if ( NULL != g_pD3D )
	{
		g_pD3D->Release();
	}
}
Example #14
0
void cGraphicsLayer::DrawTextString( int x, int y,
                                     DWORD color, const char * str )
{

    HRESULT r = 0;

    if( !m_pBackSurf )
        return;

    // Get a handle for the font to use
    HFONT hFont = (HFONT)GetStockObject( SYSTEM_FONT );

    LPD3DXFONT pFont = 0;
    // Create the D3DX Font
    r = D3DXCreateFont( m_pDevice, hFont, &pFont );
    if( FAILED( r ) )
        return;

    // Rectangle where the text will be located
    RECT TextRect = { x, y, 0, 0 };

    // Inform font it is about to be used
    pFont->Begin();

    // Calculate the rectangle the text will occupy
    pFont->DrawText( str, -1, &TextRect, DT_CALCRECT, 0 );

    // Output the text, left aligned
    pFont->DrawText( str, -1, &TextRect, DT_LEFT, color );

    // Finish up drawing
    pFont->End();

    // Release the font
    pFont->Release();

}
void	IEX_ReleaseText( void )
{
	g_pd3dFont->Release();
	g_pd3dFontM->Release();
}
Example #16
0
// Reset the Direct3D device to resize window or toggle fullscreen/windowed
bool ResetDevice( HWND hWnd, bool ToggleFullscreen = false )
{
	// If currently windowed...
	if (!Fullscreen)
	{
		// Get current window and client window dimensions
		RECT NewClientRect;
		GetWindowRect( hWnd, &WindowRect );
		GetClientRect( hWnd, &NewClientRect );

		// If not switching to fullscreen, then we must ensure the window is changing size, if
		// it isn't then return without doing anything
		if (!ToggleFullscreen && NewClientRect.right == ClientRect.right && 
			NewClientRect.bottom == ClientRect.bottom)
		{
			return true;
		}
		ClientRect = NewClientRect;
	}

	// Toggle fullscreen if requested
	if (ToggleFullscreen)
	{
		Fullscreen = !Fullscreen;
	}

	// Reset the structure used to create the D3DDevice
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;  // Don't wait for vertical sync
	d3dpp.BackBufferCount = 1;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
	if (!Fullscreen)
	{
		// Set windowed parameters - need to set the back buffer dimensions when reseting,
		// match them to the window client area
	    d3dpp.Windowed = TRUE;
		d3dpp.BackBufferWidth = ClientRect.right;
		d3dpp.BackBufferHeight = ClientRect.bottom;
	    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	}
	else
	{
		// Get current dimensions of primary monitor
		MONITORINFO monitorInfo;
		monitorInfo.cbSize = sizeof(MONITORINFO);
		if (GetMonitorInfo( g_pD3D->GetAdapterMonitor( D3DADAPTER_DEFAULT ), &monitorInfo ))
		{
			d3dpp.BackBufferWidth = monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left;
			d3dpp.BackBufferHeight = monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top;
		}
		else
		{
			d3dpp.BackBufferWidth = 1280;
			d3dpp.BackBufferHeight = 1024;
		}

		// Set other fullscreen parameters
		d3dpp.Windowed = FALSE;
	    d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
	}
	ViewportWidth = d3dpp.BackBufferWidth;
	ViewportHeight = d3dpp.BackBufferHeight;

	// Need to recreate resources when reseting. Any resources (vertex & index buffers, textures) created
	// using D3DPOOL_MANAGED rather than D3DPOOL_DEFAULT will be recreated automatically. Dynamic resources
	// must be in D3DPOOL_DEFAULT, so they must be recreated manually. D3DX fonts are such an example.
	// Other dynamic resources are those that are updated during the game loop, e.g. procedural textures,
	// or dynamic terrain
	if (g_pFont != NULL)
		g_pFont->Release();

	// Reset the Direct3D device with the new settings
    if (FAILED(g_pd3dDevice->Reset( &d3dpp )))
    {
        return false;
    }

	// If reseting to windowed mode, we need to reset the window size
	if (!Fullscreen)
	{
		SetWindowPos( hWnd, HWND_NOTOPMOST, WindowRect.left, WindowRect.top,
			          WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, 0 );
	}

	// Need to set up states again after reset
    g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
    g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
    g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );

	g_pd3dDevice->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
    g_pd3dDevice->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
    g_pd3dDevice->SetSamplerState( 1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );

	g_pd3dDevice->SetSamplerState( 2, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
    g_pd3dDevice->SetSamplerState( 2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
    g_pd3dDevice->SetSamplerState( 2, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );

	// Recreate the font
    if (FAILED(D3DXCreateFont( g_pd3dDevice, 12, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
                               DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &g_pFont )))
    {
        return false;
    }

	return true;
}