예제 #1
0
void Game::drawScene()
{

	// Clear the backbuffer and depth buffer.
	HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, gMyGameWorld->Background(), 1.0f, 0));

	HR(gd3dDevice->BeginScene());

	// Setup the rendering FX
	HR(mFX->SetTechnique(mhTech));
	
	//gMyGameWorld->Render(mFX, mhWVP, mView, mProj);
	gMyGameWorld->Render(mFX, mhWVP, DXCI->getView(), mProj);

	displayGfxStats();

	//sprite
	mSprite->Begin(D3DXSPRITE_ALPHABLEND);

	mSprite->Flush();
	mSprite->End();

	HR(gd3dDevice->EndScene());

	// Present the backbuffer.
	HR(gd3dDevice->Present(0, 0, 0, 0));


}
예제 #2
0
bool cTexture::draw
( 
	long p_destX, long p_destY, 
	long p_srcX /*= 0*/, long p_srcY /*= 0*/, 
	long p_width /*= 0*/, long p_height /*= 0*/, 
	D3DCOLOR p_color /*= 0xffffffff*/,
	D3DXVECTOR2 *p_pRotationCenter /*= NULL*/,
	float p_angle /*= 0.0f*/, 
	float p_XScale /*= 1.0f*/, float p_YScale /*= 1.0f*/
)
{
	RECT rect;
	ID3DXSprite *pSprite;
	
	if(m_pTexture == NULL)
		return FALSE;
	if(m_pGraphics == NULL)
		return FALSE;
	if((pSprite = m_pGraphics->getSprite()) == NULL)
		return FALSE;
	
	if(!p_width)
		p_width = m_width;
	if(!p_height)
		p_height = m_height;
	
	rect.left = p_srcX;
	rect.top  = p_srcY;
	rect.right = rect.left + p_width;
	rect.bottom = rect.top + p_height;
	
	//D3DXVECTOR3 Center = D3DXVECTOR3(10, 10, 1);          // 材质的矩形区域的中心点
	D3DXVECTOR3 Position = D3DXVECTOR3((float)p_destX, (float)p_destY, 0);   // 画的位置
	
	pSprite->Begin(D3DXSPRITE_ALPHABLEND);
	D3DXVECTOR2 Scaling(p_XScale, p_YScale);                         // 縮放比例
	/*D3DXVECTOR2 RotationCenter( p_destX + p_width / 2,
								p_destY + p_height / 2 );*/
	D3DXMATRIX  Matrix;  // 坐标转换矩阵 
	D3DXVECTOR2 d3dx_vector2((float)p_destX, (float)p_destY);
	D3DXMatrixTransformation2D(&Matrix, &d3dx_vector2, 
		0.0, &Scaling, p_pRotationCenter, p_angle, 0 );
	pSprite->SetTransform(&Matrix);
	pSprite->Draw( m_pTexture, &rect, NULL, &Position, p_color);
	pSprite->End();
	return true;
}