Jump to content
  • Advertisement
Sign in to follow this  
Sandra-24

Using Direct3D to draw a 2D image

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

All I want to do is draw a 2D image onto a window. I've finally managed to this using two traingles and 4 PositionTextured vertices. The image is 3500x2400 pixels and I want to be able to scroll to see the entire image. So in the render loop I create 4 vertices to display the image 1 pixel over each time and the image scrolls around rapidly. However the drawing is far from perfect. There's all kinds of wavy blurry things happening and I can see the join between the triangles as it's drawing. I know this is nothing compared to the drawing involved even in trivial games, but why can't I get the image to scroll nicely? I'm fast running out of ideas an patience, is there anything I can try? Thanks, -Sandra

Share this post


Link to post
Share on other sites
Advertisement
The blurriness is probably due to what happens when the image is loaded into a texture. For one thing many cards don't support textures larger than 2048x2048, so your texture is probably scaled to fit these proportions (or the max for your specific video card) when you load it, with a loss in quality. You should consider splitting the image into several smaller images and render them side by side.

Second most video cards requires textures to be square and with dimensions that are power of two (128, 256, 512, etc.) and similarly the textures will be scaled to the closest power dimension. You need to consider this when you split the image and make sure all the partial images are of power-of-two dimensions.

Share this post


Link to post
Share on other sites
Quote:
Original post by staaf
Second most video cards requires textures to be square

I don't think so. Most videocards handle non-square textures just fine, as long as its dimensions are powers of two.

Share this post


Link to post
Share on other sites
Thanks for pointing that out centipede. Well, to be specific you can check this for you specific video card with DX Caps Viewer or with the Caps functionality in the API.

I dont know how many actual cards there are that do support non-square textures today. Probably all newer cards have this support. Still it is a possible cause for Sandra's problem. I've had problems with this myself when moving apps from one machine to another with older video cards installed.

Share this post


Link to post
Share on other sites
That didn't occur to me, I'll make it into several square power of 2 images and see if that helps. Thanks for your help.

-Sandra

Share this post


Link to post
Share on other sites
Are you using an orthographic projection and correctly mapping texels to pixels? Your quad should be offset from the actual top right pixel by (-.5, -.5) to correctly draw texels to pixels. otherwise texels will become blended together and appear blurred.

Share this post


Link to post
Share on other sites
No, I don't think I'm mapping pixels to texels correctly at all, nor am I using any projections at all, just a Viewport, not sure if that's what I should be doing but it was the only way I got my code to work.

I'm reworking the code a little here, I'll post my code when I get that finished in an hour or two (I hope.)

Thanks for your help guys, I'm an experienced programmer, but DirectX is new (and scary) to me.

-Sandra

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!