Sign in to follow this  

[C# 2005 Direct3D 9] Stretch Texture

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

This topic is 3660 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this