Viewports, Present and RECT'S

Started by
2 comments, last by rohde 21 years, 10 months ago
I am slightly confused (again!). Could someone please help me out before I throw myself out from a tall building. Thank you Anyways, here goes: 1. With the use of IDirectDevice8::SetViewPort() I am able to render to onlay a small part of the screen. What if I've set a viewport and then use IDirectDevice8::Clear()? Will that clear the ENTIRE backbuffer or only the part definded by the use of IDirectDevice8::SetViewPort()? 2. The same with IDirectDevice8:: Present(). Will it only affect the part defined by the viewport or the entie backbuffer/fronbuffer (under the assumption that I am passing the value NULL to the RECT's parameters in IDirectDevice8:: Present() ) 3. Supposing I am using D3DSWAPEFFECT_COPY and specifying two rects in my IDirectDevice8:: Present() like this: globalpD3DDeivice->Present( rect1, rect2, NULL, NULL ); Can I then assume that only the frontbuffer's dest rect (rect2) is replaced by the source rect (rect1) i.e. the other parts of the frontbuffer is left untouched and presented to the display? In this way I can load and display a background image only once, and then just flip/copy the parts I need every frame. A year spent in artificial intelligence is enough to make one believe in God. [edited by - rohde on June 4, 2002 6:54:48 AM] [edited by - rohde on June 4, 2002 6:55:01 AM] [edited by - rohde on June 4, 2002 6:55:18 AM]
"We confess our little faults to persuade people that we have no large ones." -Francois de La Rochefoucauld (1613 - 1680). | My blog
Advertisement
quote:Original post by granat
There are no tall buildings in Denmark


Nej, what about Hotel Australia in Vejle..? , and the windows are easy to fall out of


And back to the original questions:

1a. The docs for Clear() say: "Clears the viewport, or a set of rectangles in the viewport" . So, as documented, it only clears the region specified by the viewport.

1b. If you''re doing split-screen, its often better to have one extra viewport representing the whole screen and do a single Clear on that rather than one for each view.


2. If you pass NULL as the rectangles to Present, then the whole surface (within the swapchain) will be presented.


3. Yes. However, in fullscreen, forcing a graphics chip to do a copy like that can cause a lot of costly behind the scenes copying to go on (see the note in the documentation for D3DSWAPEFFECT). So if you''re doing this for performance reasons you may find it has a negative effect!!. Wait until you have a profilable app before you start attempting "guess" based optimisations.

The viewport isn''t anything special - all it does is scales and offsets clip space vertices into a screen area. I suggest reading the "Viewports and Clipping" topic in the docs a few times.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

quote:Original post by S1CA
I suggest reading the "Viewports and Clipping" topic in the docs a few times.


Thanks, for the answers. I will go and read that now. I just wanna elaborate on something.

quote:Original post by S1CA
3. Yes. However, in fullscreen, forcing a graphics chip to do a copy like that can cause a lot of costly behind the scenes copying to go on (see the note in the documentation for D3DSWAPEFFECT). So if you're doing this for performance reasons you may find it has a negative effect!!.


So what you're saying is that I might as well just use D3DSWAPEFFECT_DISCARD (or maybe D3DSWAPEFFECT_FLIP?) and then just draw the background image together with the moving objects each frame?

I just thought thath it's the usual thing to do when there's a background image that'll stay the same. But it doesn't seem that way.

Thanks again.
--------------------------
A year spent in artificial intelligence is enough to make one believe in God.

[edited by - rohde on June 4, 2002 11:15:07 AM]
"We confess our little faults to persuade people that we have no large ones." -Francois de La Rochefoucauld (1613 - 1680). | My blog
quote:So what you''re saying is that I might as well just use D3DSWAPEFFECT_DISCARD (or maybe D3DSWAPEFFECT_FLIP?) and then just draw the background image together with the moving objects each frame?


Yes. Generally graphics chips and their drivers are optimised for the most common rendering paths - which is most often (with 3D graphics which is where they make their money) set up to flip the whole render target every frame. Also display hardware such as monitors and TVs display in terms of "frames" whereby *ALL* of the visible area is updated, flipping with multiple render targets fits well with this, partial updates don''t.

If you wanted to not update certain areas of the screen, a much better way to do it would be to pass smaller areas to the Clear() call so the area of the screen which stays the same never gets cleared.


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement