PDA

View Full Version : 2D clipping



nickn
08-17-2000, 08:29 AM
I need to clip some objects in a 2D view, and can't figure out how to do it. The situation is a rolling digit field, like an odometer, where the digits are clipped as they scroll either up or down. I can't use a rectangular mask above and below to obscure them because other graphics must appear there "behind" the digit display. Does anyone have any ideas?

I'm doing this on a Windows 2000 PC, using MS VC++ with glut. This will eventually run on a Pentium with Mesa and no OS.

[This message has been edited by nickn (edited 08-17-2000).]

john
08-17-2000, 05:14 PM
no o/s then. okay. good luck. Incidentially, if you're not going to use an o/s (whatever _that_ means), then why are you using opengl? because opengl is an abstraction over the graphics h/w and... hey... the o/s is also an abstraction over the h/w, which.. hmm, is quite a conundrum.

and the answer to your problem is the problem is under constrained.

What are you clipping? arbitary polygons? triangles? a bitmap, perhaps? what kind of handle do you have on the graphics you want to clip?

You can use the scissor test to mask out a rectangular region for only a sub-set of the graphics required for a frame, btw. So, you could draw your background stuff, THEN set the rectangle and draw the digits, and then reset the scissor mask.

cheers
John

08-17-2000, 07:36 PM
draw the plastic overlay after you draw the numbers (painters algorythm)

if I understand right?

nickn
08-18-2000, 07:21 AM
The objects I need to clip are text strings drawn using glutStrokeCharacter. The odometer example I used is pretty much exactly the situation I'm describing. Simply masking the space above and below the digits won't work because there is a dial needle that spins under the rolling digits but over the rest of the dial. Anything that masks the digits would also mask this needle towards its center.

john
08-20-2000, 04:45 AM
EXCEPT if you enable the masks ONLY when you draw the digits. Simple pseudocode:

glDisable(SCISSOR_TEST)
drawTheNeedle();

glScissorTest(blah)
glEnable(SCISSOR_TEST);
drawTheDigits()

glDisable(SCISSOR_TEST)
drawthetopthing()

see? disable it when you don't need it; enable it when you do. it's a matter of building up _layers_.

cheers
John