Jump to content
  • Advertisement
Sign in to follow this  
cbichis

Sprites problem

This topic is 4822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I have the following problem in DirectX 9c. I have a bitmap of 1024/650 pixels and I want to be render on the screen using a sprite. The problem is that the bitmap appears to be scaled vertically very much (he get's out of the screen in fact), and I cannot find any logical explanation. O width all it's fine. My code is: RECT srcRect; srcRect.top = 0; srcRect.left = 0; srcRect.bottom = 650; srcRect.right = 1024; D3DXVECTOR3 vCenter( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vPosition( 0.0f, 0.0f, 0.0f ); pd3ddev->BeginScene(); pSprite->Begin(D3DXSPRITE_ALPHABLEND); pSprite->Draw(pTexture, &srcRect, &vCenter, &vPosition, 0xFFFFFFFF); pSprite->End(); pd3ddev->EndScene(); Please give me some tips about how to solve this. Best Regards, Cristian

Share this post


Link to post
Share on other sites
Advertisement
Texture dimension must be a power of 2. If any dimension is not a power of 2, it will get scaled to the next power of 2. In this case, since 650 is not a power of 2, it is being scaled to 1024.

Share this post


Link to post
Share on other sites
IIRC, if you use D3DXCreateTextureFromFileEx() to load your texture and specify D3DX_DEFAULT_NONPOW2 for the width and height, it will not round the sizes to the next power of 2. However, your graphics hardware must support non-power-of-2 textures, which all current cards do.

Share this post


Link to post
Share on other sites
Hello!

My complete code is below. I am using 5200 or 6600 cards but still no luck.

D3DXCreateTextureFromFileEx(pd3ddev, pFileName, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0xFFFFFFFF, NULL, NULL, &pTexture);


D3DXCreateSprite(pd3ddev, &pSprite);

RECT srcRect;
srcRect.top = 0;
srcRect.left = 0;
srcRect.bottom = 650;
srcRect.right = 1024;

D3DXVECTOR3 vCenter( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vPosition( 0.0f, 0.0f, 0.0f );


pd3ddev->BeginScene();

pSprite->Begin(D3DXSPRITE_ALPHABLEND);

pSprite->Draw(pTexture, &srcRect, &vCenter, &vPosition, 0xFFFFFFFF);

pSprite->End();

pd3ddev->EndScene();

Share this post


Link to post
Share on other sites
One alternative would be not to use filters:

D3DXCreateTextureFromFileEx(pd3ddev, pFileName, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_FILTER_NONE, D3DX_DEFAULT, 0xFFFFFFFF, NULL, NULL, &pTexture);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!