Example #1
0
void render()
{
   static RECT rc = {0, 0, 320, 100};   // rectangular region.. used for text drawing
   static DWORD frameCount = 0;
   static DWORD startTime = clock();
   char str[16];

   doMath();   // do the math.. :-P   
   
   frameCount++;   //  increment frame count
    
   // Clear the back buffer to a black... values r g b are 0-256
    lpD3DDevice8->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER ,D3DCOLOR_XRGB(256, 256, 256), 1.0f, 0);

   // render the cubes
   myRect1->render(clock());
   myRect2->render(clock());

   // this function writes a formatted string to a character string
   // in this case.. it will write "Avg fps" followed by the 
   // frames per second.. with 2 decimal places
   sprintf(str, "Avg fps %.2f", (float) frameCount / ((clock() - startTime) / 1000.0f));
      
   // draw the text string..
   lpD3DXFont->Begin();
   lpD3DXFont->DrawText(str, -1, &rc, DT_LEFT, 0xFFFFFFFF);
   lpD3DXFont->End();
   
    // present the back buffer.. or "flip" the page
    lpD3DDevice8->Present( NULL, NULL, NULL, NULL );   // these options are for using rectangular
    // regions for rendering/drawing...
    // 3rd is which target window.. NULL makes it use the currently set one (default)
    // last one is NEVER used.. that happens with DirectX often
}
/// <summary>Draws some text to the screen at the specified coordinates
/// with the given color, drawing from the display parameters initialized
/// in this display manager's constructor.</summary>
/// <param name="pDevice">LPDIRECT3DDEVICE9 to render to.</param>
/// <param name="x">Screen X coordinate to draw to.</param>
/// <param name="y">Screen Y coordinate to draw to.</param>
/// <param name="alpha">Alpha level for the rectangle (transparency).</param>
/// <param name="r">Red color component for the colour of the rectangle.</param>
/// <param name="g">Green color component for the colour of the rectangle.</param>
/// <param name="b">Blue color component for the colour of the rectangle.</param>
/// <param name="message">String to draw.</param>
/// <param name="fontType">D3DDisplayManager::FontType value to describe the
/// type of font which should be used.</param>
bool D3DDisplayManager::DrawCooldownTextToScreen(LPDIRECT3DDEVICE9 pDevice,
		unsigned int x,	unsigned int y, int alpha, int r, int g, int b,
		LPCSTR message,	FontType fontType) {

	_CreateFont(pDevice);

	// Choose our font based on input
	LPD3DXFONT font;
	switch (fontType) {
		case FontType::TITLE:
			font = pTitleFont;
			break;
		default:
			font = pFont;
	}

	D3DCOLOR fontColor = D3DCOLOR_ARGB(alpha, r, g, b);
	RECT rct;
	rct.left = x;
	rct.right = x + ((mDisplayParams.backdropWidth / 5) * 4);
	rct.top = y;
	rct.bottom = rct.top + mDisplayParams.backdropHeight;

	// TODO: add better support for different resolutions:
	// Use a lookup table to adjust font size dynamically?

	// Draw the text
	pFontSprite->Begin(D3DXSPRITE_SORT_TEXTURE);
	font->DrawTextA(pFontSprite, message, -1, &rct, DT_RIGHT, fontColor);
	pFontSprite->End();
	return true;
}
Example #3
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 #4
0
// Close the Device and Direct3D
void CloseDirect3D()
{
	dxfont->Release();
	dxfontpeschkes->Release();
    d3ddev->Release();
    d3d->Release();

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

    DirectInput_Shutdown();
    Direct3D_Shutdown();
}
Example #6
0
void FontPrint(LPD3DXFONT font, int x, int y, string text, D3DCOLOR color)
{
    //figure out the text boundary
    RECT rect = { x, y, 0, 0 };
    font->DrawText( NULL, text.c_str(), text.length(), &rect, DT_CALCRECT, color); 

    //print the text
    font->DrawText(spriteobj, text.c_str(), text.length(), &rect, DT_LEFT, color); 
}
Example #7
0
void Direct3D::Text( LPD3DXFONT Font, int X, int Y, D3DCOLOR Color, char *String )
{
	// DT_WORDBREAK might be needed.
	// Rectangle where the text will be located
	RECT TextRect={X,Y,0,0};
	// Calculate the rectangle the text will occupy
	Font->DrawTextA( Sprite, String, -1, &TextRect, DT_CALCRECT, 0 );
	// Output the text, left aligned
	Font->DrawTextA( Sprite, String, -1, &TextRect, DT_LEFT, Color );
}
Example #8
0
void Direct3DRender(HWND hwnd)
{
	gPD3DDevice->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
	gPD3DDevice->BeginScene();
	
	InputUpdate();
	MatrixSet();

	RECT formatRect;
	GetClientRect(hwnd, &formatRect);

	for (int i = 0; i < gDwNumMtrl; i++)
	{
		gPD3DDevice->SetMaterial(&gPMaterial[i]);
		gPD3DDevice->SetTexture(0, gPTexture[i]);
		gPCharacter->DrawSubset(i);
	}

	int strLen = swprintf_s(gStrFPS, _T("FPS: %f"), 123.45f);
	gPTextFPSFont->DrawTextW(nullptr, gStrFPS, strLen, &formatRect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(0, 239, 136));	
	strLen = sizeof(gStrAdapterDesc);
	gPTextAdapterFont->DrawTextW(nullptr, gStrAdapterDesc, -1, &formatRect, DT_TOP | DT_LEFT, D3DCOLOR_XRGB(23, 23, 236));

	formatRect.top = 30;
	static wchar_t strInfo[256] = { 0 };
	swprintf_s(strInfo, -1, L"模型坐标: (%.2f, %.2f, %.2f)", gMatWorld._41, gMatWorld._42, gMatWorld._43);
	gPTextHelperFont->DrawText(NULL, strInfo, -1, &formatRect, DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(135, 239, 136, 255));

	formatRect.top = WINDOW_HEIGHT * 2 / 3;
	gPTextInfoFont->DrawTextW(nullptr, _T("控制说明:"), -1, &formatRect, DT_NOCLIP|DT_LEFT | DT_SINGLELINE, D3DCOLOR_XRGB(23, 25, 111));
	formatRect.top += 35;
	formatRect.left += 50;
	gPTextHelperFont->DrawText(NULL, L"按住鼠标左键并拖动:平移模型", -1, &formatRect,
		DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
	formatRect.top += 25;
	gPTextHelperFont->DrawText(NULL, L"按住鼠标右键并拖动:旋转模型", -1, &formatRect,
		DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
	formatRect.top += 25;
	gPTextHelperFont->DrawText(NULL, L"滑动鼠标滚轮:拉伸模型", -1, &formatRect,
		DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
	formatRect.top += 25;
	gPTextHelperFont->DrawText(NULL, L"W、S、A、D键:平移模型 ", -1, &formatRect,
		DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
	formatRect.top += 25;
	gPTextHelperFont->DrawText(NULL, L"上、下、左、右方向键:旋转模型 ", -1, &formatRect,
		DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));
	formatRect.top += 25;
	gPTextHelperFont->DrawText(NULL, L"ESC键 : 退出程序", -1, &formatRect,
		DT_SINGLELINE | DT_NOCLIP | DT_LEFT, D3DCOLOR_RGBA(255, 200, 0, 255));


	gPD3DDevice->EndScene();
	gPD3DDevice->Present(nullptr, nullptr, nullptr, nullptr);

}
VOID Render( )
{
	RECT rt1, rt2;
	D3DXMATRIX matWorld, matScale, matRotateZ, matTrans;

	g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );

	if ( SUCCEEDED( g_pD3DDevice->BeginScene( ) ) )
	{

		SetupMatrices( );
		SetRect( &rt1, 10, 10, 0, 0 );
		if (!g_Method)
		{
			g_pFont->DrawTextW( NULL, L"AABB 충돌(left click으로 방법 변경)", -1, &rt1, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
		}
		else
		{
			g_pFont->DrawTextW( NULL, L"OBB 충돌(left click으로 방법 변경)", -1, &rt1, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
		}
		


		g_pD3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );


		for ( DWORD i = 0; i < sizeof( g_Box ) / sizeof( g_Box[1] ); ++i )
		{
			D3DXMatrixTranslation( &matTrans, g_Box[i].CenterPos.x, g_Box[i].CenterPos.y, g_Box[i].CenterPos.z );
			D3DXMatrixScaling( &matScale, g_Box[i].BoxScaling, g_Box[i].BoxScaling, g_Box[i].BoxScaling );
			D3DXMatrixRotationZ( &matRotateZ, g_Box[i].BoxRotateZ );
			matWorld = matRotateZ * matScale * matTrans;

			g_pD3DDevice->SetTransform( D3DTS_WORLD, &matWorld );

			g_pMesh->DrawSubset( 0 );
		}
		SetRect( &rt2, 10, 30, 0, 0 );

		if ( g_CheckFlag )
		{
			g_pFont->DrawTextW( NULL, L"박았음!!", -1, &rt2, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
		}
		else
		{
			g_pFont->DrawTextW( NULL, L"아직 멀었음!!", -1, &rt2, DT_NOCLIP, D3DXCOLOR( 1.f, 1.f, 0.f, 1.f ) );
		}

		g_pD3DDevice->EndScene( );
	}

	g_pD3DDevice->Present( NULL, NULL, NULL, NULL );
}
Example #10
0
void DirectX::FontPrint(LPD3DXFONT font, int x, int y, string text, D3DCOLOR color)
{
    //figure out the text boundary
    RECT rect = { x, y , 200, 200};
    
    D3DXVECTOR3 dest (100, 100, -100);

    font->DrawText( NULL, text.c_str(), text.length(), &rect, DT_CALCRECT, color); 

    //print the text
    font->DrawText(NULL, text.c_str(), text.length(), &rect, DT_CENTER | DT_NOCLIP |DT_TOP, color); 

}
void	IEX_DrawText( LPSTR str, int x, int y, int width, int height, DWORD color, BOOL bMini )
{
	RECT	rect;

	rect.left   = x;
	rect.top    = y;
	rect.right  = x + width;
	rect.bottom = y + height;

	iexSystem::Device->SetRenderState(D3DRS_FOGENABLE, FALSE);

	if( !bMini ) g_pd3dFont->DrawText(  NULL, str, -1, &rect, DT_LEFT|DT_WORDBREAK, color ); 
	 else        g_pd3dFontM->DrawText( NULL, str, -1, &rect, DT_LEFT|DT_WORDBREAK, color );
}
// Render a single text string at the given position in the given colour, may optionally centre it
void RenderText( const string& text, int X, int Y, float r, float g, float b, bool centre = false )
{
	RECT rect;
	if (!centre)
	{
		SetRect( &rect, X, Y, 0, 0 );
		g_pFont->DrawText( NULL, text.c_str(), -1, &rect, DT_NOCLIP, D3DXCOLOR( r, g, b, 1.0f ) );
	}
	else
	{
		SetRect( &rect, X - 100, Y, X + 100, 0 );
		g_pFont->DrawText( NULL, text.c_str(), -1, &rect, 
		                   DT_CENTER | DT_NOCLIP, D3DXCOLOR( r, g, b, 1.0f ) );
	}
}
Example #13
0
float CGraphics::GetFontHeight(float fScale)
{
	// Get the font
	LPD3DXFONT pFont = GetFont(0);

	// Is the font valid?
	if(pFont)
	{
		D3DXFONT_DESC desc;
		pFont->GetDesc(&desc);
		return ((float) desc.Height * fScale);
	}

	return 0.0f;
}
/** Use a given font object to draw text at location (x,y) in a certain color */
void DirectXStuff::fontPrint(LPD3DXFONT font, int x, int y, string text, D3DCOLOR color)
{
	//Figure out the text boundary first
	RECT Rect = {x, y, 0, 0};

	/** 
	int DrawText( LPD3DXSPRITE pSprite, LPCTSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color );

	pSprite - the first parameter allows a sprite interface to be passed in. Setting this to NULL means Direct3D 
		will use its own internal sprite object to render the text. If you are doing lots of DrawText calls passing 
		your own sprite object can SPEED UP RENDERING SIGNIFICANTLY (Up to 4x - see font drawing optimisations).
	pString - this is the string to render. The type of string depends on your projects character set.
	Count -  the number of characters in the string. You can set this to the magic number -1 in order to specify that 
		Direct3D should count the characters itself. Note that this only works with null terminated strings.
	pRect - the rectangular area in which the text will be displayed. How the text is justified within this rectangle 
		depends on the next parameter:
	Format - allows you to specify some flags. This allows you to specify the justification of the text within the 
		rectangle plus some other options (see advanced).
	Color - the final parameter is the colour you want to render the text.
	As always you must release the D3DX interface before your program exits or on a device reset:

	*/
	//This call fills in values for rect (alternatively you could just fill in rect yourself)
	font->DrawText(this->spriteObj, text.c_str(), text.length(), &Rect, DT_CALCRECT, color);

	//Now print the text actually
	//Create vectors for matrix transformation (annoying)
	D3DXVECTOR2 scale(1, 1);
	D3DXVECTOR2 translate(x, y);
	D3DXVECTOR2 center((float)(Rect.right)/2, (float)(Rect.bottom));

	//The 2D transformation matrix and the function that actually sets the matrix values
	D3DXMATRIX mat;

	D3DXMatrixTransformation2D(
		&mat, //The matrix; note pass by reference 
		NULL, //scaling center point (not used)
		0, //scaling rotation value (not used)
		&scale, //scaling vector
		&center, //rotation / pivot center
		0, //rotation angle
		&translate //translation vector
	); 

	//Tell sprite object to use the matrix
	this->spriteObj->SetTransform(&mat);
	font->DrawText(this->spriteObj, text.c_str(), text.length(), &Rect, DT_LEFT, color);
}
Example #15
0
void CConsoleBuffer::OnFrameRender(IDirect3DDevice9 *pd3dDevice, LPD3DXFONT font, RECT rct){
	int height = rct.bottom - rct.top; // The height of one line in the buffer
	float left = (float) rct.left - 4, 
		right = (float) rct.right + 4, 
		top = (float) rct.top - 4;
	SVertex bverts[] = 
	{
		{ left,		top + (height * (int)m_iMaxLines) + 8,	0.0f,	1.0f,	0x11ffffff },
		{ left,		top,									0.0f,	1.0f,	0x11ffffff },
		{ right,	top,									0.0f,	1.0f,	0x11ffffff },
		{ right,	top + (height * (int)m_iMaxLines) + 8,	0.0f,	1.0f,	0x11ffffff },
		{ left,		top + (height * (int)m_iMaxLines) + 8,	0.0f,	1.0f,	0x11ffffff }
	};
	pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, bverts, sizeof(SVertex));

	SVertex verts[] = 
	{
		{ left,		top + (height * (int)m_iMaxLines) + 8,	0.0f,	1.0f,	0xccffffff },
		{ left,		top,									0.0f,	1.0f,	0xccffffff },
		{ right,	top,									0.0f,	1.0f,	0xccffffff },
		{ right,	top,									0.0f,	1.0f,	0xcc888888 },
		{ right,	top + (height * (int)m_iMaxLines) + 8,	0.0f,	1.0f,	0xcc888888 },
		{ left,		top + (height * (int)m_iMaxLines) + 8,	0.0f,	1.0f,	0xcc888888 }
	};
	pd3dDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, 5, verts, sizeof(SVertex));
	
	if (m_vLines.empty())
		return;

	for (UINT i = m_start; i <= m_end; i++){
		font->DrawTextA(NULL, m_vLines[i]->GetText(), -1, &rct, DT_LEFT, D3DCOLOR_ARGB(255,255,255,255) );
		rct.top = rct.top + height;
		rct.bottom = rct.top + height;
	}
}
Example #16
0
void drawPeschkes(const char* peschkes)
{
	static RECT textbox;
	SetRect(&textbox, 224, 700, 1014, 758);
	dxfontpeschkes->DrawTextA(NULL, peschkes, strlen(peschkes), &textbox, DT_RIGHT | DT_BOTTOM,
					  D3DCOLOR_ARGB(255, 255, 255, 255));
}
Example #17
0
	void Draw() {
		device->CreateStateBlock(D3DSBT_ALL, &state);
		state->Capture();
		device->SetVertexShader(nullptr);
		// draw
		try {
			if (memory.UpdateAll()) {
				device->GetCreationParameters(&cparams);
				GetClientRect(cparams.hFocusWindow, &gameWindow);
				if (gameWindow.bottom / 1080.0 != heightModifier || gameWindow.right / 1920.0 != widthModifier) {
					heightModifier = gameWindow.bottom / 1080.0;
					widthModifier = gameWindow.right / 1920.0;
					D3DXCreateFont(device, (int)(40 * heightModifier * (heightModifier + .75 * (1 - heightModifier))), 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, 5, DEFAULT_PITCH | FF_DONTCARE, L"Verdana", &pFont);
					int left = (int)(855 * widthModifier);
					int top = (int)(304 * heightModifier);
					int right = (int)(left + 285 * widthModifier);
					int bottom = (int)(top + 50 * heightModifier);
					rectangle = { left, top, right, bottom };
					textrect = { left, top, right, bottom };
				}
				if (memory.IsOnEndScreen.Current()) {
					DrawIGTRectangle();
					DrawIGT();
				}
			}
		}
		catch (...) {
			pFont->DrawTextA(NULL, "Exception", -1, &textrect, DT_CENTER, textColor);
		}
		//release
		state->Apply();
		state->Release();
	}
Example #18
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 #19
0
void render()
{
    assert(g_pd3dDevice);

    g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

    D3DCOLOR color[3];
    color[0] = D3DCOLOR_XRGB(255, 0, 0);
    color[1] = D3DCOLOR_XRGB(0, 255, 0);
    color[2] = D3DCOLOR_XRGB(0, 0, 255);

    int i = 0;
    int step = 50;

    int delta = 0;
    int max_delta = 2;

    g_pd3dDevice->BeginScene();
    {
        RECT rect(*g_pRect);
        while(rect.top < rect.bottom) {
            delta = (rand() % max_delta) - max_delta / 2;
            rect.top += delta;
            g_pFont->DrawText(NULL, "This text is created using ID3DXFont =)))", -1, &rect, DT_TOP | DT_LEFT, color[i]);
            i = ++i % 3;
            rect.top += step;
        }
    }
    g_pd3dDevice->EndScene();

    g_pd3dDevice->Present(NULL, NULL, NULL, NULL);

    camera();
}
Example #20
0
void Game_End()
{
    background->Release();
    font->Release();
    DirectInput_Shutdown();
    Direct3D_Shutdown();
}
Example #21
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 #22
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 #23
0
float CGraphics::GetCharacterWidth(char c, float fScale)
{
	// Get the font
	LPD3DXFONT pFont = GetFont(0);

	// Is the font valid?
	if(pFont)
	{
		HDC dc = pFont->GetDC();
		SIZE size;
		GetTextExtentPoint32(dc, &c, 1, &size);
		return ((float)size.cx * fScale);
	}

	return 0.0f;
}
Example #24
0
void drawChat(string msg)
{
	static RECT textbox{ 10, 586, 341, 1024 };
	StartSpriteRender();
	DrawSprite(chatWindow, 0, 576);
	EndSpriteRender();
	dxfont->DrawTextA(NULL, msg.c_str(), msg.size(), &textbox, DT_LEFT | DT_TOP | DT_WORDBREAK, D3DCOLOR_ARGB(255, 255, 255, 0));
}
Example #25
0
void Drawing::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Colour, LPD3DXFONT m_font)
{
	// Create a rectangle to indicate where on the screen it should be drawn
	RECT rct = {x- 120, y, x+ 120, y + 15};

	// Draw some text 
	m_font->DrawText(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Colour );
}
Example #26
0
//=============================================================================
// デバッグ表示処理の終了処理
//=============================================================================
void UninitDebugProc(void)
{
	if(g_pD3DXFont != NULL)
	{// 情報表示用フォントの開放
		g_pD3DXFont->Release();
		g_pD3DXFont = NULL;
	}
}
Example #27
0
//Add your objects here.
void CALLBACK RenderFunc(void)
{
	/**
	 *	Show GPU info on TOP|LEFT .
	 */
	WCHAR TempName[60] = L"GPU Info:";
	WCHAR adapterName[30]{0};
	D3DADAPTER_IDENTIFIER9 Adapter; 
	LPDIRECT3D9  pD3D = NULL;
	if (NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
	{
		return;
	}
	pD3D->GetAdapterIdentifier(0, 0, &Adapter);
	int len = ::MultiByteToWideChar(CP_ACP, 0, Adapter.Description, -1, NULL, 0);
	::MultiByteToWideChar(CP_ACP, 0, Adapter.Description, -1, adapterName, len);
	wcscat_s(TempName, adapterName);
	pD3D->Release();

	gPFont->DrawText(nullptr, TempName, -1, nullptr, DT_TOP | DT_LEFT, D3DCOLOR_XRGB(124, 24, 222));

	/**
	 *	Set camera and view here.
	 */
	D3DMATRIX* pMatView = nullptr;
	GD::CMatrix44<float> viewMat(gEnv.m_pCamera->GetViewMatrixDX());
	pMatView = (D3DMATRIX*)(&viewMat);
	gEnv.m_pDXDevice->GetD3DDevice()->SetTransform(D3DTS_VIEW, pMatView); //应用取景变换矩阵

	D3DMATRIX* pProjMatrix;
	pProjMatrix = (D3DMATRIX*)(&gEnv.m_pCamera->GetProjMatrix().GetFliped());
	gEnv.m_pDXDevice->GetD3DDevice()->SetTransform(D3DTS_PROJECTION, pProjMatrix);  //设置投影变换矩阵

	D3DVIEWPORT9* pViewPort;
	pViewPort = (D3DVIEWPORT9*)(&gEnv.m_pCamera->GetViewPort());
	gEnv.m_pDXDevice->GetD3DDevice()->SetViewport(pViewPort); //视口的设置
	/**
	 *	Draw terrain here.
	 */
	Matrix I;
	I.Identity();
	gEnv.m_pTerrain->Draw(I, false);
	/**
	 *	Draw objects in scene here.
	 */	
	D3DXMATRIX W;
	D3DXMatrixIdentity(&W);
	gEnv.m_pDXDevice->GetD3DDevice()->SetTransform(D3DTS_WORLD, &W);
	D3DMATERIAL9 mtrl;
	mtrl.Ambient = D3DCOLOR_WHITE;
	mtrl.Diffuse = D3DCOLOR_WHITE;
	mtrl.Emissive = D3DCOLOR_RED;
	mtrl.Specular = D3DCOLOR_PUREGREEN;
	mtrl.Power = 2.0f;
	gEnv.m_pDXDevice->GetD3DDevice()->SetMaterial(&mtrl);	
	gPMesh->DrawSubset(0);
}
Example #28
0
void CHud::DrawHUDText(LPD3DXFONT font, LPCSTR text, int x, int y, int height, int width, DWORD format, SColor c, float alphaPercent){
	if (!font)
		return;
	RECT rct;
	rct.top = y;// + height / 4;
	rct.bottom = y + height; //3 * height / 4;
	rct.left = x;
	rct.right = x + width;
	font->DrawTextA(NULL, text, -1, &rct, format, D3DCOLOR_ARGB((int)(alpha * alphaPercent), c.r, c.g, c.b) );
}
Example #29
0
void DirectXHook::drawText(int x, int y, DWORD color, const char* text, LPD3DXFONT pFont)
{
	RECT shadow1;
	RECT shadow2;
	RECT shadow3;
	RECT shadow4;
	SetRect(&shadow1, x + 1, y + 1, x + 1, y + 1);
	SetRect(&shadow2, x - 1, y + 1, x - 1, y + 1);
	SetRect(&shadow3, x + 1, y - 1, x + 1, y - 1);
	SetRect(&shadow4, x - 1, y - 1, x - 1, y - 1);
	pFont->DrawText(NULL, text, -1, &shadow1, DT_LEFT | DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 0));
	pFont->DrawText(NULL, text, -1, &shadow2, DT_LEFT | DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 0));
	pFont->DrawText(NULL, text, -1, &shadow3, DT_LEFT | DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 0));
	pFont->DrawText(NULL, text, -1, &shadow4, DT_LEFT | DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 0));

	RECT rect;
	SetRect(&rect, x, y, x, y);
	pFont->DrawText(NULL, text, -1, &rect, DT_LEFT | DT_NOCLIP, color);
}
Example #30
0
//=============================================================================
// デバッグ表示処理の描画処理
//=============================================================================
void DrawDebugProc(void)
{
	RECT rect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};

	// 情報表示
	g_pD3DXFont->DrawText(NULL, g_aStrDebug, -1, &rect, DT_RIGHT, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0xff));

	// 情報クリア
	memset(g_aStrDebug, 0, sizeof g_aStrDebug);
}