/// <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;
}
Ejemplo n.º 2
0
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;
	}
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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);
}
Ejemplo n.º 5
0
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();
}
Ejemplo n.º 6
0
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 );
}
Ejemplo n.º 7
0
 // 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;
 }
Ejemplo n.º 8
0
//------------------------------------------------------------
// 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;
}
Ejemplo n.º 9
0
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();
}
//-----------------------------------【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;
}
Ejemplo n.º 11
0
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);
}
Ejemplo n.º 12
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();
	}
Ejemplo n.º 13
0
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;
}
Ejemplo n.º 14
0
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");
	}
}
Ejemplo n.º 15
0
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;
}
Ejemplo n.º 16
0
void Engine::Text::init()
{
	D3DXCreateFont(Engine::DX::instance()->getDevice(),
		30, 10, FW_NORMAL, 0, false, DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
		TEXT("Arial"), &font);
}
Ejemplo n.º 17
0
void cMainGame::Init(){
	m_cAxis = new cAxis(100.0f);
	m_cAxis->init();

	m_cGrid = new cGrid(100.0f, 100);
	m_cGrid->init();

	m_cCamera = new cCamera;
	m_cCamera->Setup();

	m_pPyramid = new cPyramid;
	m_pPyramid->setup();

	m_pParticleSystem = new cParticlesSystem;
	m_pParticleSystem->Setup();

	//m_vecSpheres;
	//cSphere* p;
	//for (int i = 0; i < 2000; i++){
	//	p = new cSphere;
	//	p->Setup();
	//	p->SetPosition(rand() % 500 / 10.0f - 25.0f, rand() % 100 / 1.0f, rand() % 500 / 10.0f - 25.0f);
	//	m_vecSpheres.push_back(p);
	//}


	D3DXCreateFont(g_pD3DDevice,		//D3D Device
		40,								//Font height
		0,								//Font width
		FW_NORMAL,						//Font Weight
		1,								//MipLevels
		false,							//Italic
		DEFAULT_CHARSET,				//CharSet
		OUT_DEFAULT_PRECIS,				//OutputPrecision
		ANTIALIASED_QUALITY,			//Quality
		DEFAULT_PITCH | FF_DONTCARE,	//PitchAndFamily
		"Arial",						//pFacename,
		&m_pFont);						//ppFont

	SetRect(&m_recFontRect, 0, 0, 400, 200);

	D3DLIGHT9 stLight;
	ZeroMemory(&stLight, sizeof(D3DLIGHT9));
	stLight.Type = D3DLIGHT_DIRECTIONAL;
	D3DXVECTOR3 vDir = D3DXVECTOR3(1.5, -1, 1);
	D3DXVec3Normalize(&vDir, &vDir);
	stLight.Direction = vDir;
	stLight.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	stLight.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	stLight.Specular = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	
	g_pD3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, true);
	g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, true);
	g_pD3DDevice->SetLight(0, &stLight);
	g_pD3DDevice->LightEnable(0, true);

	DWORD dwThID;

	//CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SetupSkinnedMesh, this, NULL/*CREATE_SUSPENDED*/, &dwThID));
}
Ejemplo n.º 18
0
//デフォルトコンストラクタ
Object::Object()
{
	// ポイントスプライトのバッファの初期化
	if (FAILED(d3dDevice->CreateVertexBuffer(10000 * sizeof(Vertex3), D3DUSAGE_WRITEONLY, VERTEX3_FVF, D3DPOOL_MANAGED, &pointBuffer, nullptr)))
		DebugAlert("頂点バッファが\n作成できませんでした。");

	// フォントの初期化
	D3DXCreateFont(d3dDevice,
		32,							// 文字の高さ
		16,							// フォントの文字の幅
		FW_NORMAL,					// フォントのウェイト
		0,							// 要求されるミップレベルの数
		false,						// 斜体フォントの場合はtrue
		0,							// 文字セット
		0,							//出力精度
		DEFAULT_QUALITY,			//出力品質
		DEFAULT_PITCH || FF_DONTCARE,	//フォントのピッチとファミリ
		"",							//フォントの書体
		&font);


	DebugLog("オブジェクトを生成しました\n");

	Initialize();
}
Ejemplo n.º 19
0
bool D3DXTextDriver::init(int fontWidth, int screenWidth, int screenHeight)
{
	HRESULT hr = E_FAIL;
	hr = D3DXCreateFont( GetDevice(), fontWidth, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, MONO_FONT | FF_DONTCARE, "Courier New", &pFont_);
	if(FAILED(hr))
		return false;

	TEXTMETRIC tm; 
	pFont_->GetTextMetrics(&tm);
	fontHeight_ = tm.tmHeight;
	fontWidth_ = tm.tmAveCharWidth;

	//create projection matrix for 2D elements
	D3DXMatrixOrthoLH(&viewMat_,(float)screenWidth, (float)screenHeight, 0.1f, 100);
	D3DXMATRIX tr_m, rot_m;
	D3DXMatrixRotationX(&rot_m, 3.14f);
	D3DXMatrixTranslation(&tr_m, 0, .5f*(float)screenHeight, 0);
	
	D3DXMatrixIdentity(&realviewMat_);
	//D3DXMatrixMultiply(&realviewMat_, &realviewMat_, &rot_m);
	D3DXMatrixMultiply(&realviewMat_, &realviewMat_, &tr_m);


	scrWidth_ = screenWidth;
	scrHeight_ = screenHeight;

	return true;
}
Ejemplo n.º 20
0
bool ObjectInit(HWND hwnd)
{
	srand(unsigned(time(nullptr)));
	PlaySound(_T("コミネリサ - Resuscitated Hope.wav"), nullptr, SND_ASYNC | SND_FILENAME | SND_LOOP);

	if (FAILED(D3DXCreateFont(gPD3DDevice, 38, 0, 0, 0, 0, 0, 0, 0, 0, _T("楷体"), &gPFont)))
	{
		return false;
	}
	D3DXCreateTeapot(gPD3DDevice, &gPTeapot, 0);
	D3DXCreateBox(gPD3DDevice, 2, 2, 2, &gPBox, 0);
	D3DXCreateTorus(gPD3DDevice, 1.0f, 2.0f, 25, 25, &gPTorus, 0);
	D3DXCreateSphere(gPD3DDevice, 2.0f, 25, 25, &gPSphere, 0);

	//D3DMATERIAL9 is a struct with diffuse, specular, ambient, and emissive;
	//There is also power typed float, however its usage not known yet.
	D3DMATERIAL9 material;
	ZeroMemory(&material, sizeof(material));
	material.Ambient = D3DXCOLOR(0.5f, 0.5f, 0.7f, 1.0f);
	material.Diffuse = D3DXCOLOR(0.4f, 0.6f, 0.6f, 1.0f);
	material.Specular = D3DXCOLOR(0.3f, 0.3f, 0.3f, 1.0f);
	material.Emissive = D3DXCOLOR(0.3f, 0.0f, 0.1f, 1.0f);
	gPD3DDevice->SetMaterial(&material);	

	return true;
}
Ejemplo n.º 21
0
void CMultiColumnList::OnFrameRender(IDirect3DDevice9 *pd3dDevice){
	if (!m_font){
		D3DXCreateFont( pd3dDevice, 18, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, 
			OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, 
			TEXT("Arial"), &m_font );
	}

	if (m_nColumns == 0)
		return;
	long rowHeight = (long) 20;
	long columnWidth = (long) m_nWidth / m_nColumns;
	DrawRowText(0, rowHeight, columnWidth, true);
	for (int r = m_start; r <= (int)m_end; r++){
		if (r == m_selected){
			float left = (float) m_nX, 
				right = (float) left + m_nWidth, 
				top = (float) m_nY + ((r - m_start + 1) * rowHeight), 
				bottom = (float) top + 20;
			DWORD color = 0x44ffffff;
			SVertex bverts[] = 
			{
				{ left,		bottom,	0.0f,	1.0f,	color },
				{ left,		top,	0.0f,	1.0f,	color },
				{ right,	top,	0.0f,	1.0f,	color },
				{ right,	bottom,	0.0f,	1.0f,	color },
				{ left,		bottom,	0.0f,	1.0f,	color }
			};
			pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, bverts, sizeof(SVertex));			
		}
		DrawRowText(r, rowHeight, columnWidth, false);
	}
}
HRESULT InitD3D( HWND hWnd )
{
	if ( nullptr == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
	{
		return E_FAIL;
	}

	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory( &d3dpp, sizeof( d3dpp ) );
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

	if ( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice ) ) )
	{
		return E_FAIL;
	}

	D3DXCreateFont( g_pD3DDevice, 15, 0, FW_NORMAL, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"돋음체", &g_pFont );

	g_pD3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
	g_pD3DDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

	return S_OK;
}
Ejemplo n.º 23
0
void Overlay::Init(D3D9Base::LPDIRECT3DDEVICE9 Device)
{
	if(g_Globals.UsingOverlay)
	{
        _Device = Device;
		FreeMemory();
		HDC hDC = GetDC( NULL );
		int nLogPixelsY = GetDeviceCaps(hDC, LOGPIXELSY);
		ReleaseDC( NULL, hDC );
		int FontHeight = -9 * nLogPixelsY / 72;	//get the appropriate height of the font
		HRESULT hr = D3DXCreateFont( Device,
						FontHeight,
						0,
						FW_BOLD,
						1,
						FALSE,
						DEFAULT_CHARSET,
						OUT_DEFAULT_PRECIS,
						DEFAULT_QUALITY,
						DEFAULT_PITCH | FF_DONTCARE,
						"Arial",
						&_Font);
		Assert(SUCCEEDED(hr), "D3DXCreateFont failed");

        for(UINT PanelIndex = 0; PanelIndex < ConsolePanelCount; PanelIndex++)
        {
            ClearPanel(PanelIndex);
        }
		hr = D3DXCreateSprite(Device, &_Sprite);
		Assert(SUCCEEDED(hr), "D3DXCreateSprite failed");

        WriteLine("Console Start", RGBColor::Yellow, 0);
	}
}
Ejemplo n.º 24
0
//-------------------------------------------------------------------------------
void CLogDisplay::RecreateNativeResource()
	{
	if (!this->piFont)
		{
		if (FAILED(D3DXCreateFont(g_piDevice,     
                     16,					//Font height
                     0,						//Font width
                     FW_BOLD,				//Font Weight
                     1,						//MipLevels
                     false,					//Italic
                     DEFAULT_CHARSET,		//CharSet
                     OUT_DEFAULT_PRECIS,	//OutputPrecision
					 //CLEARTYPE_QUALITY,	//Quality
					 5,	//Quality
                     DEFAULT_PITCH|FF_DONTCARE,	//PitchAndFamily
                     "Verdana",					//pFacename,
					 &this->piFont)))
			{
			CLogDisplay::Instance().AddEntry("Unable to load font",D3DCOLOR_ARGB(0xFF,0xFF,0,0));

			this->piFont = NULL;
			return;
			}
		}
	return;
	}
Ejemplo n.º 25
0
void Drawer::Load()
{
	m_vertices = new D3DXVECTOR2[(RenderDeviceManager::ResolutionWidth / TILESIZE + 2) * 2 + (RenderDeviceManager::ResolutionHeight / TILESIZE + 2) * 2];
	PrepareGridVertices();

	HRESULT hRes;
	hRes = D3DXCreateSprite(RenderDeviceManager::RenderDevice, &m_sprite);
	hRes = D3DXCreateLine(RenderDeviceManager::RenderDevice, &m_line);

	tilesOnScreenX = RenderDeviceManager::ResolutionWidth / TILESIZE;
	tilesOnScreenY = RenderDeviceManager::ResolutionHeight / TILESIZE;

	m_camPosXMin = 0;
	m_camPosYMin = -TILESIZE;
	m_camPosXMax = m_camPosXMin + WWIDTH * TILESIZE - RenderDeviceManager::ResolutionWidth;
	m_camPosYMax = m_camPosYMin + WHEIGHT * TILESIZE - RenderDeviceManager::ResolutionHeight + TILESIZE * 4;

	SetCamPosCenter(WWIDTH * TILESIZE / 2, WHEIGHT * TILESIZE / 2);

	// Font
	D3DXCreateFont(RenderDeviceManager::RenderDevice, 20, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, 
		ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &m_font);

	UpdateMiniMap();
	PrepareMinimapFrame();
}
Ejemplo n.º 26
0
bool CGraphics::LoadFonts()
{
	// Create the font and sprite objects
	static const sFontInfo fontInfos[] =
	{
		{ "default",		15,		FW_NORMAL },
		{ "default-bold",	15,		FW_BOLD },
		{ "tahoma",			15,		FW_NORMAL },
		{ "tahoma-bold",	15,		FW_BOLD },
		{ "verdana",		15,		FW_NORMAL },
		{ "arial",			15,		FW_NORMAL }
	};

	bool bSuccess = true;
	for(int i = 0; bSuccess && i < NUM_FONTS; i++)
	{	
		bSuccess &= SUCCEEDED(D3DXCreateFont(m_pDevice, fontInfos[i].uiHeight, 0, fontInfos[i].uiWeight, 1, FALSE,
						DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, fontInfos[i].szFontName,
                        &m_pFonts[i]));
	}

	// Load texture for radar
	D3DXCreateTextureFromFileExA(m_pDevice, SharedUtility::GetAbsolutePath("multiplayer\\datafiles\\hud.png").Get(), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, 
		D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT,D3DX_DEFAULT, 0, 
		NULL, NULL, &m_pRadarOverlayTexture);

	return bSuccess && SUCCEEDED(D3DXCreateSprite(m_pDevice, &m_pSprite));
}
Ejemplo n.º 27
0
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(g_pDevice->CreateVertexBuffer(8 * sizeof(CUSTOMVERTEX)
		, 0
		, D3DFVF_CUSTOMVERTEX
		, D3DPOOL_DEFAULT
		, &g_pVertexBuffer
		, NULL)))
	{
		return E_FAIL;
	}

	if (FAILED(g_pDevice->CreateIndexBuffer(36 * sizeof(WORD)
		, 0
		, D3DFMT_INDEX16
		, D3DPOOL_DEFAULT
		, &g_pIndexBuffer
		, NULL)))
	{
		return E_FAIL;
	}

	ChangeObject();

	return S_OK;
}
Ejemplo n.º 28
0
void Main_Scene::Initialize(const HWND& hWnd)
{
	if(!Manage_Scene::Initialized())
	{
		Manage_Scene::Initialize(hWnd);
	}
	
	if (!SUCCEEDED(D3DXCreateTextureFromFileEx(gDevice->g_pd3dDevice, background.c_str(), GetWindowWidth(), GetWindowHeight(), 1, NULL, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
		D3DX_FILTER_NONE, D3DX_FILTER_NONE, NULL, NULL, NULL, &texture)))
	{
		MessageBox(NULL,_T("Image Load error"),NULL,NULL);
	}
	
	if (!SUCCEEDED(D3DXCreateSprite(gDevice->g_pd3dDevice, &spriter)))
	{
		MessageBox(NULL,_T("Error on generating spriter"),NULL,NULL);
	}

	if (!SUCCEEDED(D3DXCreateFont(gDevice->g_pd3dDevice, 30,15, 255, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("맑은 고딕"), &pFont)))
	{
		MessageBox(NULL, _T("Load Error of Font from the System"), NULL, NULL);
	}

	if (!SUCCEEDED(D3DXCreateFont(gDevice->g_pd3dDevice, 30,15, 255, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("맑은 고딕"), &pServerMsgFont)))
	{
		MessageBox(NULL, _T("Load Error of Font from the System"), NULL, NULL);
	}

	if (!SUCCEEDED(hEditWnd = CreateWindow(_T("edit"), _T(""), WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL, 200, 350, 225, 25, hWnd, (HMENU) EDITBTN_ID, NULL, NULL)))
	{
		MessageBox(NULL, _T("Generation error of Edit Box"), NULL, NULL);
	}

	
	if (!SUCCEEDED(btnWnd = CreateWindow(_T("button"),_T("확인"),WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 450,350,100,25,hWnd,(HMENU)NAME_SEND_BTN,NULL,NULL)))
	{
		MessageBox(NULL, _T("Generation error of Button"), NULL, NULL);
	}

	if (!SUCCEEDED(permissionWnd = CreateWindow(_T("button"),_T("게임시작"),WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 250,400,100,25,hWnd,(HMENU)ACCESS_PERMISSION_BTN,NULL,NULL)))
	{
		MessageBox(NULL, _T("Generation error of Button"), NULL, NULL);
	}
	ShowWindow(permissionWnd, SW_HIDE);
}
Ejemplo n.º 29
0
// Initialise Direct3D
bool D3DSetup( HWND hWnd )
{
	// Get initial window and client window dimensions
	GetWindowRect( hWnd, &WindowRect );
	GetClientRect( hWnd, &ClientRect );

    // Create the D3D object.
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
	if (!g_pD3D)
	{
        return false;
	}

    // Set up 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;
    d3dpp.Windowed = TRUE;
	d3dpp.BackBufferWidth = ClientRect.right;
	d3dpp.BackBufferHeight = ClientRect.bottom;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	Fullscreen = false;
	ViewportWidth = d3dpp.BackBufferWidth;
	ViewportHeight = d3dpp.BackBufferHeight;

    // Create the D3DDevice
    if (FAILED(g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                     D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                     &d3dpp, &g_pd3dDevice )))
    {
        return false;
    }
	
	// Turn on tri-linear filtering (for up to three simultaneous textures)
    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 );

	// Create a font using D3DX helper functions
    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;
}
Ejemplo n.º 30
0
// setup retrieves an interface to the font COM object 
//
void APIText::setup() {

  // retrieve an API interface to the font object 
  if (FAILED(D3DXCreateFont(d3dd, fontHght, 0, weight, 0, 0, 
    DEFAULT_CHARSET, precision, quality, FF_DONTCARE | DEFAULT_PITCH,
    typeFace, &d3dfont)))
    error(L"APIText::10 Failed to retrieve the font interface");
}