[comp.windows.x] XDrawPoints question

caron@polya.Stanford.EDU (Ilan G. Caron) (07/13/89)

I'm new to this bboard and to X programming (so if this question's
been asked 9000 times already...)

I'm using X11 (I don't know what release - how do I work that out?) on
a Decstation 3100 (Ultrix Worksystem V2.0 + Multicast 1.1 (Rev. 7) -
whatever that means).

It turns that in the following call, if npoints > ~15000 then I get
an X runtime error (bad request length or something akin).

  XDrawPoints(display, drawable, gc, points, npoints, mode);

(the O'Reilly book declares npoints as an int).

Is there any rhyme or reason to this (or is it a known bug)?

thanks,

--ilan
caron@polya.stanford.edu

rws@EXPO.LCS.MIT.EDU (07/13/89)

    Is there any rhyme or reason to this (or is it a known bug)?

Yes and yes.  It's happening because there is a maximum length for any
single X request, and you've exceeded it.  In this case, Xlib can reasonably
break it up into multiple requests, but isn't doing so.  This will be fixed
in the MIT R4 Xlib.

adrian@ora.UUCP (Adrian Nye ) (07/15/89)

In article <10561@polya.Stanford.EDU>, caron@polya.Stanford.EDU (Ilan G. Caron) writes:
> 
> It turns that in the following call, if npoints > ~15000 then I get
> an X runtime error (bad request length or something akin).
> 
>   XDrawPoints(display, drawable, gc, points, npoints, mode);

This is a known problem, that can also happen with
all the poly requests;
XDrawLines, XDrawSegments, XDrawArcs etc.  Each server has a
maximum request length, and your request of 15,000 points is
too big for your server.  The immediate solution is to chop
your request into smaller pieces.  To determine how small, you
find out your server's maximum request size using the
R3 function Xlib function XMaxRequestSize (or access the
Display structure member directly in R2).  Subtract 3, and
this is the maximum number of points you 
can draw in a single XDrawPoints request.  
You can draw half this many lines, 
segments, or rectangles, and 1/3 this many arcs.
These calculations are based on the sizes of the protocol
requests.

The reason you get the protocol error BadLength is that
most current implementations of Xlib (like MIT R3) don't
check to make sure that these requests are small enough.
They just pass through your request to the server, and the
server detects the error.  There has been some talk in the X
Consortium of changing Xlib to detect this problem and notify
the programmer, or possibly to have Xlib split up the request itself
so that applications can draw 15,000 points in a single call
without problems.  Which of these approaches (if in fact
either) will be adopted for R4 has not been decided as far as I know.
-- 
Adrian Nye (617) 527-4210
O'Reilly & Associates, Inc., Publishers of Nutshell Handbooks
981 Chestnut Street, Newton, MA 02164
UUCP:	uunet!ora!adrian   ARPA: adrian@ora.uu.net