Sprite aspect ratio??

Started by
2 comments, last by mdias 18 years, 7 months ago
I loaded the sprite in photoshop and took the exact pixel pos and width of the sprite I wanted to load. I used the same pixel point in Directx. It gives all weird result. It does not match. Although the sprite is square I have to read more pixel in width than height to get complete sprite. I thought aspect ratio might fix it so, I did this. height = 32; width = 32 * (SCREEN_WIDTH/SCREEN_HEIGHT); Isn't this correct or am I doing something wrong?? This does not work either. Somebody HELP
Advertisement
If the sprite is square then it's width and height should be the same.
Maybe the bottleneck lies in your projection matrix?
Be sure to make the projection matrix's aspect ratio match backbuffer_width/backbuffer_height, unless you're using an orthogonal matrix [smile]
Also, make sure it's not your backbuffer that's being streched or something.
D3DXMatrixPerspectiveFovLH(
&proj, // result
D3DX_PI * 0.25f, // 45 - degrees
(float)Width / (float)Height, // aspect ratio
1.0f, // near plane
1000.0f);

This is how I set my projection matrix. Is this wrong?
It isn't as long as Width and Height correspond to the size of the backbuffer, and to the destination rect of your window.

This topic is closed to new replies.

Advertisement