2D clipping

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).]

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.


draw the plastic overlay after you draw the numbers (painters algorythm)

if I understand right?

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.

EXCEPT if you enable the masks ONLY when you draw the digits. Simple pseudocode:




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