当前位置: 首页>>代码示例>>C++>>正文


C++ LPD3DXFONT类代码示例

本文整理汇总了C++中LPD3DXFONT的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXFONT类的具体用法?C++ LPD3DXFONT怎么用?C++ LPD3DXFONT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LPD3DXFONT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _CreateFont

/// <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;
}
开发者ID:rivenz,项目名称:LoL-Ability-Timers,代码行数:45,代码来源:D3DDisplayManager.cpp

示例2: DrawString

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();
}
开发者ID:mathijs0587,项目名称:WinCpp,代码行数:9,代码来源:WinCpp.cpp

示例3: FontPrint

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); 
}
开发者ID:kyphelps,项目名称:spring-2013,代码行数:9,代码来源:MyDirectX.cpp

示例4:

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 );
}
开发者ID:ClericX,项目名称:Projects,代码行数:10,代码来源:Direct3D.cpp

示例5: FontPrint

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); 

}
开发者ID:tj10200,项目名称:Simple-Soccer,代码行数:13,代码来源:DirectX.cpp

示例6: GetFont

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;
}
开发者ID:DarkSlim,项目名称:IVMultiplayer-1,代码行数:15,代码来源:CGraphics.cpp

示例7: fontPrint

/** 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);
}
开发者ID:thawhtaik,项目名称:Battle-of-Fight-War,代码行数:49,代码来源:DirectXStuff.cpp

示例8: OnFrameRender

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;
	}
}
开发者ID:dimroc,项目名称:sunborn_igf,代码行数:35,代码来源:ConsoleBuffer.cpp

示例9: render

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
}
开发者ID:pnchang,项目名称:advgraphics,代码行数:34,代码来源:example03.cpp

示例10: CloseDirect3D

// Close the Device and Direct3D
void CloseDirect3D()
{
	dxfont->Release();
	dxfontpeschkes->Release();
    d3ddev->Release();
    d3d->Release();

    return;
}
开发者ID:ppeschke,项目名称:hexar,代码行数:10,代码来源:direct3d.cpp

示例11: Game_End

void Game_End()
{
    if (fontArial24) fontArial24->Release(); 
    if (fontGaramond36) fontGaramond36->Release();
    if (fontTimesNewRoman40) fontTimesNewRoman40->Release();

    DirectInput_Shutdown();
    Direct3D_Shutdown();
}
开发者ID:kyphelps,项目名称:spring-2013,代码行数:9,代码来源:MyGame.cpp

示例12: Direct3DRender

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);

}
开发者ID:wakqaz4,项目名称:MyGame,代码行数:55,代码来源:main.cpp

示例13: Render

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 );
}
开发者ID:trizdreaming,项目名称:AABB_OBB_collision,代码行数:53,代码来源:AABB_OBB_collision.cpp

示例14:

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 );
}
开发者ID:2015ECCSSPaperProject,项目名称:MAIN,代码行数:14,代码来源:IEX_Direct3D.cpp

示例15: RenderText

// 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 ) );
	}
}
开发者ID:Nixxus,项目名称:GamesDevelopment2,代码行数:16,代码来源:TankAssignment.cpp


注:本文中的LPD3DXFONT类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。