コード例 #1
0
ファイル: Direct3D.cpp プロジェクト: ClericX/Projects
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 );
}
コード例 #2
0
/// <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;
}
コード例 #3
0
ファイル: ConsoleBuffer.cpp プロジェクト: dimroc/sunborn_igf
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;
	}
}
コード例 #4
0
ファイル: Overlay.cpp プロジェクト: 0Seren/LCGoL-D3D9-Wrapper
	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();
	}
コード例 #5
0
ファイル: direct3d.cpp プロジェクト: ppeschke/hexar
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));
}
コード例 #6
0
ファイル: direct3d.cpp プロジェクト: ppeschke/hexar
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));
}
コード例 #7
0
ファイル: WinCpp.cpp プロジェクト: mathijs0587/WinCpp
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();
}
コード例 #8
0
ファイル: HUD.cpp プロジェクト: dimroc/sunborn_igf
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) );
}
コード例 #9
0
ファイル: Overlay.cpp プロジェクト: 0Seren/LCGoL-D3D9-Wrapper
	void DrawIGT() {
		UINT32 igt = memory.GameTime.Current();
		UINT32 millis = igt % 1000;
		UINT32 seconds = (igt / 1000) % 60;
		UINT32 minutes = ((igt / (1000 * 60)) % 60);
		UINT32 hours = ((igt / (1000 * 60 * 60)) % 24);

		char timer_text[128];
		sprintf_s(timer_text, 128, "%01u:%02u:%02u.%03u", hours, minutes, seconds, millis);
		pFont->DrawTextA(NULL, timer_text, -1, &textrect, DT_CENTER | DT_VCENTER, textColor);
	}
コード例 #10
0
void Game_Run(HWND window)
{
	UINT numPasses = 0;
	static float y = 0.0;

	if (!d3ddev) return;
	myInput->DirectInput_UpdateState();
	d3ddev->Clear(0, NULL, D3DCLEAR_TARGET , D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);

	// slow rendering to approximately 60 fps
	if (timeGetTime() > screentimer + 14)
	{
		screentimer = GetTickCount();

		//start rendering
		if (d3ddev->BeginScene())
		{
			//rotate the view
			View_Change();

			if (myInput->Key_Down(DIK_J))
			{
				d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
				
			}
			else if (myInput->Key_Down(DIK_K))
			{
				d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
		
			}

			//concrete rendering............................................................
			for (int i=0;i<nums;i++)
			{
				d3ddev->SetMaterial(&mats[i]);
				d3ddev->SetTexture(0,textures[i]);
				mesh->DrawSubset(i);	
			}
			RECT rect={0,0,0,0};
			font->DrawTextA(nullptr,s.c_str(),s.length(),&rect,DT_SINGLELINE | DT_NOCLIP | DT_LEFT,D3DCOLOR_XRGB(255,0,0));
			//concrete rendering............................................................

			//stop rendering
			d3ddev->EndScene();
			d3ddev->Present(NULL, NULL, NULL, NULL);
		}
	}


	if (myInput->Key_Down(DIK_ESCAPE)) gameOver = true;
}
コード例 #11
0
ファイル: Graphics.cpp プロジェクト: Griffone/Everward
void renderFrame(void) {
	d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 162, 232), 1.0f, 0);	// use 0, 162, 232 for nice blue color

	d3ddev->BeginScene();    // begins the 3D scene

	// SET UP THE PIPELINE
	D3DXMATRIX matTranslate;

	Vector2 mousePos = worldCoord(mouseX, mouseY);

	D3DXMatrixTranslation(&matTranslate, mousePos.x, mousePos.y, 0);

	D3DXMATRIX matView;    // the view transform matrix

	D3DXMatrixLookAtRH(&matView,
		&D3DXVECTOR3(0.0f, 0.0f, 5.0f),    // the camera position
		&D3DXVECTOR3(0.0f, 0.0f, 0.0f),    // the look-at position
		&D3DXVECTOR3(0.0f, 1.0f, 0.0f));    // the up direction

	d3ddev->SetTransform(D3DTS_VIEW, &(matView));    // set the view transform to matView

	D3DXMATRIX matProjection;     // the projection transform matrix

	D3DXMatrixOrthoRH(&matProjection,
		viewWidth,	// the horizontal view volume
		viewWidth * currentRatio,	// the vertical view volume
		0.25f,    // the near view-plane
		15.0f);    // the far view-plane

	d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);    // set the projection

	d3ddev->SetTexture(0, tx);

	// select the vertex buffer to display
	d3ddev->SetStreamSource(0, vb, 0, sizeof(CUSTOMVERTEX));

	// copy the vertex buffer to the back buffer
	d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

	RECT rect;

	SetRect(&rect, 0, 0, wndWidth, wndHeight);

	font->DrawTextA(NULL, "Everward", 8, &rect, DT_CENTER | DT_VCENTER, 0xffffff00);

	d3ddev->EndScene();    // ends the 3D scene

	d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen
}
コード例 #12
0
ファイル: TDWMap.cpp プロジェクト: fedaykinofdune/ffxinfinity
//这里才是镜像文件的实际读取
BOOL ImgReadMap(int no)
{	
	char buff[256];
	RECT rc={40,200,600,400};

	g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,128,0), 1.0f, 0L );
	g_pD3DDevice->BeginScene();
	GetClientRect(hwndMain,&rc); rc.top+=(rc.bottom-rc.top)/3;
	wsprintf(buff,"僼傽僀儖傪撉傒崬傫偱偄傑偡丅");
	pDxFont->DrawTextA(NULL, buff,lstrlen(buff),&rc, DT_CENTER,  D3DCOLOR_XRGB(0,255,255));
	g_pD3DDevice->EndScene();
	g_pD3DDevice->Present( NULL, NULL, NULL, NULL ); 

	for (int i = 0; i < NumTexList; ++i)
	{
		if (TexList[i].pTex)
		{
			TexList[i].pTex->Release();
			TexList[i].pTex = NULL;
		}
	}

	NumTexList = 0;
	NumMMB = 0;
	noj = 0;
	oj = NULL;

	if( !ImgLoad(no) ) return FALSE;

	g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,128,0), 1.0f, 0L );
	g_pD3DDevice->BeginScene();
	rc.top+=16;
	wsprintf(buff,"妋擣偟偰偄傑偡丅");
	pDxFont->DrawTextA(NULL, buff,lstrlen(buff),&rc, DT_CENTER,  D3DCOLOR_XRGB(0,255,255)); 
	g_pD3DDevice->EndScene();
	g_pD3DDevice->Present( NULL, NULL, NULL, NULL ); 

	char *p;
	DATHEAD hd;
	for( p=f.FistData(&hd); p; p=f.NextData(&hd) )
	{
		int type = (int)hd.type;

		switch (type)
		{
			case 0x1c:  //MZB
			{
				decode_mzb((BYTE*)(p+16));
				oj =  (OBJINFO *)(p+16+32);
				noj = (*(int*)(p+16+4) )&0xffffff;
			}
			break;
			case 0x2e:  //MMB
			{
				decode_mmb((BYTE*)(p+16));
				MMBlist[NumMMB++] = p+16;
				if( NumMMB >= sizeof(MMBlist)/sizeof(MMBlist[0]) )
				{
					logprintf("NumTextList偑椪奅揰偵払偟傑偟偨");
				}
			}
			break;
			case 0x20:  //IMG
			{
				if( IsImg(p+16) )
				{
					AddList(p+16);
				}
			}
			break;
		}
	}

	wsprintf(buff,"%d",no);
	WritePrivateProfileString("GENERIC","LASTMAP" ,buff,".\\TDWGame.ini");
	g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,128,0), 1.0f, 0L );
	g_pD3DDevice->BeginScene();
	rc.top+=16;
	wsprintf(buff,"撉傒崬傒傪廔椆偟傑偟偨丅昤夋偟傑偡丅\n偙偙偱傾僾儕働乕僔儑儞僄儔乕弌偨応崌偼師夞昤夋偝傟傑偣傫丅");
	pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_CENTER,  D3DCOLOR_XRGB(0,255,255));
	g_pD3DDevice->EndScene();
	g_pD3DDevice->Present( NULL, NULL, NULL, NULL ); 
	return TRUE;
}
コード例 #13
0
ファイル: dxctrltreeview.cpp プロジェクト: ohio813/bwh14
VOID CDXCtrlTreeview::DrawText()
{
	TEXTMETRIC tm;
	LPD3DXFONT pFont;
	RECT rect, irect;
	PLISTITEM pItem;
	D3DCOLOR Color;
	DWORD dwIndex;
	DWORD dwIndexTextSize;
	SIZE size;
	char szBuff[8];
	if(m_pManager)
	{

		GetRect(&rect);
		pFont = m_pManager->GetFixedWidthFont();
		pFont->GetTextMetrics(&tm);
		
		GetTextExtentPoint32(pFont->GetDC(), "999", 3, &size);
		
		if(m_bShowIndex)
			dwIndexTextSize = size.cx;
		else
			dwIndexTextSize = 0;

		pItem = m_pList;
		for(dwIndex = 0; dwIndex < m_dwTopIndex; dwIndex++)
			pItem = pItem->link;
		rect.left += (5 * m_dwFrameWidth / 8) + tm.tmHeight;
		rect.top += (5 * m_dwFrameWidth / 8);
		rect.bottom -= (5 * m_dwFrameWidth / 8);
		rect.right -= ((5 * m_dwFrameWidth / 8) + 16 + dwIndexTextSize);
		for(; rect.top <= rect.bottom - tm.tmHeight && pItem; dwIndex++)
		{
			if(pItem->bGroup || pItem->bVisible)
			{
				if(dwIndex == m_dwSelectedIndex)
				{
					Color = m_SelectedColor;
				}
				else
				{
					if(pItem->bGroup)
						Color = m_GroupColor;
					else
						Color = m_ItemColor;
				}
				pFont->DrawTextA(m_pManager->GetFontSprite(), pItem->szText, -1, &rect, DT_TOP | DT_LEFT, Color);
				if(m_bShowIndex && pItem->bGroup == FALSE)
				{
					irect = rect;
					irect.left = irect.right;
					irect.right = irect.left + dwIndexTextSize;
					pFont->DrawTextA(m_pManager->GetFontSprite(), itoa(dwIndex, szBuff, 10), -1, &irect, DT_TOP | DT_RIGHT, Color);
				}
				rect.top += tm.tmHeight;
			}
			pItem = pItem->link;
		}
	}
}
コード例 #14
0
ファイル: Dialog.cpp プロジェクト: gasbank/poolg
void Dialog::printName()
{
	g_dlgContentFont->DrawTextA(0, m_speakArray[m_curSpeakIdx].name, -1, &m_nameRect, DT_NOCLIP | DT_WORDBREAK, D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
}
コード例 #15
0
ファイル: Dialog.cpp プロジェクト: gasbank/poolg
void Dialog::printDialog()
{
	g_dlgNameFont->DrawTextA(0, m_speakArray[m_curSpeakIdx].content, -1, &m_contentRect, DT_NOCLIP | DT_WORDBREAK, D3DXCOLOR( 0.0f, 1.0f, 1.0f, 1.0f ) );
}
コード例 #16
0
ファイル: direct3d.cpp プロジェクト: ppeschke/hexar
void drawTextAt(const char* text, RECT* textbox)
{
	dxfont->DrawTextA(NULL, text, strlen(text), textbox, DT_LEFT | DT_TOP | DT_WORDBREAK, D3DCOLOR_ARGB(255, 255, 255, 0));
}
コード例 #17
0
ファイル: TDWMap.cpp プロジェクト: fedaykinofdune/ffxinfinity
void DrawMMB(char *pp)
{
  float *ff = (float*)pp;

  char *p = pp;
  p+=0x020;
	for(;;)
	{
		OOO * oo;
		oo = (OOO*)(p+4);
		D3DXMATRIX mat;
		D3DXMATRIX mat1;
		g_pD3DDevice->GetTransform(D3DTS_WORLD, &mat1); mat = mat1;
		g_pD3DDevice->GetTransform(D3DTS_VIEW, &mat1); mat *= mat1;
		g_pD3DDevice->GetTransform(D3DTS_PROJECTION, &mat1); mat *= mat1;
		D3DXVECTOR3 Vec;
		D3DXVECTOR4 v;
		Vec.x=oo->x1;Vec.y=oo->y1;Vec.z=oo->z1; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
		Vec.x=oo->x1;Vec.y=oo->y1;Vec.z=oo->z2; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
		Vec.x=oo->x1;Vec.y=oo->y2;Vec.z=oo->z1; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
		Vec.x=oo->x1;Vec.y=oo->y2;Vec.z=oo->z2; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
		Vec.x=oo->x2;Vec.y=oo->y1;Vec.z=oo->z1; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
		Vec.x=oo->x2;Vec.y=oo->y1;Vec.z=oo->z2; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
		Vec.x=oo->x2;Vec.y=oo->y2;Vec.z=oo->z1; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
		Vec.x=oo->x2;Vec.y=oo->y2;Vec.z=oo->z2; D3DXVec3Transform(&v,&Vec,&mat); v.x/=v.w; v.y/=v.w; v.z/=v.w;
		if( v.x<=2.2 && v.x>=-2.2 && v.y<=2.2 && v.y>=-2.2 && v.z<=2.2 && v.z>=-1.2 ) break;
    return;
    if(0)
	{
      //float pp[]={-20,0,0,20,0,0, 0,-20,0,0,20,0, 0,0,-20,0,0,20};
      float pp[]={
        oo->x1,oo->y1,oo->z1, oo->x2,oo->y1,oo->z1,
        oo->x1,oo->y2,oo->z1, oo->x2,oo->y2,oo->z1,
        oo->x1,oo->y1,oo->z2, oo->x2,oo->y1,oo->z2,
        oo->x1,oo->y2,oo->z2, oo->x2,oo->y2,oo->z2,

        oo->x1,oo->y1,oo->z1, oo->x1,oo->y2,oo->z1,
        oo->x2,oo->y1,oo->z1, oo->x2,oo->y2,oo->z1,
        oo->x1,oo->y1,oo->z2, oo->x1,oo->y2,oo->z2,
        oo->x2,oo->y1,oo->z2, oo->x2,oo->y2,oo->z2,

        oo->x1,oo->y1,oo->z1, oo->x1,oo->y1,oo->z2,
        oo->x1,oo->y2,oo->z1, oo->x1,oo->y2,oo->z2,
        oo->x2,oo->y1,oo->z1, oo->x2,oo->y1,oo->z2,
        oo->x2,oo->y2,oo->z1, oo->x2,oo->y2,oo->z2,
      };
      g_pD3DDevice->SetFVF(D3DFVF_XYZ);
      g_pD3DDevice->DrawPrimitiveUP(D3DPT_LINELIST,12,pp,12);
    }
  }
  g_pD3DDevice->SetFVF(D3DFVF_TEXVERTEX);
  int kai;
  //while( (kai=*(int*)p)<=0 ) p+=32;
  kai=*(int*)p;
  if( flgFirst ) logprintf("kai=%d",kai);
  if( kai<=0 ) return;
  if( kai==1 ) p+=32;
  if( kai>=2 && kai<=16 ){
    p+=16*4;
  }
  if( kai>16 )  p+=kai*4;

  if( kai>0xff ) return;
  if( kai>64 ){
         MessageBox(NULL,"傢偍","傢偍",MB_OK);
  }
  int i,j;
  while(kai){
    j = *(int*)p;
    if( j > 0xffff || j<0 ){
      if( flgFirst ) logprintf("Strip越界: %d",j);
      return;
    }
    p += 32;
    for( i=0; i<j; i++ ){


    //draw using textures hint
  {
	char buff[512];
    RECT rc={5,177,600,292}; rc.top+=i*40;
    sprintf(buff,"Serch Textur: %s",sstr(p,16));
	//如何把buff分段呢
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(196,196,0)); 
  }
      g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
      g_pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);

      g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
      g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
      g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
      g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);

      //g_pD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
      //g_pD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
      //g_pD3DDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
	  int k;
      for( k=0; k<NumTexList; k++ ){
        if( !memcmp(p,TexList[k].ID,16) ){

          if( flgFirst ) logprintf("Finded Textur: %s",sstr(TexList[k].ID,16));

          g_pD3DDevice->SetTexture(0, TexList[k].pTex); 
          g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE2X);
          g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
          g_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
          D3DSURFACE_DESC Desc;

          TexList[k].pTex->GetLevelDesc( 0, &Desc );
          if( /*Desc.Format == D3DFMT_DXT1*/0 ){
            //g_pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
            g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
            //typedef enum _D3DTEXTUREOP
            //g_pD3DDevice->SetRenderState( D3DRS_ALPHAREF,0x7f) ;
            //g_pD3DDevice->SetRenderState( D3DRS_ALPHAFUNC,D3DCMP_NOTEQUAL) ;
            g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE4X );
            g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
            g_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);

            g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
            g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 
             g_pD3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );          }
          break;
        }
      }
      int nVer     = (int)*(short*)(p+16);
      int nVerReal = (int)*(int*)(p+16);
      if( nVer > 0xffff || nVer<0 ){
        if( flgFirst ) logprintf("MaxVertex is : %d (%lx)",nVer,nVer);
        return;
      }
      int nIdx = (*(int*)(p+16+4+nVer*36));
      if( nIdx > 0xffff || nIdx < 0 ){
        if( flgFirst ) logprintf("MaxIndex is : %d (%lx)",nIdx,nIdx);
        return;
      }
      k = 16  +    4+ nVer*36+    4+ nIdx*2;
      k = 4*((k+3)/4);
      /*
      if( pdat+dwSize < p+k ){
        if( flgFirst ) logprintf("Size Over Flow");
        return;
      }
      */
      for( int ii=0; ii<nIdx; ii++ ){
        WORD *pidx = (WORD*)(p+16+4+nVer*36+4);
        if( (int)(UINT)pidx[ii]>=nVer ){
          if( flgFirst ) logprintf("Index 越界: %d/%d",(int)(UINT)pidx[ii],nVer);
          return;
        }
      }
      //if( flgFirst ) logprintf("DrawPrimitive: pp=%lx Vertex=%d Index=%d",p-pdat,nVer,nIdx);
#ifdef _DEBUG
      /*
      if(p-pdat==7505268){
        D3DTEXVERTEX *d =  (D3DTEXVERTEX *)(p+16+4);
        for( int ppp=0; ppp<nVer; ppp++ ){
          d[ppp].x = d[ppp].x;
        }
        for( int iii=0; iii<nIdx; iii++ ){
          WORD *pidx = (WORD*)(p+16+4+nVer*36+4);
      //    pidx[iii]= 0;
        }
      }
      */
#endif
//      if( nVerReal>0 ){
#if 1
        g_pD3DDevice->BeginScene();
        pory += nIdx-2;

        g_pD3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP,0,nIdx,nIdx-2,p+16+4+nVer*36+4,D3DFMT_INDEX16, (p+16+4) ,36 );
        if( flgFirst ) logprintf("DrawPrimitive:ok");
        g_pD3DDevice->EndScene();
#else
          g_pD3DDevice->BeginScene();
        for(DWORD cp=0; cp<nIdx-2; cp+=102){
          DWORD cpp = 102;
          if( cp+cpp>=nIdx-2 ){
            cpp = nIdx-2-cp;
          }
          //g_pD3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP,0,cpp+2,cpp,p+16+4+nVer*36+4+cp*2,D3DFMT_INDEX16, (p+16+4) ,36 );
          //g_pD3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP,cp,cpp+2,cpp,p+16+4+nVer*36+4,D3DFMT_INDEX16, (p+16+4) ,36 );
          g_pD3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP,cp,nIdx,cpp,p+16+4+nVer*36+4,D3DFMT_INDEX16, (p+16+4) ,36 );
          if( flgFirst ) logprintf("DrawPrimitive:ok");
        }
        if( flgFirst ) logprintf("DrawPrimitive:ok");
        g_pD3DDevice->EndScene();
#endif
//      }
      g_pD3DDevice->SetTexture(0,NULL); 
      p += k;
    }
    kai--;
  }
}
コード例 #18
0
ファイル: TDWMap.cpp プロジェクト: fedaykinofdune/ffxinfinity
void DrawMap(void)
{

  char buff[512];
	
  /*------------------------------------------------------------------------------
  //Begin Input Ctrl & View Matrix Setup
  ------------------------------------------------------------------------------*/
  static float angle = 0.0f;
  static float view = -240.0f;
  //view = -view;
  D3DXMATRIX matWorld;
  D3DXMATRIX matWorld2;
  D3DXMatrixTranslation(&matWorld2,0.0f,0.0f,angle/1500.0f);
  //D3DXMatrixRotationX(&matWorld, DEGtoRAD(angle/1.0069));
  //DXMatrixRotationY(&matWorld, DEGtoRAD(angle));
  D3DXMatrixRotationYawPitchRoll(&matWorld,DEGtoRAD(angle/20.0f),DEGtoRAD(angle/15.0f),DEGtoRAD(angle/10.0f));
  matWorld*=matWorld2;
  angle += 1.0f;
  //g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);

  D3DXMATRIX matView;
  static float mawari = 0.0f;
  float delta;
  delta = 0.02f;
  if( GetKeyState(VK_CONTROL)&0x8000 ){ delta = 0.1f; };
  if( GetKeyState(VK_RIGHT) & 0x8000 ) mawari-=delta;
  if( GetKeyState(VK_LEFT)  & 0x8000 ) mawari+=delta;
  static D3DXVECTOR3 pos(0.0f, 0.0f, 0.0f);
  delta = 2.0f;
  if( GetKeyState(VK_CONTROL)&0x8000 ){ delta = 5.0f; };
  if( GetKeyState(VK_UP)    & 0x8000 ){ pos.x+=cos(mawari)*delta; pos.z+=sin(mawari)*delta; }
  if( GetKeyState(VK_DOWN)  & 0x8000 ){ pos.x+=cos(mawari+3.1415926f)*delta; pos.z+=sin(mawari+3.1415926f)*delta; }
  if( GetKeyState(VK_PRIOR) & 0x8000 ){ pos.y+=delta; }
  if( GetKeyState(VK_NEXT)  & 0x8000 ){ pos.y-=delta; }
  if( GetKeyState(VK_HOME)  & 0x8000 ){ mawari=pos.x=pos.y=pos.z=0.0f; }
  D3DXVECTOR3 pnt(pos.x+cos(mawari), pos.y+0.0f, pos.z+sin(mawari));
  D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
  D3DXMatrixLookAtRH(&matView, &pos, &pnt, &up);
  g_pD3DDevice->SetTransform(D3DTS_VIEW, &matView); 

  D3DXMATRIX matProj;
  D3DXMatrixPerspectiveFovRH(&matProj, DEGtoRAD(45.0f), 4.0f / 3.0f, 1.0f, 500.0f);
  g_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);


   if( GetAsyncKeyState(VK_RETURN)  & 0x1 ){ AutoMakeMMB=TRUE;}


  /*------------------------------------------------------------------------------
  //End Input Ctrl & View Matrix Setup
  ------------------------------------------------------------------------------*/

  /*------------------------------------------------------------------------------
  //Begin RenderState
  ------------------------------------------------------------------------------*/
  //g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CW/*/D3DCULL_NONE*/  );
  g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CCW/*/D3DCULL_NONE*/  );
  g_pD3DDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
  //g_pD3DDevice->SetLight(0,&light);
  //g_pD3DDevice->LightEnable(0,TRUE);
  g_pD3DDevice->SetRenderState(D3DRS_LIGHTING,FALSE);
  //g_pD3DDevice->SetRenderState(D3DRS_AMBIENT, 0xF0F0F0F0);
  g_pD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD );

  g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
  g_pD3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
  g_pD3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE , TRUE );
  g_pD3DDevice->SetRenderState( D3DRS_ALPHAREF , 0x80 );
  g_pD3DDevice->SetRenderState( D3DRS_ALPHAFUNC  , D3DCMP_GREATER );
  //g_pD3DDevice->SetRenderState(D3DRS_EDGEANTIALIAS,TRUE);
  /*------------------------------------------------------------------------------
  //End RenderState
  ------------------------------------------------------------------------------*/

  //地图是在TheDesertWorld.cpp里画的
  //g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,128), 1.0f, 0L );



  if( flgFirst ) logprintf("MZB:%d",noj);
  pory = 0;
  for( int i=0; i< noj; i++ )
  {
    //if(i>=50) break;
    D3DXMATRIX matWorld;
    D3DXMATRIX matWorld2;
    D3DXMATRIX matWorld3;
    D3DXMATRIX matWorld4;
    D3DXMATRIX matWorldR4;
    D3DXMATRIX matWorldR5;
    D3DXMATRIX matWorldR6;
    ZeroMemory(&matWorld,sizeof(D3DXMATRIX));
    D3DXMatrixScaling(&matWorld3,oj[i].fScaleX,oj[i].fScaleY,oj[i].fScaleZ); 
    D3DXMatrixTranslation(&matWorld,oj[i].fTransX,oj[i].fTransY,oj[i].fTransZ);
    D3DXMatrixRotationX(&matWorldR4,oj[i].fRotX);
    D3DXMatrixRotationY(&matWorldR5,oj[i].fRotY);
    D3DXMatrixRotationZ(&matWorldR6,oj[i].fRotZ);
    matWorld2 = matWorldR4 * matWorldR5 * matWorldR6;
    matWorld=((matWorld3*matWorld2)/**matWorld4*/)*matWorld;
    g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);
    if( oj[i].fScaleX*oj[i].fScaleY*oj[i].fScaleZ < 0.0f )
	{ 
      g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CW );
    }
	else
	{
      g_pD3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CCW );
    }
    if(0)
	{
       float pp[]={-20,0,0,20,0,0, 0,-20,0,0,20,0, 0,0,-20,0,0,20};
       //float pp[]={-10,0,0,10,0,0, 0,-10,0,0,10,0, 0,0,-10,0,0,10};
       g_pD3DDevice->SetFVF(D3DFVF_XYZ);
       g_pD3DDevice->DrawPrimitiveUP(D3DPT_LINELIST,3,pp,12);
    }



	//Draw MzbLists Hint
	{
    RECT rc={5,91,600,128};

	  //自动输出
	  i = haha; //这个会打乱文件名和文件内容的正确配对吗?
	  if (AutoMakeMMB == TRUE) {haha+=1;};
      if (haha == (noj -1)) {haha = 0;AutoMakeMMB == false;};

    sprintf(buff,"-----MZBList:%d/%d",i,noj);
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(0,0,255)); 
	}


    for( int j=0; j< NumMMB; j++ )
	{
      if( memcmp(MMBlist[j]+16,oj[i].id,16) ) continue;

	//Draw Mmb Hint
	{
    RECT rc={5,134,600,160};
    sprintf(buff,"------- Draw MMB:%s",sstr(oj[i].id,16));
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(0,0,255)); 
	}

    /*------------------------------------------------------------------------------
    //Begin MapObj Files Output
    ------------------------------------------------------------------------------*/
    char opname[16];  //要输出的文件名
    CopyMemory(opname,MMBlist[j]+16,16);
    ChangeSpaceToNull(opname);
	lstrcat(opname,".MapObj");


    if (DoesFileExist(opname)) { logprintf("发现有文件重复将自动复盖,这些文件是%s",opname);}
    HANDLE hFile = CreateFile(opname,GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL );
    //ReadFile(hFile,pdat,dwSize,&dmy,NULL);	  

    if( hFile!=INVALID_HANDLE_VALUE && hFile!=NULL )
	{
    DWORD dmy;
    //SetFilePointer(hFile,0,NULL,FILE_END);

	LPSTR ReadLocate = MMBlist[j+1]-16;

	int size = (int)(((*(DWORD*)&ReadLocate[4])>>3)&0x007ffff0);

    WriteFile(hFile,&ReadLocate[0],size,&dmy,NULL);
    CloseHandle(hFile);
	}
   /*------------------------------------------------------------------------------
   //End MapObj Files Output
   ------------------------------------------------------------------------------*/

    DrawMMB(MMBlist[j]);

    //信息输出1
	{
    RECT rc={5,5,600,64};
    sprintf(buff,"正在绘制Index数=%d\nLookAt:X=%02.2f Y=%02.2f Z=%02.2f",pory,pos.x,pos.y,pos.z);
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(196,196,0)); 
	}
    //信息输出2
	{
    RECT rc={5,48,600,96};
    sprintf(buff,"%sMZB=%d MMB=%d\n当前第%d个MMB",oj?"总共":"第",noj,NumMMB,j);
    pDxFont->DrawTextA(NULL,buff,lstrlen(buff),&rc, DT_LEFT,  D3DCOLOR_XRGB(196,196,0)); 
	}

	break;
	}//End For MumMMB

  break;
  }//End For Noj
コード例 #19
0
void Game_Run(HWND window)
{

	if (!d3ddev) return;
	myInput->DirectInput_UpdateState();
	d3ddev->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL , D3DCOLOR_XRGB(0, 108, 255), 1.0f, 0);

	// slow rendering to approximately 60 fps
	if (timeGetTime() > screentimer + 14)
	{
		screentimer = GetTickCount();
		//start rendering
		if (d3ddev->BeginScene())
		{		
			//Change the camera view
			View_Change();
			//concrete rendering............................................................
			D3DXMATRIX matWorld;
			D3DXMatrixTranslation(&matWorld, 0.0f,0.0f,0.0f);

			D3DXMATRIX mScal,mRot1,mRot2,mTrans,mFinal;   
			D3DXMatrixScaling(&mScal,20.0f,20.0f,20.0f);  
			D3DXMatrixTranslation(&mTrans,0,8000,0);
			D3DXMatrixRotationX(&mRot1, D3DX_PI/2); 
			D3DXMatrixRotationY(&mRot2, D3DX_PI/2); 
			mFinal=mScal*mRot1*mRot2*mTrans*matWorld;
			d3ddev->SetTransform(D3DTS_WORLD, &mFinal);
			for (int i=0;i<nums;i++)
			{
				d3ddev->SetMaterial(&mats[i]);
				d3ddev->SetTexture(0,textures[i]);
				mesh->DrawSubset(i);	
			}
			//font
			RECT rect={0,0,0,0};
			char strInfo[30];
			sprintf_s(strInfo, "(%.2f, %.2f, %.2f)", g_matWorld._41, g_matWorld._42, g_matWorld._43);
			string message = strInfo;
			font->DrawTextA(nullptr,message.c_str(),message.length(),&rect,DT_SINGLELINE | DT_NOCLIP | DT_LEFT,D3DCOLOR_XRGB(255,0,0));

			//Terrain
			myTerrain->RenderTerrain(&matWorld, false);

			//SkyBox
			D3DXMATRIX matSky,matTransSky,matRotSky;
			D3DXMatrixTranslation(&matTransSky,0.0f,-3500.0f,0.0f);
			D3DXMatrixRotationY(&matRotSky,-0.000005f*timeGetTime());
			matSky = matRotSky*matTransSky;
			mySkyBox->RenderSkyBox(&matSky,FALSE);
			//Cylinder
			D3DXMATRIX TransMatrix, RotMatrix, FinalMatrix;
			D3DXMatrixRotationX(&RotMatrix, -D3DX_PI * 0.5f);
			d3ddev->SetMaterial(&cylinderMat);
			for(int i = 0; i < 4; i++)
			{
				D3DXMatrixTranslation(&TransMatrix, -10000.0f, 0.0f, -15000.0f + (i * 20000.0f));
				FinalMatrix = RotMatrix * TransMatrix ;
				d3ddev->SetTransform(D3DTS_WORLD, &FinalMatrix);
				cylinder->DrawSubset(0);

				D3DXMatrixTranslation(&TransMatrix, 10000.0f, 0.0f, -15000.0f + (i * 20000.0f));
				FinalMatrix = RotMatrix * TransMatrix ;
				d3ddev->SetTransform(D3DTS_WORLD, &FinalMatrix);
				cylinder->DrawSubset(0);
			}
		


			//concrete rendering............................................................

			//stop rendering
			d3ddev->EndScene();
			d3ddev->Present(NULL, NULL, NULL, NULL);
		}
	}
	if (myInput->Key_Down(DIK_ESCAPE)) gameOver = true;
}