Page 1 of 1
Best way to clear only the viewport in DirectX 10?
Posted: Mon Nov 03, 2008 2:18 am
by unholysavagery
Well I'm trying to add a feature to my engine which allows multiple render targets to a window or texture, so you can do things like split screen coop games but I have a small problem I could fix in a crappy way but I'd like to know if anyone has a better idea. Well the problem is that when I clear the render target view it does not just clear the area in the viewport but also the entire render target view so I could just draw a quad to clear the screen but I think it may effect performance a bit. So does anyone know of a better way of clearing the area inside the viewport?
Re: Best way to clear only the viewport in DirectX 10?
Posted: Tue Nov 04, 2008 10:37 am
by MarauderIIC
Are you looking for a DirectX equivalent of
http://sdl.beuc.net/sdl.wiki/SDL_UpdateRect then?
Re: Best way to clear only the viewport in DirectX 10?
Posted: Tue Nov 04, 2008 6:18 pm
by Trask
Hey, I hope this helps as this is the only clear thing that I can find:
Use IDirect3DDevice9::Clear to clear the viewport. The method accepts one or more rectangles that define the areas on the surface being cleared. Setting the Count parameter to 1, and the pRects parameter to the address of a single rectangle that covers the entire viewport area will clear the entire viewport. Another way to clear the entire viewport is to set the pRects parameter to NULL and the Count parameter to 0.
This is coming from:
http://msdn.microsoft.com/en-us/library ... S.85).aspx and it's using DirectX 9, but it will hopefully step you in the right direction.
http://msdn.microsoft.com/en-us/library ... S.85).aspx <- This is DirectX 10 specific, but I couldn't find what you're looking for on a cursory glance, it's quite possible that the syntax may be the same, but I'm sure you'd be able to dig it out of here quicker than me.
Re: Best way to clear only the viewport in DirectX 10?
Posted: Wed Nov 05, 2008 11:59 am
by unholysavagery
Well some random guy on the XNA forums said the only way to do it is to use a quad, so since I have nothing else to go on it's my only option.
Re: Best way to clear only the viewport in DirectX 10?
Posted: Wed Nov 05, 2008 12:04 pm
by unholysavagery
No thanks this is a 3D engine that is being built for many years from now so DirectX 10 is a viable option for me, though clearly microsoft has not smoothed out all the rough edges yet.
Re: Best way to clear only the viewport in DirectX 10?
Posted: Thu Nov 06, 2008 4:36 pm
by MarauderIIC
I wasn't saying use SDL, I was asking if that did the same type of thing. Update a portion of the screen. If you're not drawing to it any more, then...
Trask's solution doesn't work?
Re: Best way to clear only the viewport in DirectX 10?
Posted: Thu Nov 06, 2008 7:28 pm
by unholysavagery
MarauderIIC wrote:I wasn't saying use SDL, I was asking if that did the same type of thing. Update a portion of the screen. If you're not drawing to it any more, then...
Trask's solution doesn't work?
Yeah it's kinda like that, You create a render target which is only suppose to use one area of a window or texture and I also want to make it so when you define a render target that is out side of the viewable area of a window then it will add scroll bars. So you could use the engine not just for games but even applications. But I've found another problem that makes the rendering a quad not work as well because when I tell DirectX to render to a viewport it does not just render to the view port it also renders black to everything outside the viewport. So it clears all the other render targets which creates flickering.
Also Trask just linked me to the msdn "Programming Guide for Direct3D 10" and "Viewports and Clipping (Direct3D 9)" DirectX 10 is pretty much completely different from DirectX 9.
Re: Best way to clear only the viewport in DirectX 10?
Posted: Fri Nov 07, 2008 7:26 am
by Trask
I figured that they probably were different, but I was hoping they would be similar enough as not all iterations of the DirectX deprecate all the previous functions what not...
If you find the solution, please post it so that others that may come and have the same issue can benefit from this.