Skip to main content
gamedev.net
🔒 Locked

Not displaying

Started by pdstatha 2 replies 850+ views
Original Post
pdstatha
pdstatha
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

}  
Hippokrates
Hippokrates
Well, you did not include the code on loading the texture.
And we will hardly find any errors when you just post your calls to your engine functions.

Im Anfang war die Tat...
Faust
Im Anfang war die Tat...Faust
pdstatha
pdstatha

  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;
}
pdstatha
pdstatha
bump

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.