Sign in to follow this  


Recommended Posts

I noticed that when I try to cram large Surfaces into small Destinations you get some pretty funky results. Like say I try a Source RECT of 1280 X 1024 into a 100 X 100 RECT Destination sometime's it will split up the Surface and sort of display parts of the selected surface in multiple locations. Or just not go to the proper destination under some condition and sometimes will. Is there a relitivly easy solution to this other than just don't try to do that? What is a good rule of thumb for how much you downsize a Surface when drawing to the backbuffer with StretchRect()?

Share this post

Link to post
Share on other sites
If I recall correctly, it could be your mipmap and/or filtering settings which are corrupting your results.

Try using D3DDevice->SetSamplerState() and set D3DSAMP_MIPFILTER to D3DTEXF_NONE, and if that doesn't fix it try setting D3DSAMP_MAGFILTER and MINFILTER to D3DTEXF_POINT.

Share this post

Link to post
Share on other sites

I don't know if this might help you, but I use D3DXLoadSurfaceFromSurface to
copy and stretch surfaces.

The most important parameter to this function is the Flags. This determines the stretching algorithm used. D3DX_FILTER_BOX and D3DX_FILTER_POINT are the fastest. You can also use D3DX_FILTER_DEFAULT.


IDirect3DXSurface srcsurface (1024x768)
IDirect3DXSurface dstsurface (512x384)



Share this post

Link to post
Share on other sites
Setting the Sample State didn't fix it. The Copy Surface to Surface got the right effect, but it's very, very slow. I want to display an updated image of my game world in a small corner of the screen so I can moniter what's going on while I test path finding and such. So I really can't call Copy Surface into Surface Functions when it to update every frame.
The thing that get's me is if I place it
left = 0;
right = 100;
top = 0;
bottom= 100;
It displays fine.
left = 100;
right = 200;
top = 100;
bottom= 200;
The pic slips into two spots and stays alinged to the left side.
left = 200;
right = 300;
top = 200;
bottom= 300;
Displays fine again.

I guess it really only matters that it displays fine in the upper left for the moment but if I wanted to put it in the lower right, I get funky results again.

Share this post

Link to post
Share on other sites
Instead of using StretchRect, another idea could be to render a small sreen-aligned quad and just texture this quad with the image you want to display.

About a year or two ago, I did some informal performance measurements between using StretchRect and rendering a screen-aligned quad. For my purposes, both gave the same performance. But remember that StretchRect has a whole slew of limitations that could cause it it perform more poorly or not at all.

I guess what you're going for is kind of a "picture in picture" deal like some televisions have. Texturing a screen-aligned quad will do this nicely.


Share this post

Link to post
Share on other sites
Ah yes for some reason I got the idea that you were stretching the texture over quads - which is where the sampler state issues can have a detrimental effect. The sampler state has no control over the actual StretchRect() function as that does not go through the graphics pipeline.

Rendering screen-space quads is the accepted way of displaying lots of rectangular images - and its very easy - simply use a transformed vertex format. I can give you more help on this subject if you need it.

Share this post

Link to post
Share on other sites

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