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


C++ D3DXCreateFont函数代码示例

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


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

示例1: D3DXCreateFont

/// <summary>Manages the creation of all resources required by this
/// class to draw text.</summary>
/// <params name="pDevice">LPDIRECT3DDEVICE9 to create data with. Must be
/// the same device later used to render.</params>
/// <returns>true if successful, false if failed.</returns>
bool D3DDisplayManager::_CreateFont(LPDIRECT3DDEVICE9 pDevice){
	// TODO: scale font size with resolution?
	if (!pFont) {
		// Create a font if we haven't already
		HRESULT hr = D3DXCreateFont(pDevice, 18, 0, FW_NORMAL, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
			DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &pFont);
		if (FAILED(hr))
			return false;
	}
	if (!pTitleFont) {
		HRESULT hr = D3DXCreateFont(pDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
			DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &pTitleFont);
		if (FAILED(hr))
			return false;
	}
	if (!pFontSprite) {
		HRESULT hr = D3DXCreateSprite(pDevice, &pFontSprite);
		if (FAILED(hr))
			return false;
	}
	if (!pLine) {
		HRESULT hr = D3DXCreateLine(pDevice, &pLine);
		if (FAILED(hr))
			return false;
		pLine->SetAntialias(false);
		pLine->SetGLLines(true);
	}
	return true;
}
开发者ID:rivenz,项目名称:LoL-Ability-Timers,代码行数:34,代码来源:D3DDisplayManager.cpp

示例2: D3DXCreateFont

void DirectXHook::initFontsIfRequired()
{
	normalSizeFontHeight = (int)(0.017 * *verticalRes);
	largeSizeFontHeight = (int)(0.034 * *verticalRes); 

	if (!normalSizeFont || normalSizeFontHeight != normalSizeCurrentFontHeight) {
		if (normalSizeFont)
		{
			normalSizeFont->Release();
		}

		D3DXCreateFont(pDevice, normalSizeFontHeight, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &normalSizeFont);
		normalSizeCurrentFontHeight = normalSizeFontHeight;
	}

	if (!largeSizeFont || largeSizeFontHeight != largeSizeCurrentFontHeight) {
		if (largeSizeFont)
		{
			largeSizeFont->Release();
		}

		D3DXCreateFont(pDevice, largeSizeFontHeight, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma", &largeSizeFont);
		largeSizeCurrentFontHeight = largeSizeFontHeight;
	}
}
开发者ID:ChurroV2,项目名称:ElDorito,代码行数:25,代码来源:DirectXHook.cpp

示例3: ObjectInit

bool ObjectInit(HWND hwnd)
{
	srand(unsigned(time(nullptr)));
	PlaySound(_T("コミネリサ - Resuscitated Hope.wav"), nullptr, SND_ASYNC | SND_FILENAME | SND_LOOP);
	D3DXCreateFont(gPD3DDevice, 30, 0, 0, 0, 0, 0, 0, 0, 0, _T("微软雅黑"), &gPTextAdapterFont);
	D3DXCreateFont(gPD3DDevice, 20, 0, 0, 0, 0, 0, 0, 0, 0, _T("华文中宋"), &gPTextHelperFont);
	D3DXCreateFont(gPD3DDevice, 30, 0, 0, 0, 0, 0, 0, 0, 0, _T("黑体"), &gPTextInfoFont);
	D3DXCreateFont(gPD3DDevice, 36, 0, 0, 0, 0, 0, 0, 0, 0, _T("楷体"), &gPTextFPSFont);

	//////////////////////////////////////////////////////////////////////////
	// Load mesh and materials here  
	//////////////////////////////////////////////////////////////////////////
	LPD3DXBUFFER pAdjBuffer;
	LPD3DXBUFFER pMtrlBuffer;
	D3DXLoadMeshFromX(_T("loli.X"), D3DXMESH_MANAGED, gPD3DDevice, &pAdjBuffer, &pMtrlBuffer, nullptr, &gDwNumMtrl, &gPCharacter);
	D3DXMATERIAL* pMaterial = (D3DXMATERIAL*)(pMtrlBuffer->GetBufferPointer());
	gPMaterial = new D3DMATERIAL9[gDwNumMtrl];
	gPTexture = new LPDIRECT3DTEXTURE9[gDwNumMtrl];
	for (DWORD i = 0; i < gDwNumMtrl; i++)
	{
		gPMaterial[i] = pMaterial->MatD3D;
		gPMaterial[i].Ambient = gPMaterial[i].Diffuse;
		gPTexture[i] = nullptr;
		D3DXCreateTextureFromFileA(gPD3DDevice, pMaterial[i].pTextureFilename, &gPTexture[i]);
	}

	pAdjBuffer->Release();
	SAFE_RELEASE(pMtrlBuffer);
	// 设置渲染状态
	gPD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);   //开启背面消隐
	gPD3DDevice->SetRenderState(D3DRS_AMBIENT, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f)); //设置环境光

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

示例4: MessageBox

void GameScene::Initialize(HWND& hWnd)
{
	if(!Manage_Scene::Initialized())
	{
		Manage_Scene::Initialize(hWnd);
	}
	
	/*
	if (!SUCCEEDED(D3DXCreateTextureFromFileEx(gDevice->g_pd3dDevice, background, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 1, NULL, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
		D3DX_FILTER_NONE, D3DX_FILTER_NONE, NULL, NULL, NULL, &backGroundTexture)))
	{
		MessageBox(NULL,_T("Image Load error"),NULL,NULL);
	}
	*/
	ZeroMemory(&g_GoalLine, sizeof(g_GoalLine));
	D3DXCreateTextureFromFileEx(gDevice->g_pd3dDevice, _T(IMG_FIREBALLOON), D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 1, NULL, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
		D3DX_FILTER_NONE, D3DX_FILTER_NONE, NULL, NULL, NULL, &balloonTexture);
	D3DXCreateTextureFromFileEx(gDevice->g_pd3dDevice, _T(IMG_BG), D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 1, NULL, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
		D3DX_FILTER_NONE, D3DX_FILTER_NONE, NULL, NULL, NULL, &backGroundTexture); 
	D3DXCreateTextureFromFileEx(gDevice->g_pd3dDevice, _T(IMG_GOALLINE), D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, 1, NULL, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
		D3DX_FILTER_NONE, D3DX_FILTER_NONE, NULL, NULL, NULL, &g_GoalLine.Texture);
	D3DXCreateFont(gDevice->g_pd3dDevice, 30,15, 255, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("바탕체"), &scoreFont);
	D3DXCreateFont(gDevice->g_pd3dDevice, 30,15, 255, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("바탕체"), &lifeFont);
	D3DXCreateFont(gDevice->g_pd3dDevice, 30,15, 255, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("바탕체"), &stageFont);

	if (!SUCCEEDED(D3DXCreateSprite(gDevice->g_pd3dDevice, &spriter)))
	{
		MessageBox(NULL,_T("Error on generating spriter"),NULL,NULL);
	}
	
	InitStage(1);
}
开发者ID:JueSungMun,项目名称:FireBalloon,代码行数:35,代码来源:GameScene.cpp

示例5: CScrollingWindow

CHud::CHud(LPDIRECT3DDEVICE9 pd3dDevice) : CScrollingWindow(0x00000000), alpha(255), pMyPlayer(NULL), m_BigFont(NULL), m_SmallFont(NULL), timeLeft(FADETIME) {
	HRESULT hr;
	// Create a D3DX font object
	V(D3DXCreateFont( pd3dDevice, 40, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, 
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, 
		TEXT("Arial"), &m_BigFont ) );

	V(D3DXCreateFont( pd3dDevice, 24, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, 
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, 
		TEXT("Arial"), &m_SmallFont ) );

	// Create sprite object
	V( D3DXCreateSprite(pd3dDevice,&m_Sprite) );

	// Load a texture for our sprite
	V( D3DXCreateTextureFromFile(pd3dDevice, LIVE_ICON, &m_Texture) );

	if (hr != S_OK)
		dprintf("Something went wrong in the HUD!!");
	this->anchor = CScrollingWindow::TOP;
	this->hidden = false;
	this->xPercent = 1.f;
	this->yPercent = 1.f;
	UpdateDimensions();
}
开发者ID:dimroc,项目名称:sunborn_igf,代码行数:25,代码来源:HUD.cpp

示例6: D3DXCreateFont

void xTextFlusher::Init( IDirect3DDevice9* device )
{
	D3DXCreateFont( device, 12, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
		"Consolas", &m_pFont9 );

	D3DXCreateFont( device, 14, 0, FW_NORMAL, 1, FALSE, DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
		"Consolas", &m_pFont9Big );

	D3DXCreateSprite( device, &m_pSprite9 );
}
开发者ID:ylyking,项目名称:d3d-profiler,代码行数:12,代码来源:xTextFlusher.cpp

示例7: create_font

 // font_size is in units of tenths of point size. i.e. 100 is a 10 point font
 FontPtr create_font(DevicePtr device, const tstring & font_name, int font_size) {
   HDC dc = GetDC(NULL);
   if (!dc) WIN_EXCEPT("Failed call to GetDC(NULL).");
   int log_pixels_y = GetDeviceCaps(dc, LOGPIXELSY);
   ReleaseDC(NULL, dc);
 
   FontPtr font;
   HRESULT hr = E_FAIL;
   if (is_fixed_width(font_name)) {
     LOGFONT lf;
     // Try filling the logfont with GDI+ first since it gives more natural font
     //   proportions than passing 0 as the width. However since GDI+ doesn't handle
     //   some fonts like Terminal properly, if GDI+ fails, try creating the font
     //   directly.
     if (get_logfont(font_name, font_size, &lf))
       return create_font(device, lf);
     hr = D3DXCreateFont(device,
                         -MulDiv(font_size, log_pixels_y, 72 * POINT_SIZE_SCALE),
                         0,
                         FW_NORMAL,
                         D3DX_DEFAULT,
                         FALSE,
                         DEFAULT_CHARSET,
                         OUT_DEFAULT_PRECIS,
                         QUALITY,
                         FIXED_PITCH | FF_DONTCARE,
                         font_name.c_str(),
                         &font);
   }
   if (FAILED(hr)) {
     tstringstream sstr;
     sstr << _T("Unable to use the font ") << font_name << ".";
     MessageBox(NULL, sstr.str().c_str(), _T("Font error"), MB_OK);
     hr = D3DXCreateFont(device,
                         -MulDiv(font_size, log_pixels_y, 72 * POINT_SIZE_SCALE),
                         0,
                         FW_NORMAL,
                         D3DX_DEFAULT,
                         FALSE,
                         DEFAULT_CHARSET,
                         OUT_DEFAULT_PRECIS,
                         QUALITY,
                         FIXED_PITCH | FF_DONTCARE,
                         _T("Lucida Console"),
                         &font);
     if (FAILED(hr)) DX_EXCEPT("Failed call to D3DXCreateFont(). ", hr);
   }
   return font;
 }
开发者ID:HowardJeng,项目名称:conrep,代码行数:50,代码来源:font_util.cpp

示例8: InitEverything

//------------------------------------------------------------
// Initialization code
//------------------------------------------------------------
bool InitEverything(HWND hWnd)
{
	// init D3D
	if (!InitD3D(hWnd))
	{
		return false;
	}

	// create a fullscreen quad
	InitFullScreenQuad();

	// create a render target
	if (FAILED(gpD3DDevice->CreateTexture(WIN_WIDTH, WIN_HEIGHT,
		1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8,
		D3DPOOL_DEFAULT, &gpSceneRenderTarget, NULL)))
	{
		return false;
	}

	// loading models, shaders and textures
	if (!LoadAssets())
	{
		return false;
	}

	// load fonts
	if (FAILED(D3DXCreateFont(gpD3DDevice, 20, 10, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, (DEFAULT_PITCH | FF_DONTCARE),
		"Arial", &gpFont)))
	{
		return false;
	}

	return true;
}
开发者ID:popekim,项目名称:ShaderPrimer,代码行数:38,代码来源:ShaderFramework.cpp

示例9: loadGeometry

void loadGeometry(void) {
	// create the vertices using the CUSTOMVERTEX struct
	CUSTOMVERTEX vertices[] = {
		{ 0.5f, -0.5f, 0.0f, 1.0f, 1.0f },
		{ -0.5f, -0.5f, 0.0f, 0.0f, 1.0f },
		{ 0.5f, 0.5f, 0.0f, 1.0f, 0.0f },
		{ -0.5f, 0.5f, 0.0f, 0.0f, 0.0f }
	};

	D3DXCreateTextureFromFile(d3ddev, "..\\Sprites\\base.dds", &tx);

	RECT rect;

	if (FAILED(D3DXCreateFont(d3ddev, 26, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE, "Arial", &font)))
		OutputDebugString("Problem");

	// create a vertex buffer interface called vb
	d3ddev->CreateVertexBuffer(sizeof(vertices),
		0,
		CUSTOMFVF,
		D3DPOOL_MANAGED,
		&vb,
		NULL);

	VOID* pVoid;    // a void pointer

					// lock v_buffer and load the vertices into it
	vb->Lock(0, 0, (void**)&pVoid, 0);
	memcpy(pVoid, vertices, sizeof(vertices));
	vb->Unlock();
}
开发者ID:Griffone,项目名称:Everward,代码行数:31,代码来源:Graphics.cpp

示例10: Objects_Init

//-----------------------------------【Object_Init( )函数】--------------------------------------
//	描述:渲染资源初始化函数,在此函数中进行要被渲染的物体的资源的初始化
//--------------------------------------------------------------------------------------------------
HRESULT Objects_Init(HWND hwnd)
{
	//创建字体
	if(FAILED(D3DXCreateFont(g_pd3dDevice, 36, 0, 0, 1, false, DEFAULT_CHARSET, 
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 0, _T("微软雅黑"), &g_pFont)))
		return E_FAIL;
	srand(timeGetTime());      //用系统时间初始化随机种子 

	// 物体的创建
	if(FAILED(D3DXCreateBox(g_pd3dDevice, 2, 2, 2, &g_cube, NULL)))	//立方体的创建
		return false;
	if(FAILED(D3DXCreateTeapot(g_pd3dDevice, &g_teapot, NULL)))		//茶壶的创建
		return false;	
	if(FAILED(D3DXCreateSphere(g_pd3dDevice, 1.5, 25, 25,					//球面体的创建
		&g_sphere, NULL))) return false;
	if(FAILED(D3DXCreateTorus(g_pd3dDevice, 0.5f, 1.2f, 25, 25,				//圆环体的创建
		&g_torus, NULL))) return false;

	// 设置渲染状态
	g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);   //关闭光照
	g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);   //开启背面消隐
	g_pd3dDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);  //设置线框填充模式

	return S_OK;
}
开发者ID:CyrusSUEN,项目名称:Direct3D-Win32-Book-Src-Code,代码行数:28,代码来源:D3Ddemo6.cpp

示例11: exit

void DirectxFunctions::DirectXInit(HWND hwnd)
{
	if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &DirectX.Object)))
		exit(1);

	ZeroMemory(&DirectX.Param, sizeof(DirectX.Param));
	DirectX.Param.Windowed = true;
	DirectX.Param.BackBufferFormat = D3DFMT_A8R8G8B8;
	DirectX.Param.BackBufferHeight = Overlay.Height;
	DirectX.Param.BackBufferWidth = Overlay.Width;
	DirectX.Param.EnableAutoDepthStencil = true;
	DirectX.Param.AutoDepthStencilFormat = D3DFMT_D16;
	DirectX.Param.MultiSampleQuality = D3DMULTISAMPLE_NONE;
	DirectX.Param.SwapEffect = D3DSWAPEFFECT_DISCARD;
	

	if (FAILED(DirectX.Object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &DirectX.Param, 0, &DirectX.Device)))
		exit(1);


	D3DXCreateFont(DirectX.Device, 16, 0, 0, 0, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &DirectX.Font);

	if (!DirectX.Line)
		D3DXCreateLine(DirectX.Device, &DirectX.Line);
}
开发者ID:qfrtt,项目名称:Framework,代码行数:25,代码来源:DirectX.cpp

示例12: Draw

	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();
	}
开发者ID:0Seren,项目名称:LCGoL-D3D9-Wrapper,代码行数:33,代码来源:Overlay.cpp

示例13: D3DXCreateFont

void Checkbox::init(IDirect3DDevice9 * i_direct3dDevice,LPCSTR i_text, int x, int y, func i_callback)
{

	//draw text
	m_direct3dDevice=i_direct3dDevice; 
	D3DXCreateFont( m_direct3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_font );
	fontColor = D3DCOLOR_ARGB(255,0,0,255); 
	fieldSelected=false;
	fieldHighlighted=false;
	checkBoxSelected=false;

       // Create a rectangle to indicate where on the screen it should be drawn
		rct.left=x+30;
		rct.right=x+150+30;
		rct.top=y+20;
		rct.bottom=y+50+20;
 
		m_text=i_text;
		
		pos.x=x;
		pos.y=y;
		pos.z=0.0f;
		D3DXCreateTextureFromFile(m_direct3dDevice,"data/Textures/menubar.png",&menuBar); 				
	    D3DXCreateSprite(m_direct3dDevice, &sprite );

		//checkbox
		checkBoxpos.x=x+175;
		checkBoxpos.y=y;
		checkBoxpos.z=0.0f;
		D3DXCreateTextureFromFile(m_direct3dDevice,"data/Textures/checkboxchecked.png",&checkbox); 				
	    D3DXCreateSprite(m_direct3dDevice, &checkBoxSprite ); 
		
		callback=i_callback;
}
开发者ID:aaraddhyanb,项目名称:GreenLagoon,代码行数:34,代码来源:Checkbox.cpp

示例14: D3DXCreateSprite

void HippoUI_RenderD3D9::Init()
{
	
	//create sprite
	HRESULT hr = D3DXCreateSprite( m_pd3dDevice, &m_pSprite );
	if( FAILED( hr ) )
	{
		m_pSprite=0;
		ReportErr("D3DXCreateSprite Failed");
	}
	const int default_font_h=10;
	hr = D3DXCreateFont( m_pd3dDevice,
		16,					// Height
		0,                     // Width
		FW_NORMAL,               // Weight
		1,                     // MipLevels, 0 = autogen mipmaps
		FALSE,                 // Italic
		DEFAULT_CHARSET,       // CharSet
		OUT_DEFAULT_PRECIS,    // OutputPrecision
		DEFAULT_QUALITY,       // Quality
		DEFAULT_PITCH | FF_DONTCARE, // PitchAndFamily
		"Arial",              // pFaceName
		&m_pFont );              // ppFont
	if( FAILED( hr ) )
	{
		m_pFont=0;
		ReportErr("D3DXCreateFont Failed");
	}
}
开发者ID:sssa2000,项目名称:AIGameDemo,代码行数:29,代码来源:HippoUI_RenderD3D9.cpp

示例15: InitObject

HRESULT InitObject(void)
{
	srand(unsigned(time(NULL)));

	if (FAILED(D3DXCreateFont(g_pDevice, 30, 0, 0, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 0, TEXT("宋体"), &g_pFont)))
	{
		return E_FAIL;
	}

	if (FAILED(D3DXCreateTeapot(g_pDevice, &g_pTeapot, NULL))) return E_FAIL;
	if (FAILED(D3DXCreateBox(g_pDevice, 2.0f, 2.0f, 2.0f, &g_pCube, NULL))) return E_FAIL;
	if (FAILED(D3DXCreateSphere(g_pDevice, 1.5f, 25, 25, &g_pSphere, NULL))) return E_FAIL;
	if (FAILED(D3DXCreateTorus(g_pDevice, 0.5f, 1.2f, 25, 25, &g_pTorus, NULL))) return E_FAIL;

	//设置材质
	D3DMATERIAL9 material;
	ZeroMemory(&material, sizeof(D3DMATERIAL9));
	material.Ambient = D3DXCOLOR(0.5f, 0.5f, 0.7f, 1.0f);	//环境光
	material.Diffuse = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f);	//漫反射
	material.Specular = D3DXCOLOR(0.3f, 0.3f, 0.3f, 0.3f);	//镜面反射
	material.Emissive = D3DXCOLOR(0.3f, 0.0f, 0.1f, 1.0f);
	g_pDevice->SetMaterial(&material);

	//设置光照
	SetLight(g_pDevice, 1);
	g_pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
	g_pDevice->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
	g_pDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
	//开启背面消隐  
	g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);

	return S_OK;
}
开发者ID:liyongfa,项目名称:DirectX,代码行数:33,代码来源:demo3.cpp


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