Jump to content
  • Advertisement
Sign in to follow this  

Source Rect for Texture

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

Hey all, I've used the ID3DXSprite interface and am now looking at the basis of it and messing around with textured quads. I have been reading this tutorial and I have noticed that there is no mention here of loading a large texture file and then using portions of it to texture the quads, only loading a texture and using all of it. I'm sure there has to be a way to set the source rect for a texture when using textured quads (that's what the sprite interface is derived from right?). Thanks in advance for any help. Jeff

Share this post


Link to post
Share on other sites
Advertisement
Look up information on texture coordinates. The basic idea is that each vertex is mapped to a certain location on the texture. Typically, you use values like 0.0 and 1.0, to map a vertex to the extreme edge of a texture, but if, for example, you have an 800x600 image on a 1024x1024 texture, you'll, need to use texture coordinates of 800/1024 (0.78125) and 600/1024 (0.5859375) for the right and bottom edges.

Share this post


Link to post
Share on other sites
Hmm, for some reason, I previously missed that you're using ID3DXSprite. What I told you will still help you understand what's going on behind the scenes, but probably won't help with ID3DXSprite specifically. However, while helping someone else with alpha-blending, I noticed that the 2nd parameter for the Draw() call for ID3DXSprite is a RECT called pSrcRect. You're probably currently passing NULL for this parameter. If you instead create a RECT struct, and fill it with the proper pixel values, it should use the specified portion of the texture, rather than the whole thing which it does if the parameter is NULL.

Share this post


Link to post
Share on other sites
No, you were right to skip that part...I'm not currently using the sprite interface. It is because of the sprite interface that I knew such a thing was possible. Thanks for the extra concern though.

Jeff

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!