Skip to main content
gamedev.net
🔒 Locked

Sprites problem

Started by cbichis Mar 14, 2005 at 12:14 PM 4 replies 1.1k views
Original Post
cbichis
cbichis
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
Dave Hunt
Dave Hunt
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.
circlesoft
circlesoft
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.
cbichis
cbichis
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();
adriano_usp
adriano_usp
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);
cbichis
cbichis
Thank you guys,

My problem was solved due to your advices.

Cristian

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.