[comp.sys.sgi] disappearing text?

dan@gistdev.gist.com (Dan Schreiber) (05/07/91)

	I'm having a very strange problem with printing out text strings
to a graphics window.  The problem is that part of a text string is 
missing, or sometimes the whole string, after drawing the window.  It happens
rarely enough to be non-reproducible, but often enough to be concerned about
it.
	I am using the font manager most of the time, where I get a font 
handle, scale the font, then use fmsetfont() and fmprstr() to print the
text.  I also have my own window manager that reads queue events and
routs them to the correct window.  It is a strange problem in that most
of text will be output, but sometimes one line will be missing, or
sometimes even parts of a line will be missing!  (also, I'm using
doublebuffer mode, and I've seen the problem on all the windows in
my application, not just one isolated window).
	My temporary fix is to queue MIDDLEMOUSE and whenever I see text
missing, I force a redraw of the window by having the window manager
redraw a window when MIDDLEMOUSE is clicked over it.  This will always
draw the missing portion of the text (but sometimes a different portion
will be missing!)  
	There is also another graphics program running at the same time, and
I am wondering if the problem could be processes colliding in the graphics system?
Perhaps there is a queue event that I am missing somewhere?  I do handle
REDRAW events, and the default for any unrecognized queue event is to
redraw the window.  What could possibly cause this problem?
	
	I realize that my description of the problem is very sketchy, but
it happens so randomly that I can't be any more specific.  I'm posting this
in the hope that someone has seen a problem like this before and can at
least point me in some direction, because I'm baffled!

	I'm using a PI, 3.3.1

Thanks in advance,

-----------------------------------------------------------------------------
Dan Schreiber			
dschreib@gistdev.gist.com		
Global Information Systems Technology, Inc.
1800 Woodfield Dr.				"Morality is 10% intention 
Savoy, IL 61874-9505				 and 90% lack of opportunity"
(217) 352-1165						- who knows ?
-----------------------------------------------------------------------------

loan@neon.Stanford.EDU (James P. Loan) (05/08/91)

In article <1171@gistdev.gist.com> dan@gistdev.gist.com (Dan Schreiber) writes:
>
>	I'm having a very strange problem with printing out text strings
>to a graphics window.  The problem is that part of a text string is 
>missing, or sometimes the whole string, after drawing the window.  It happens
>rarely enough to be non-reproducible, but often enough to be concerned about
>it.

(more problem description)

>	I realize that my description of the problem is very sketchy, but
>it happens so randomly that I can't be any more specific.  I'm posting this
>in the hope that someone has seen a problem like this before and can at
>least point me in some direction, because I'm baffled!
>
>	I'm using a PI, 3.3.1
>

Excuse the me-tooism, but I thought I should mention that I have been
having *exactly* the same problem, also on a PI (3.3.1). This should
confirm that it's not some pipe-dream that Dan Schreiber is having, and
that it's not a problem specific to his code. I do admit, however, that it
could be due to a "misuse" of some GL routine that he and I both use.
I did check the strings that I was displaying with fmprstr(), and they
do not get clobbered by some wild pointer before they are displayed. I
didn't think that was a real possibility anyway, though, because as Dan
says, the next redraw displays the string correctly (but may goober another
one). The only other symptom I can add is that the problem is more likely
to happen when I am running the graphics program within dbx, and when I
am alternating between drawing a 2D window with text (using fmprstr())
and a 3D window with lots of lighted, z-buffered polygons.

thanks in advance
pete loan

loan@neon.stanford.edu

andru@electron.lcs.mit.edu (Andrew Myers) (05/08/91)

In article <1991May7.193349.16623@neon.Stanford.EDU> loan@neon.Stanford.EDU (James P. Loan) writes:
>In article <1171@gistdev.gist.com> dan@gistdev.gist.com (Dan Schreiber) writes:
>>	I'm having a very strange problem with printing out text strings
>>to a graphics window.  The problem is that part of a text string is 
>>missing, or sometimes the whole string, after drawing the window.  It happens
>>rarely enough to be non-reproducible, but often enough to be concerned about
>>it.
>
>Excuse the me-tooism, but I thought I should mention that I have been
>having *exactly* the same problem, also on a PI (3.3.1). This should

One thing to remember about imaging character strings is that character
strings are subject to "gross clipping". If the transformed location of
the start of the string is outside the current viewport, the entire string
will be clipped! This happens because the character string has point size
as far as the transformation engines are concerned.

To avoid this problem, you can use "fine clipping" via the scrmask() call.
That is, set your viewport to be larger than the current window, and
use scrmask() to do the actual clipping. Here is an example:

    getsize(&sx,&sy);
    viewport(-MARGIN, sx - 1 + MARGIN, -MARGIN, sy - 1 + MARGIN);
    scrmask(0, sx - 1, 0, sy - 1);
    ortho2(-0.5 - MARGIN, sx - 0.5 + MARGIN, -0.5 - MARGIN, sy - 0.5 + MARGIN);


                      __ screenmask, window borders
                     /
       -------------/-------
       |           /       |
 ---   |   -------------   |  __ viewport
  |    |   |           |   | /          
  |    |   |           |   |/          
  sy   |   |           |   |
  |    |   |           |   |
  |    |   |           |<->| MARGIN
 ---   |   -------------   |      
       |      MARGIN       |
       ---------------------
       
	   |---- sx ---|

Where you can adjust MARGIN to allow character strings to start as far
outside the current viewport as you like. A value of 64 is usually
satisfactory.

Note that viewport() always resets the current screenmask, so you have
to call scrmask() afterwards. Note also that viewport() and scrmask()
take pixel indices, whereas ortho2() supplies world coordinates for the
edges of the viewport(). Hence the MARGINs in the ortho2 call. This
allows points to be transformed into the entire viewport area, but only
made visible if they fall within the screenmask.

Andrew