Sign in to follow this  

Could the screen or clipping region built by DirectX be transparent?

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

The viewport clipping region and any region set with SetScissorRect() are rectangular only and either clipped (outside) or rendered (inside).

However you can still achieve the same effect of arbitrarily shaped 'clipping' using the stencil buffer. Clear the stencil buffer; turn off colour writes; draw your clipper geometry into the stencil buffer with stencil writes on; render the geometry to be clipped with stencil test on. ISTR there's some sample code in the SDK documentation.

Alternative methods are using alpha test or the clip() [or texkill] instruction in your pixel shader.

Share this post


Link to post
Share on other sites
Viewport clipping is a standard feature so you shouldn't have any problems with that one. Not got my documentation to hand, but I'm pretty sure scissor rects are either standard or fairly well supported. Using alpha-test/clip/texkill may well be a little more painful though.

Also, I get the impression you might be after something else - "abritrary shape window". The methods Simon's posted will allow arbitrary shaped or clipped regions within your main D3D target area but they won't allow your parent/target region to be an arbitrary shape.

I forget the details, but there are some GDI/Win32 functions that allow you do mask off parts of a window and thus generate non-rectangular regions, but i'd be surprised if that worked with Direct3D. D3D and GDI don't tend to mix perfectly - for the most part you'll be able to use one or the other but probably not both.

On a related note, ISTR there was a thread in here a few months back where someone couldn't make the background window transparent when D3D was attached to it. D3D just hooked into the window and overrode whatever GDI was trying to do...

hth
Jack

Share this post


Link to post
Share on other sites

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