6 Replies - 556 Views - Last Post: 04 November 2011 - 08:41 PM Rate Topic: -----

#1 bijan311  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 31-January 10

Can't draw meshes and text at the same time in direct3d 10

Posted 29 October 2011 - 02:17 PM

When I try to draw a some text and a mesh at the same time the screen is blank, but if I only draw one it would work just fine. Does anyone know what the problem is?

Thank You.
Is This A Good Question/Topic? 0
  • +

Replies To: Can't draw meshes and text at the same time in direct3d 10

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Can't draw meshes and text at the same time in direct3d 10

Posted 30 October 2011 - 04:01 AM

Not without code! You've been posting long enough here to know that.
Was This Post Helpful? 0
  • +
  • -

#3 bijan311  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 31-January 10

Re: Can't draw meshes and text at the same time in direct3d 10

Posted 30 October 2011 - 04:38 PM

Alright, here's my code.

void GamePaint()
{
	g_pGame->CreateFont(20, 0, FW_BOLD, FALSE);
	g_pGame->DrawText(TEXT("Hello World"), 10, 10, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f));
	g_pModel->Draw();
}

void BimanEngine::CreateFont(int height, int width, UINT weight, BOOL italics)
{
	HRESULT hr = D3DX10CreateFont(m_pD3DDevice, height, width, weight, 1, italics, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 
		DEFAULT_PITCH | FF_DONTCARE, TEXT("Ariel"), &m_pFont);

	if(FAILED(hr))
		Error(TEXT("Can't create font object"));
}

void BimanEngine::DrawText(LPCWSTR szText, int x, int y, D3DXCOLOR TextColor)
{
	RECT rect = {x, y, 0, 0};
	
	//Display rect
	HRESULT hr = m_pFont->DrawTextW(m_pFontSprite, szText, -1, &rect, DT_NOCLIP, TextColor);
	if(FAILED(hr))
		Error(TEXT("DrawText Failed"));
}

void ModelObject::Draw()
{
	//Make sure the mesh is valid
	if(!m_pMesh)
		return;

	m_pDevice->IASetInputLayout(m_pInputLayout);

	//Render the object
	D3D10_TECHNIQUE_DESC TechniqueDesc;
	m_pTechnique->GetDesc(&TechniqueDesc);

	for(UINT p = 0; p < TechniqueDesc.Passes; ++p)
	{
		m_pTechnique->GetPassByIndex(p)->Apply(0);
		
		//Draw the mesh
		m_pMesh->DrawSubset(0);
	}
}


Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Can't draw meshes and text at the same time in direct3d 10

Posted 31 October 2011 - 02:58 AM

Just on first glance you are doing something highly inefficient.

g_pGame->CreateFont(20, 0, FW_BOLD, FALSE);



You are calling this every time you draw the scene, bad! You want to put this into a function that gets called once before moving onto rendering. So you will load and create objects once then render and update them each frame or within whatever time frame you want.

Another thing, where are your matrices? you are going to need them.
Was This Post Helpful? 0
  • +
  • -

#5 bijan311  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 31-January 10

Re: Can't draw meshes and text at the same time in direct3d 10

Posted 01 November 2011 - 03:49 PM

View Poststayscrisp, on 31 October 2011 - 03:58 AM, said:

Another thing, where are your matrices? you are going to need them.


They are right here

void BimanEngine::Rotate(float RotationAngle, BOOL bXAxis)
{
	if(bXAxis)
		D3DXMatrixRotationX(&m_mxWorld, RotationAngle);
	else
		D3DXMatrixRotationY(&m_mxWorld, RotationAngle);
}

void BimanEngine::SetCamera(D3DXVECTOR3 Eye, D3DXVECTOR3 At)
{
	D3DXMatrixLookAtLH(&m_mxView, &Eye, &At, new D3DXVECTOR3(0.0f, 1.0f, 0.0f));
}

//This is in the InitD3D function
D3DXMatrixPerspectiveFovLH(&m_mxProjection, (float)D3DX_PI * 0.5f, (float)m_iWidth/(float)m_iHeight, 0.1f, 100.0f);

//This is needed for camera to work
Rotate(0.0f, FALSE);

void BimanEngine::Update()
{
	//Send the Projection Matrix value to the effect file
	D3DXMATRIX FinalMatrix = (m_mxWorld * m_mxView * m_mxProjection);
	m_pProjectionMatrix->SetMatrix((float*)FinalMatrix);

}


Was This Post Helpful? 0
  • +
  • -

#6 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 998
  • View blog
  • Posts: 4,173
  • Joined: 14-February 08

Re: Can't draw meshes and text at the same time in direct3d 10

Posted 02 November 2011 - 07:40 AM

Please have a good read of this http://www.toymaker....l/matrices.html it will make things a lot clearer :)
Was This Post Helpful? 0
  • +
  • -

#7 bijan311  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 31-January 10

Re: Can't draw meshes and text at the same time in direct3d 10

Posted 04 November 2011 - 08:41 PM

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1