Jump to content
  • Advertisement
Sign in to follow this  
Fromethius

[C# 2005 Direct3D 9] Stretch Texture

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

Here is my code for drawing the texture onto the screen: sprite.Draw(Textures.Retrieve(Textures.Texture.Background), Vector3.Empty, Vector3.Empty, Color.White.ToArgb()); However, my image is 800x600 and my resolution is 1280x1024. How can I stretch the texture to occupy the entire screen? Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
I can't be sure how things are when you use C# and what I'm guessing is Managed DX (which if it were me, I'd abandon in favor of XNA), but here goes for C++/DX:


D3DXMATRIX stretch;

// scale along x- and y-axis, using texture-to-screen ratio
D3DXMatrixScaling( &stretch, 1280.0f / 800.0f, 1024.0f / 600.0f, 1.0f );

sprite.SetTransform( &stretch );
sprite.Draw( pTexture, NULL, NULL, NULL, 0xFFFFFFFF ); // this is identical to your call in C#


This is pseudo-code and should in no way reflect production code. For example, I used literals where I should have defined the appropriate constants and variables to store both rt and texture sizes.

Note that this transformation can easily been done in a vertex shader...

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!