本文整理汇总了C++中LPD3DXSPRITE::DrawTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXSPRITE::DrawTransform方法的具体用法?C++ LPD3DXSPRITE::DrawTransform怎么用?C++ LPD3DXSPRITE::DrawTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXSPRITE
的用法示例。
在下文中一共展示了LPD3DXSPRITE::DrawTransform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSprite
void Renderer::DrawSprite(Vector2 position, float width, float height, TexCoord textureCoordinates, float angle,Vector2 rotationPoint)
{
#if IS_XBOX
// Convert Param Information into proper structures
XGVECTOR2 scale;
scale.x = (IMAGE_TO_SCREEN_X / SCREEN_WIDTH) / textureCoordinates.width * width;
scale.y = (IMAGE_TO_SCREEN_Y / SCREEN_HEIGHT) / textureCoordinates.height * height;
RECT tex;
tex.top = (LONG)((textureCoordinates.y)*IMAGE_HEIGHT);
tex.bottom = (LONG)((textureCoordinates.y + textureCoordinates.height)*IMAGE_HEIGHT);
tex.left = (LONG)((textureCoordinates.x)*IMAGE_WIDTH);
tex.right = (LONG)((textureCoordinates.x + textureCoordinates.width)*IMAGE_WIDTH);
XGVECTOR2 rot;
rot.x = rotationPoint.x - position.x;
rot.y = rotationPoint.y - position.y;
XGVECTOR2 pos;
pos.x = position.x;
pos.y = position.y;
m_sprite->Begin();
// Transform and Draw the Sprite
# if FALSE
// Apply Transform Matrix
D3DXMATRIX matWorld;
D3DXMatrixIdentity(&matWorld);
D3DXMATRIX matTransform;
D3DXMatrixScaling(&matTransform, scale.x, scale.y, 1);
D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
if(angle != 0){
D3DXMatrixTranslation(&matTransform, - rotationPoint.x, - rotationPoint.y , 0.0f);
D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
D3DXMatrixRotationZ(&matTransform, angle);
D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
D3DXMatrixTranslation(&matTransform, rotationPoint.x, rotationPoint.y , 0.0f);
D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
}
D3DXMatrixTranslation(&matTransform, position.x, position.y, 0.0f);
D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
m_sprite->DrawTransform(g_pTextureMap[currentID], &tex, &matWorld, 0xffffffff);
# else
// Trust Draw Method
m_sprite->Draw(g_pTextureMap[currentID], &tex, &scale, &rot, angle, &pos, 0xffffffff);
# endif
m_sprite->End();
#else
// Simple inversion of the texture for DirectX
textureCoordinates.y = 1 - textureCoordinates.y;
GLdouble matrix[16];
glGetDoublev(GL_MODELVIEW_MATRIX, matrix);
Vector2 topLeft, topRight, bottomLeft, bottomRight;
topLeft = position;
topRight = position;
bottomLeft = position;
bottomRight = position;
topRight.x += width;
bottomLeft.y += height;
bottomRight.x += width;
bottomRight.y += height;
if (angle != 0) {
topLeft.rotateOnPivot(angle, &rotationPoint);
topRight.rotateOnPivot(angle, &rotationPoint);
bottomLeft.rotateOnPivot(angle, &rotationPoint);
bottomRight.rotateOnPivot(angle, &rotationPoint);
}
glGetDoublev(GL_MODELVIEW_MATRIX, matrix);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTextureID[currentID]);
glBegin(GL_QUADS);
glTexCoord2f(textureCoordinates.x, textureCoordinates.y);
glVertex2f(topLeft.x, topLeft.y);
glTexCoord2f(textureCoordinates.x, textureCoordinates.y - textureCoordinates.height);
glVertex2f(bottomLeft.x, bottomLeft.y );
glTexCoord2f(textureCoordinates.x + textureCoordinates.width, textureCoordinates.y - textureCoordinates.height);
glVertex2f(bottomRight.x , bottomRight.y );
glTexCoord2f(textureCoordinates.x + textureCoordinates.width, textureCoordinates.y);
glVertex2f(topRight.x, topRight.y);
//.........这里部分代码省略.........