Jump to content
  • Advertisement
Sign in to follow this  
peter_b

Is the ID3DXSprite interface broken, or am i going crazy?

This topic is 4977 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

I just tried it and what the hell! i must say. :-) It has some serius issues displaying the correct sizes of textures. So far it has only been able to display a 128x64 texture correctly. Sizes like 100x50, 640x480, 640x640 seems to be randomly resized to totaly wacko sizes. Now just don't assume it is working and that im a sucky noob. Iv been at it for hours, it just cant display most sizes! :-) This is what im doing, there aint many other ways to do it really. I just want to draw a 640x480 image as background. m_d3dx_sprite->Begin(0); D3DXVECTOR3 pos((float)posx, (float)posy, 0); m_d3dx_sprite->Draw(texture, 0, 0, &pos, 0xffffffff); m_d3dx_sprite->End(); The original image: http://hem.passagen.se/storage/proof2.gif The result of the above code, note that you dont see the end of the arrows: http://hem.passagen.se/storage/proof1.gif Is this known issues? Or am i experiencing some paranormal dimension shift here where im the only one its not working for? :-P I mean its a major system, i have a hard time imagening it would not work. But i can't deny what my eye's tell's me. Which leads to the conclusion that im doing something wrong. But what? I mean its a minimal interface and iv read the documentation several times, i cant find any other way to do it.. Has anyone else experienced this?

Share this post


Link to post
Share on other sites
Advertisement
It's not ID3DXSprite that's responsible for this, it's D3DXCreateTextureFromFile[Ex](). As Syranide said, if the texture isn't a power-of-two, then D3DXCreateTextureFromFile[Ex] will create a surface of the next power of two up (e.g. 100x50 becomes 128x64), and it'll make it square if the card requires it (so 100x50 becomes 128x128). The texture is only loaded into the top left corner of the texture though, and the rest of the surface is filled with black (although that might only be the debug D3DX library that does that, I don't know).
You can use the second parameter of ID3DXSprite::Draw() to specify the rectangle to use when drawing the texture, and you can get the size of the loaded texture from the last parameter to D3DXCreateTextureFromFileEx - it'll get filled with the size of the image (e.g. 100x50 in a 128x64 surface), and you can then plug that into the RECT you're using as the source rectangle when drawing.

Share this post


Link to post
Share on other sites
correct me if im wrong, i think if D3DX_FILTER_NONE is specified for D3DXCreateTextureFromFileEx, the loaded the image will not get scaled. However, u still got pow-of-2 surface, but the extra space will be transparent.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!