示例#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::Blit(long DestX, long DestY,                   \
                    long SrcX, long SrcY,                     \
                    long Width, long Height,                  \
                    float XScale, float YScale,               \
                    D3DCOLOR Color)
{
  RECT Rect;
  ID3DXSprite *pSprite;

  if(m_Texture == NULL)
    return FALSE;
  if(m_Graphics == NULL)
    return FALSE;
  if((pSprite = m_Graphics->GetSpriteCOM()) == NULL)
    return FALSE;

  if(!Width)
    Width = m_Width;
  if(!Height)
    Height = m_Height;

  Rect.left = SrcX;
  Rect.top  = SrcY;
  Rect.right = Rect.left + Width;
  Rect.bottom = Rect.top + Height;

  if(FAILED(pSprite->Draw(m_Texture,&Rect,NULL, NULL,Color)))
    return FALSE;
  return TRUE;
}
示例#3
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;
}
示例#4
0
void Game::onLostDevice()
{
	HR(mFX->OnLostDevice());
	HR(mFont->OnLostDevice());

	gMyGameWorld->OnLostDevice();
	mSprite->OnLostDevice();
}
示例#5
0
void Game::onResetDevice()
{
	HR(mFX->OnResetDevice());
	HR(mFont->OnResetDevice());

	gMyGameWorld->OnResetDevice();
	mSprite->OnResetDevice();

	// The aspect ratio depends on the backbuffer dimensions, which can 
	// possibly change after a reset.  So rebuild the projection matrix.
	buildProjMtx();
}
	void nekoGUISelectionButtons::Draw()
	{
		if(mButtons.empty())
			return;

		nekoVideoDriver *videoDrv = GetNekoNovel()->GetVideoDriver();
		ID3DXSprite *sprite = videoDrv->GetSprite();

		uint32 color = GetNekoNovel()->GetCurrentGame()->GetEnvironment().mSelectionColor;
		list<nekoOneButton *>::iterator iter = mButtons.begin();
		int32 a;
		int32 i = 0;
		D3DXMATRIX matIdentity;

		D3DXMatrixIdentity(&matIdentity);
		matIdentity *= videoDrv->GetBaseMatrix();

		for(;iter != mButtons.end();++iter, ++i)
		{
			if(mSelectedIndex == i)
				a = mButtonState;
			else
				a = 0;

			if(!(*iter)->mImage[a])
				continue;

			videoDrv->DrawImage((*iter)->mImage[a], 
				(*iter)->rect.left, (*iter)->rect.top,
				-1, -1, 0xffffffff, 0, 0, -1, -1, 0, 1, 1, 0.46f);

			sprite->SetTransform(&matIdentity);

			nekoPoint center = (*iter)->rect.GetCenter();
			RECT rect = {center.x - (*iter)->mTextSize.x / 2, center.y - (*iter)->mTextSize.y / 2, 0, 0};
			(*iter)->mFont->DrawText(sprite, (*iter)->mCaption.c_str(), -1, &rect, DT_NOCLIP, color);
		}
	}