Sign in to follow this  

Homogeneous coordinates and viewport clipping

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

Hi, I use 2d vertexes with homogenoeous coordinates (xyzhrw) to draw 2d stuff and I was curious if I can use the viewport setting for fast 2d clipping instead of clipping the geometry myself (which may be tricky for triangles or random lines). I also use a vertex buffer (hardware processing if supported) to store the vertexes. View and projection matrices are not used. For example, I have a screen of 640x480 and I want to set a viewport half of it, in the middle (x=160,y=120,w=320,h=240). Then if I move a sprite arround the screan (from 0 to 640) I expect it to be visible only when crossing the middle area I set as viewport. I see that it works, but I just want to be sure it works on any hardware, and DirectX does always clip those homogeneous coordinates with the viewport rect. Because I read about some clipping render state support for transforming 3d vertexes and some special cases for vertex buffers but I didn't see anything mentioned about homogeneous 2d vertexes. So if anyone knows if this procedure of clipping 2d vertexes with the viewport is ok to use, or it just works on some video cards, please let me know. Thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Seems to me that just beacuse it is not rendered on the viewport doesnt meant that is not 'rendered', the engine will process all the pumped vertices, however to cull geometry/vertices might require aditional processing, it all depends on the amount data processed

Share this post


Link to post
Share on other sites
there's no problem if vertexes are processed,
because I don't send too much data out of this clipping rect.

I just want to make sure the visile result is indeed clipped
and no pixels are painted out of the viewport on any hardware.
So the question remains.

Share this post


Link to post
Share on other sites
You're probably getting the benefit of Guard Band Clipping. Most cards support this, but there's are caps you can check to verify.

You can also get similar results by enabling scissor testing and setting the scissor rect to that of your viewport. There is also a caps bit for this (D3DPRASTERCAPS_SCISSORTEST) to determine if it is supported on a particular card.

Share this post


Link to post
Share on other sites

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