pds@quintus.UUCP (Peter Schachte) (02/18/88)
A question for all you Gurus (sorry if this is an old, stale question): what is the blessed way to clip stuff to the inside of a window? I don't want to waste the space of a SMART_REFRESH or GIMME_ZERO_ZERO window, I'm using SIMPLE_REFRESH. Right now I'm just displaying text, but later I may want to do graphics in my window. I don't want to have to clip everything I put in the window myself, I want the system (hardware?) to do it for me. What I've been doing is changing the window's clipping rectangle before I draw, and resetting after I'm done. The problem with this is that when I have a scroll bar in the right margin of my window, and I mouse in it while my code is redrawing the contents of the window, the elevator box in the scroll bar is not changed. I suppose I could forbid()/permit() around my drawing, but it may take a while to fill the window, and this doesn't seem very sporting. Or I could try to redraw the window in small installments, and forbid()/permit() around them. But what I'd really like is to have my own clipping rectangle for the inside of the window, like a GZZ window, without having the overhead of another bitmap. Any suggestions? -- -Peter Schachte pds@quintus.uucp ...!sun!quintus!pds
cmcmanis%pepper@Sun.COM (Chuck McManis) (02/18/88)
In article <658@sandino.quintus.UUCP> pds@quintus.UUCP (Peter Schachte) writes: >A question for all you Gurus (sorry if this is an old, stale question): >what is the blessed way to clip stuff to the inside of a window? I >don't want to waste the space of a SMART_REFRESH or GIMME_ZERO_ZERO >window, I'm using SIMPLE_REFRESH. Have you tried creating your own rastport structure and then installing a UserClip region into it. (point at the same bit map the window uses). This aliased RastPort should work like a GZZ window but be space efficient since there is only one bitmap hanging around. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you.
jesup@pawl21.pawl.rpi.edu (Randell E. Jesup) (02/18/88)
In article <658@sandino.quintus.UUCP> pds@quintus.UUCP (Peter Schachte) writes: >A question for all you Gurus (sorry if this is an old, stale question): >what is the blessed way to clip stuff to the inside of a window? I >don't want to waste the space of a SMART_REFRESH or GIMME_ZERO_ZERO >window, I'm using SIMPLE_REFRESH. Ah! One of the lesser-known new functions in 1.2 Intuition is the call InstallClipRegion(). There is (I think) an example on a fish disk done by either RJ or Jim Mackraz of this, and it is documented in the 1.2 AutoDocs (mentioned on page 68 of the Enhancer booklet). This does EXACTLY what you are looking for, without the GZZ overhead (you can even get quite fancy with it). // Randell Jesup Lunge Software Development // Dedicated Amiga Programmer 13 Frear Ave, Troy, NY 12180 \\// beowulf!lunge!jesup@steinmetz.UUCP (518) 272-2942 \/ (uunet!steinmetz!beowulf!lunge!jesup) BIX: rjesup
cks@radio.toronto.edu (Chris Siebenmann) (02/24/88)
In article <386@imagine.PAWL.RPI.EDU> beowulf!lunge!jesup@steinmetz.UUCP writes: > Ah! One of the lesser-known new functions in 1.2 Intuition is the >call InstallClipRegion(). InstallClipRegion() is great, and very useful. Unfortunately, it seems to have a fair amount of overhead; we got significant speedups in the refresh code of an application by getting rid of redundant InstallClipRegion()s. Does anyone know what it does internally that makes it slow? -- "I shall clasp my hands together and bow to the corners of the world." Number Ten Ox, "Bridge of Birds" Chris Siebenmann {allegra,mnetor,decvax,pyramid}!utgpu!radio!cks cks@radio.toronto.edu or ...!utgpu!{chp!hak!ziebmef,ontmoh}!cks
1LENDL%EDVZ.UNI-SALZBURG.ADA.AT@cunyvm.cuny.edu (02/15/90)
Hi all ! I'm searching for a *FAST* clipping algorithm, because I'm writing an animated Vektorgraphic in assembler, and I want to clip all lines which go out of the screen : For example : Such a line Should be Clipped to : \ _______\______ ______________ I \ I I \ I I \ I I \ I I \ I I \ I I \ I I \ I ------------\- -------------- \ \ Any suggestions ? Please reply directly to me, I'm not on this list. /*****************************************************************************/ /* Otmar Lendl at the E-Mail : 1LENDL@EDVZ.UNI-SALZBURG.ADA.AT */ /* University of Salzburg PSI : PSI%023225629007::1LENDL */ /* AUSTRIA Amiga, 68000 Ass. , C, VAX, M2, ADA, Fractals */ /* Maybe you have to route : 1lendl%edvz.uni-salzburg.ada.at@CUNYVM.CUNY.EDU */ /*****************************************************************************/
mleone@f.gp.cs.cmu.edu (Mark Leone) (02/16/90)
In article <11230@baldrick.udel.EDU> 1LENDL%EDVZ.UNI-SALZBURG.ADA.AT@cunyvm.cuny.edu writes: >I'm searching for a *FAST* clipping algorithm, because I'm writing >an animated Vektorgraphic in assembler, and I want to clip all lines >which go out of the screen : > >For example : > > Such a line Should be Clipped to : > \ > _______\______ ______________ > I \ I I \ I > I \ I I \ I > I \ I I \ I > I \ I I \ I > ------------\- -------------- > \ Here's an easy and fast clipping algorithm from Newman & Sproull, _Principles of Interactive Computer Graphics_. The algorithm was invented by Cohen & Sutherland. The basic idea is to use a bit-encoding to categorize the positions of points relative to the screen (or window): First bit: point is to the left of the left-hand side of the screen. Second bit: point is to the right of the right-hand side of the screen. Third bit: point is below the bottom edge of the screen. Fourth bit: point is above the top edge of the screen. Obviously, all visible points have the encoding 0000. The other possible encodings are as follows: | | 1001 | 1000 | 1010 | | -------|--------|-------- |(screen)| 0001 | 0000 | 0010 | | -------|--------|-------- | | 0101 | 0100 | 0110 | | It's easy write a function that, given a point, returns the appropriate four-bit encoding. Now, for the algorithm: Given a line segment, compute the encodings of the endpoints. Check whether both endpoints are visible (codes are both 0000). If so, display the line. If not, compute the bitwise "and" of the two encodings. If this value is NON-ZERO, the whole line is INVISIBLE. Otherwise, part of the line may be visible. Find the coordinates of the point where the line intersects the "tic-tac-toe" grid above. (It may intersect the grid several times; just choose any point of intersection). Discard the part of the line that is invisible, and recursively apply the algorithm to the remainder of the line. (The algorithm gets slightly faster if you intelligently choose which part of the line to ignore). Pretty simple! -- Mark R. Leone <mleone@cs.cmu.edu> "Don't just do something, Computer Science, Carnegie Mellon University sit there!" Pittsburgh, PA 15213