Archived

This topic is now archived and is closed to further replies.

d000hg

How do I just copy part of the backbuffer to a window?

Recommended Posts

My level editor uses d3d in windowed mode. The problem is that when you resize the window, it still copies the whole backbuffer into the client area, when I want it to reduce the are being viewed, but keep it at the same scale. I tried viewports but that just renders to part of the backbuffer, then the whole backbuffer is still downsized to the window. I could reset D3D to get a new device but that seems a dirty hack!
Read about my game, project #1 NEW (13th August): A new screenshot is up, plus diaries for week #3
John 3:16

Share this post


Link to post
Share on other sites
Another alternative is to render to a texture and each frame render that texture (on a quad) to the screen. Use XYZ_RHW for your quad coordinates and you should be laughing.

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

[edited by - thedo on August 14, 2002 6:34:07 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What is happening in your code!!!???

When you resize the window, absolutely no surface is resized, this has to be treated by you in the code (and if you don''t resize the surface then you will get some interesting artefacts, trust me).

I''ll assume your building on the DX samples, then you must remember that (if you look at their code) when the program receives the end resize command the base class resizes all the surfaces and resets all relevant data, namely, part of your problem must reside in the resetting of some the matrix data.

But let''s leave that alone (as one way that this could be done would be to keep a backsurface and only present part of it (that''s why the present command has those parameters), but this approach might not work correctly, or you could simply find out where the data is being reset and fix what you want).

For your case, I recommend creating a surface and a render to surface interface (it''s in the D3DX part, and to initialize it you just need to call one function with all the data it needs), then on every render pass you render to the surface (instead of a backbuffer) and when your done you just need copy the relevant part of the surface to the backbuffer (the documentation has some examples of some of these steps). Don''t forget to change the beginscene and endscene stuff so that your running in the render to scene interface (which will render to the surface) and not in the d3ddevice interface (which will render to the backbuffer), read the documentation. With a little work I got this up and running in one afternoon.

I only recommend this approach because, as your making a level editor you might want various views and with one surface and one render to surface interface you can render various views, you''ll need various view (and possibly projection) matrices, on to the backbuffer.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What is happening in your code!!!???

When you resize the window, absolutely no surface is resized, this has to be treated by you in the code (and if you don''t resize the surface then you will get some interesting artefacts, trust me).

I''ll assume your building on the DX samples, then you must remember that (if you look at their code) when the program receives the end resize command the base class resizes all the surfaces and resets all relevant data, namely, part of your problem must reside in the resetting of some the matrix data.

But let''s leave that alone (as one way that this could be done would be to keep a backsurface and only present part of it (that''s why the present command has those parameters), but this approach might not work correctly, or you could simply find out where the data is being reset and fix what you want).

For your case, I recommend creating a surface and a render to surface interface (it''s in the D3DX part, and to initialize it you just need to call one function with all the data it needs), then on every render pass you render to the surface (instead of a backbuffer) and when your done you just need copy the relevant part of the surface to the backbuffer (the documentation has some examples of some of these steps). Don''t forget to change the beginscene and endscene stuff so that your running in the render to scene interface (which will render to the surface) and not in the d3ddevice interface (which will render to the backbuffer), read the documentation. With a little work I got this up and running in one afternoon.

I only recommend this approach because, as your making a level editor you might want various views and with one surface and one render to surface interface you can render various views, you''ll need various view (and possibly projection) matrices, on to the backbuffer.

Share this post


Link to post
Share on other sites