本文整理汇总了C++中LPD3DXSPRITE::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXSPRITE::Draw方法的具体用法?C++ LPD3DXSPRITE::Draw怎么用?C++ LPD3DXSPRITE::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXSPRITE
的用法示例。
在下文中一共展示了LPD3DXSPRITE::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
int OpticSprite::draw(LPD3DXSPRITE sprite, double time, D3DXCOLOR colour, double offsetX, double offsetY) {
if(!this->animate) {
sprite->Draw(texture, NULL, NULL, NULL, colour);
return 1;
}
if(animation.lifetime() > time) {
animation.updateState(aniState, time);
colour = D3DXCOLOR(aniState.red, aniState.green, aniState.blue, colour.a < aniState.alpha? colour.a : aniState.alpha);
float rotation = 6.28318531f * aniState.rotation;
D3DXMATRIX mat, current;
D3DXVECTOR2 scaling(aniState.scale_x, aniState.scale_y);
D3DXVECTOR2 position(floor(((pResolution->width * aniState.position_x) - translateCentre.x) + offsetX),
floor(((pResolution->height * aniState.position_y) - translateCentre.y) + offsetY));
D3DXMatrixTransformation2D(&mat, &transformCentre, 0.0f, &scaling, &transformCentre, rotation, &position);
sprite->GetTransform(¤t);
mat *= current;
sprite->SetTransform(&mat);
HRESULT res;
//Spritesheet rect calculations are slightly iffy thanks to the texture scaling (rounding errors)
if(this->spritesheet) {
int x = (width * currFrame) % surfaceDesc.Width;
//Hacky workaround
int diff = x - surfaceDesc.Width;
if(abs(diff) <= 10) {
x = 0;
}
//End of hacky workaround
int y = height * currRow;
RECT source;
source.top = y;
source.left = x;
source.right = x + width;
source.bottom = y + height;
res = sprite->Draw(texture, &source, NULL, NULL, colour);
sprite->SetTransform(¤t);
if(!advanceFrame(time, x, y)) {
return 0;
}
} else {
res = sprite->Draw(texture, NULL, NULL, NULL, colour);
sprite->SetTransform(¤t);
}
if(res != S_OK) {
throw OpticSpriteException("Rendering sprite failed!");
}
return 1;
}
return 0;
}
示例2: currentPosition
void CTextureDx9::RenderWithoutTransform(LPD3DXSPRITE _lpDSpriteHandle, D3DXVECTOR2 position, D3DXVECTOR2 Center, D3DXVECTOR2 scale, float angle, D3DCOLOR color, RECT *srcRect, float deep)
{
D3DXVECTOR2 CamTransDistance;
CamTransDistance.x = -Camera::getInstance()->GetMatrixTranslate()._41;
CamTransDistance.y = Camera::getInstance()->GetMatrixTranslate()._42;
position.y += Camera::getInstance()->getBound().bottom;
Center.y += Camera::getInstance()->getBound().bottom;
D3DXVECTOR3 currentPosition(position.x + CamTransDistance.x, position.y, deep); //toa do trong the gioi thuc
D3DXMATRIX oldMatrix; //ma tran luu lai phep transform cua SpriteBatch
_lpDSpriteHandle->GetTransform(&oldMatrix);
D3DXVECTOR2 centerScale = D3DXVECTOR2(position.x, position.y);//lay vi tri cua vat the lam tam xoay(vi vi tri cua vat la vi tri chinh giua cua vat)
D3DXMATRIX matrixScalingRotate; //ma tran rotate, scale
D3DXMatrixTransformation2D(&matrixScalingRotate, ¢erScale, 0.0f, &scale, &Center, D3DXToRadian(angle), 0);
D3DXMATRIX finalMatrix = matrixScalingRotate * oldMatrix;
_lpDSpriteHandle->SetTransform(&finalMatrix); //ma tran chuyen toa do vi tri cua vat the tu the gioi thuc sang toa do trong directX de ve
_lpDSpriteHandle->Draw(
this->m_lpTexture,
srcRect,
&D3DXVECTOR3((float)(srcRect->right - srcRect->left)/2, (float)(srcRect->bottom - srcRect->top)/2, 0),
¤tPosition,
color);
_lpDSpriteHandle->SetTransform(&oldMatrix);
}
示例3:
//
// --------------------------------------------------------
// Renders the edit box and the internal text.
// --------------------------------------------------------
void DirectX::GUI::EditBox::render( LPD3DXSPRITE d3dsprite, const POINT* pos )
{
// Compute absolute offset
int xpos = m_posX + pos->x;
int ypos = m_posY + pos->y;
// Render edit box background sprite
Matrix fieldTransform;
float fieldScaleX = (float)m_sizeX / (float)(m_style->selectionBox.right - m_style->selectionBox.left);
float fieldScaleY = (float)m_sizeY / (float)(m_style->selectionBox.bottom - m_style->selectionBox.top);
D3DXMatrixTransformation2D( &fieldTransform, NULL, 0.0, &Vector2( fieldScaleX, fieldScaleY ), NULL,
NULL, &Vector2( (float)xpos, (float)ypos ) );
// Render the properly positioned sprite
d3dsprite->SetTransform( &fieldTransform );
d3dsprite->Draw( m_style->spriteSheet.getImage( ),
&m_style->selectionBox, NULL, NULL, 0xFFFFFFFF );
// Draw button text
if( m_state&FOCUSED ) m_cursorPosition = m_text.insert( m_cursorPosition, '|' );
Matrix iden; RECT textRect = { xpos, ypos, xpos+m_sizeX, ypos+m_sizeY };
D3DXMatrixIdentity( &iden ); d3dsprite->SetTransform( &iden );
m_style->font.getFont( )->DrawTextW( d3dsprite, m_text.c_str( ), -1,
&textRect, m_alignment, m_style->color );
if( m_state&FOCUSED ) { std::wstring::iterator next = m_cursorPosition; next++;
m_cursorPosition = m_text.erase( m_cursorPosition, next ); }
}
示例4: Render
void CGameEnd::Render(LPDIRECT3DDEVICE9& dxdevice, LPD3DXSPRITE& dxsprite)
{
dxsprite->Begin(D3DXSPRITE_ALPHABLEND);
dxsprite->Draw(GMAIN->m_pGameTex[6].m_pTex, &(GMAIN->rc), NULL, &(GMAIN->vcPos), D3DXCOLOR(1, 1, 1, 1.f));
////////////////////////////////////////////////////////////////////////////////
dxsprite->End();
GMAIN->m_text.Begin();
char scoreBuf[80];
TCHAR fpsBuf[128];
if (GMAIN->m_nGameBeforePhase == ST_MULTI) {
sprintf(scoreBuf, "%d", GGAMEMULTI->score);//멀티 게임 점수
}
else {
sprintf(scoreBuf, "%d", GGAME->score);//싱글 게임 점수.
}
GMAIN->m_text.Draw("Game Over", 355, 250, D3DXCOLOR(0, 0, 0, 1));
GMAIN->m_text.Draw("Total Score", 355, 300, D3DXCOLOR(0, 0, 0, 1));
GMAIN->m_text.Draw(scoreBuf, 355, 320, D3DXCOLOR(0, 0, 0, 1));
GMAIN->m_text.Draw("Press Enter for going back to Menu", 250, 400, D3DXCOLOR(0, 0, 0, 1));
////////////////////////////////////////////////////////////////////////////////
//FPS 화면에 출력
sprintf(fpsBuf, "FPS: %4.1f", GMAIN->m_fFps);
GMAIN->m_text.Draw(fpsBuf, 700, 300);
GMAIN->m_text.End();
}
示例5: fn_drawButton
HRESULT Li_lstBtnSprite::fn_drawButton(LPD3DXSPRITE dxSpriteInterface)
{
// Build our matrix to rotate, scale and position our sprite
D3DXMATRIX mat;
RECT srcRect;
srcRect.left = 0;
srcRect.right = m_Width;
switch (m_direction)
{
case 0: // Down
{
// draw the selected button in the list
srcRect.top = m_Height / m_lstSize * m_curSelect;
srcRect.bottom = m_Height / m_lstSize * (m_curSelect + 1);
} break;
default: break;
}
D3DXVECTOR3 translation;
translation.x = m_pos.x;
translation.y = m_pos.y;
translation.z = 0;
// out, scaling centre, scaling rotation, scaling, rotation centre, rotation, translation
D3DXMatrixTransformation(&mat, NULL, NULL, NULL, NULL, NULL, &translation);
dxSpriteInterface->SetTransform(&mat);
return dxSpriteInterface->Draw(m_dxTexture,&srcRect,NULL,NULL,0xFFFFFFFF);
}
示例6: DrawSprite
void CImage::DrawSprite(LPD3DXSPRITE SpriteInterface, LPDIRECT3DTEXTURE9 TextureInterface, int PosX, int PosY, int Rotation, int Align)
{
if(SpriteInterface == NULL || TextureInterface == NULL)
return;
D3DXVECTOR3 Vec;
Vec.x = (FLOAT)PosX;
Vec.y = (FLOAT)PosY;
Vec.z = (FLOAT)0.0f;
D3DXMATRIX mat;
D3DXVECTOR2 scaling(1.0f, 1.0f);
D3DSURFACE_DESC desc;
TextureInterface->GetLevelDesc(0, &desc);
D3DXVECTOR2 spriteCentre;
if(Align == 1)
spriteCentre = D3DXVECTOR2((FLOAT)desc.Width / 2, (FLOAT)desc.Height / 2);
else
spriteCentre = D3DXVECTOR2(0, 0);
D3DXVECTOR2 trans = D3DXVECTOR2(0, 0);
D3DXMatrixTransformation2D(&mat, NULL, 0.0, &scaling, &spriteCentre, (FLOAT)Rotation, &trans);
SpriteInterface->SetTransform(&mat);
SpriteInterface->Begin(D3DXSPRITE_ALPHABLEND);
SpriteInterface->Draw(TextureInterface, NULL, NULL, &Vec, 0xFFFFFFFF);
SpriteInterface->End();
}
示例7: Sprite_Transform_Draw
void Sprite_Transform_Draw(LPDIRECT3DTEXTURE9 image, int x, int y, int width, int height,
int frame, int columns, float rotation, float scaling, D3DCOLOR color)
{
//create a scale vector
D3DXVECTOR2 scale( scaling, scaling );
//create a translate vector
D3DXVECTOR2 trans( (float)x, (float)y );
//set center by dividing width and height by two
D3DXVECTOR2 center( (float)( width * scaling )/2, (float)( height * scaling )/2);
//create 2D transformation matrix
D3DXMATRIX mat;
D3DXMatrixTransformation2D( &mat, NULL, 0, &scale, ¢er, rotation, &trans );
//tell sprite object to use the transform
spriteobj->SetTransform( &mat );
//calculate frame location in source image
int fx = (frame % columns) * width;
int fy = (frame / columns) * height;
RECT srcRect = {fx, fy, fx + width, fy + height};
//draw the sprite frame
spriteobj->Draw( image, &srcRect, NULL, NULL, color );
}
示例8: drawStringMarkup
/**
* CBitmapFont::drawStringMarkup
* @date Modified Mar 29, 2006
*/
void CBitmapFont::drawStringMarkup(CString str, float fX, float fY, D3DCOLOR dwColor, bool bHandleSprite)
{
CRenderDevice& oDev = CRenderSystem::getInstance().getRenderDevice();
LPD3DXSPRITE pSprite = oDev.getD3DXSprite();
RECT rChar;
char cChar;
D3DXVECTOR3 vPos, vZero;
vPos.x = fX;
vPos.y = fY;
vPos.z = 0.0f;
vZero.x = vZero.y = vZero.z = 0.0f;
if(bHandleSprite)
beginSprite();
// Split strings
bool bFirst = false;
std::vector<CString> vStrings;
str.ToList(vStrings, TEXT("{}"));
if(str.GetChar(0) == '{')
bFirst = true;
// Iterate split strings, and change color if needed.
for(size_t v = 0; v < vStrings.size(); ++v)
{
// Get string, and read color
if((bFirst && v % 2 == 0) || (!bFirst && v % 2 == 1))
{
dwColor = vStrings[v].ToUlongFromHex();
continue;
}
// Iterate string and draw characters.
size_t nSize = vStrings[v].GetLength();
for(size_t i = 0; i < nSize; ++i)
{
cChar = vStrings[v].GetChar(i);
switch(cChar)
{
case '\n':
vPos.y += m_cLineHeight;
vPos.x = fX;
break;
case '\t':
vPos.x += m_mCharMap['X'] * 4;
break;
default:
getCharRect(cChar, &rChar);
pSprite->Draw(m_poTexture->getD3DTexture(), &rChar, NULL, &vPos, dwColor);
vPos.x += (rChar.right - rChar.left);
break;
}
}
}
if(bHandleSprite)
endSprite();
}
示例9: render
void Texture::render(LPD3DXSPRITE spriteHandle, const RECT* rect, const GVector3* center, const GVector3* position)
{
spriteHandle->Draw(
this->_texture,
rect,
center,
position,
_color);
}
示例10: Draw
void Sprite::Draw(float X,float Y,int Index,LPD3DXSPRITE _Handler)
{
D3DXMATRIX m;
D3DXMatrixIdentity(&m);
_Handler->SetTransform(&m);
_Handler->Draw(m_Image,&this->getRect(Index),
NULL,&D3DXVECTOR3(X,Y,0),D3DCOLOR_ARGB(255,255,255,255));
}
示例11: display
void Button::display(LPD3DXSPRITE spt){
if (visible){
D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 position((float)size.left, (float)size.top, 1.0f);
spt->Draw(*sprite, NULL, ¢er, &position, D3DCOLOR_XRGB(255, 255, 255));
(*font)->DrawTextA(spt,
text.c_str(),
text.length(),
&size,
DT_CENTER | DT_VCENTER | DT_SINGLELINE,
color);
}
}
示例12: Sprite_Draw_Frame
void Sprite_Draw_Frame(LPDIRECT3DTEXTURE9 texture, int destx, int desty, int framenum, int framew, int frameh, int columns)
{
D3DXVECTOR3 position( (float)destx, (float)desty, 0 );
D3DCOLOR white = D3DCOLOR_XRGB(255,255,255);
RECT rect;
rect.left = (framenum % columns) * framew;
rect.top = (framenum / columns) * frameh;
rect.right = rect.left + framew;
rect.bottom = rect.top + frameh;
spriteobj->Draw( texture, &rect, NULL, &position, white);
}
示例13: myAdditions
static void myAdditions(LPDIRECT3DDEVICE9 Device_Interface)
{
D3DXVECTOR3 imagepos;
BOOL currentState = (BOOL)(GetAsyncKeyState(VK_INSERT) & 0x8000);
//Switch ON and OFF
if(!currentState && oldState) //Si la touche passe de enfoncée à relevée
DRAW_CROSSHAIR ^= TRUE;
oldState = currentState;
if(DRAW_CROSSHAIR)
{
//Checks / Init =============================================================================================================
if(imagetex == NULL)
{
if(!SUCCEEDED(D3DXCreateTextureFromFileEx(Device_Interface, "crosshair.png", D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &imageInfo, NULL, &imagetex)))
{
DRAW_CROSSHAIR = FALSE;
return;
}
}
if(sprite == NULL)
{
if(!SUCCEEDED(D3DXCreateSprite(Device_Interface, &sprite)))
{
DRAW_CROSSHAIR = FALSE;
return;
}
}
//=============================================================================================================
if(SUCCEEDED(Device_Interface->BeginScene()))
{
//RESOLUTION ?
D3DVIEWPORT9 vp;
Device_Interface->GetViewport(&vp);
imagepos.x = (vp.Width - imageInfo.Width)/2.0f; //coord x of our sprite
imagepos.y = (vp.Height - imageInfo.Height)/2.0f; //coord y of out sprite
imagepos.z = 0.0f;
if(SUCCEEDED(sprite->Begin(D3DXSPRITE_ALPHABLEND)))
{
sprite->Draw(imagetex, NULL, NULL, &imagepos, 0xFFFFFFFF);
sprite->End();
}
Device_Interface->EndScene();
}
}
}
示例14: DrawSprite
void DrawSprite(LPD3DXSPRITE pSpriteBat,LPDIRECT3DTEXTURE9 pSpriteTex,
const RECT& to,D3DCOLOR col)
{
int w,h;
GetSpriteSize(pSpriteTex,w,h);
float sx=float(to.right-to.left)/w;
float sy=float(to.bottom-to.top)/h;
D3DXMATRIX scale;
D3DXMatrixScaling(&scale,sx,sy,1);
pSpriteBat->SetTransform(&scale);
pSpriteBat->Draw(pSpriteTex,NULL,NULL,
&D3DXVECTOR3(to.left/sx,to.top/sy,0),col);
pSpriteBat->SetTransform(&IDENTITY_MAT); // reset the matrix
}
示例15: DrawSprite
void DrawSprite(LPDIRECT3DTEXTURE9 s, int x, int y)
{
HRESULT hr = ddraw->Draw(s, NULL, &D3DXVECTOR3(0.0f, 0.0f, 0.0f), &D3DXVECTOR3((float)x, (float)y, 0.0f), D3DCOLOR_XRGB(255, 255, 255));
//s->sprite is the sprite to draw
//NULL tells it to draw the whole stinkin' thing (would normally be a pRECT
//D3DXVECTOR3 is the center point (just setting it to (0, 0)
//the second D3DVECTOR3 is the point to start drawing it on the screen
//the color is to draw at full intensity
/*HRESULT Draw(LPDIRECT3DTEXTURE9 pTexture,
CONST RECT* pSrcRect,
CONST D3DXVECTOR3* pCenter,
CONST D3DXVECTOR3* pPosition,
D3DCOLOR Color);*/
}