Archived

This topic is now archived and is closed to further replies.

pdstatha

Not displaying

Recommended Posts

Yeah its me again, i''ve encountered another problem , I''ve set up a vertex quad and tried to load a texture on to it. But when I call the render function it doesn''t display itself!!! Where the vertices get initialised
  bool CHardball::InitGame()
{
	//Setup panels for 2D

	m_pBackground = new CPanel(pD3D->getD3DDevice(),800,600,pWindow->getWidth(),pWindow->getHeight());
	m_pBackground->setTexture("Bckg.bmp", D3DCOLOR_XRGB(0, 0, 0));	//Load the texture and set the key colour

	return true;
}  
Rendering objects
  void CHardball::Render()
{
	pD3D->Clear(D3DCOLOR_XRGB(0, 0, 0));
	pD3D->BeginScene();	

	//Setup the camera ready for 2D elements

	Setup2DCamera();
	
	//Now that the 2D camera is setup, render the 2D objects

	Render2D();

	pD3D->EndScene();
	pD3D->Present();

	//Count Frames

	m_dwFrames++;
}
void CHardball::Render2D()
{
	m_pBackground->moveTo(0,0);
	m_dwTotalPolygons += m_pBackground->Render();
}
  
The CPanel Render function
  DWORD CPanel::Render()
{
	m_pD3DDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(PANEL_CUSTOMVERTEX));
	m_pD3DDevice->SetVertexShader(PANEL_D3DFVF_CUSTOMVERTEX);

	if(m_pTexture != NULL)
	{
		m_pD3DDevice->SetTexture(0, m_pTexture);
		m_pD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
	}
	else
	{
		m_pD3DDevice->SetTexture(0, NULL);
	}

	m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

	return 2;	//Return the number of polygons rendered

}  

Share this post


Link to post
Share on other sites

  bool CPanel::setTexture(const char *szTextureFilePath, DWORD dwKeyColour)
{

if(FAILED(D3DXCreateTextureFromFileEx(m_pD3DDevice, szTextureFilePath, 0, 0, 0, 0,
D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT,
D3DX_DEFAULT, dwKeyColour, NULL, NULL, &m_pTexture)))
{
return false;
}

return true;
}

Share this post


Link to post
Share on other sites