Archived

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

OGL Scissor test equivalent in DX? Need to clip 3d sprites...

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

Is there a DX equivalent to scissor testing in OpenGL? (Nehe, Lesson 24) Basically I have my own font class that pulls fonts from a font texture, like it''s done in those nehe tutorials, but in DX. I need them to be clipped to a certain region sometimes but am not sure how to do it. The OGL Scirssor test seems to be perfect, but I doubt DX has an equivalent. If it does, anyone know what it is? If it doesnt, anyone know a way to accomplish what I need without it? ByteMe95::~ByteMe95() My S(h)ite

Share this post


Link to post
Share on other sites
There are three ways to do it (possibly more, but three that I can think of right now):
1) Setting the viewport - Nothing will be drawn outside the viewport.
2) Using the stencil buffer - Draw a rectangle (or any shape) to the stencil buffer, and use it to make sure things only get drawn in that area
3) Set up a set of clip planes to clip triangles that go outside the area (nb: look at the ClipMirror sample from the SDK for more info)

IMO setting the viewport should be easiest.

John B

Share this post


Link to post
Share on other sites
I should mention that this if for a "2d in 3d" game, using d3d8 with an ortho view, will the viewport be able to work with screen coordinates?
that would be PERFECT

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites
I should mention that this if for a "2d in 3d" game, using d3d8 with an ortho view, will the viewport be able to work with screen coordinates?
that would be PERFECT

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites
It should be able to. You may have to reset the projection matrix when you change viewports (I''m not sure, because I''ve never had to change viewports myself).

John B

Share this post


Link to post
Share on other sites
JohnB:
just realized that when I reset the viewport, just tested it to make the viewport 100,100,700,500 (at 800x600), and it just shrunk the image to be that size so everything.
In other words, everything that should get blitted still gets blitted, but to fit in the new viewport

ByteMe95::~ByteMe95()
My S(h)ite

Share this post


Link to post
Share on other sites