Jump to content
  • Advertisement
Sign in to follow this  
kazenofairy

[HLSL/Direct3D] Drawing a texture quad

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

Hello,

I've been using these forums as help for a while, but this is actually the first time I will be posting. Maybe I am very bad at searching but I've been unable to find anything about this.

I am pretty new to DirectX and HLSL. I want to do page flipping animation using textures and HLSL shaders. I know it is far easier using ID3DXSprite but I don't want to do it that way as I already have everything set the other way. What I actually want to know is... how do you tell the HLSL shader that you want to draw just a portion of the texture?

I know that changing the Tu and Tv elements of the VertexBuffer can help you achieve that but I don't really know/think it is a good idea to keep locking, changing and unlocking the vertex buffer each time I draw a game object.

Does anyone know a way to do this right? Maybe setting some values in the vertex or pixel shader?

Hope I explained myself.

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Doing it in the vertex shader could be as easy as 4 adds to your quad's uv coordinates if you have your sprite frames in a strip. Not costly at all :D

Share this post


Link to post
Share on other sites
Really? Thanks for the info! Although, I already tried to find examples on how to do that and I was not able to found any. Is there any guidance that you can give me? Thanks again!

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!