Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU Newsgroups: comp.windows.x Subject: Re: XDrawLine doesn't draw lines! Looking for help. Message-ID: <9101250109.AA05849@lightning.McRCIM.McGill.EDU> Date: 25 Jan 91 01:09:53 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 31 > I seem to be running into a problem when I use XDrawLine to draw a > set of lines. My program [...] reads from a text file 4 values at a > time and draws a line using the read values as coordinates for the > two endpoints. > The program does not give any errors during compilation. But I seem > to get different results each time I execute the compiled code. > Sometimes I get all lines drawn properly, sometimes none, sometimes a > few. > theNewWindow = XCreateWindow( [...] ); > XMapWindow(theDisplay, theNewWindow); > XFlush(theDisplay); > for (i=0; i<44; i++) { > fscanf(line_fin,"%d %d %d %d\n", &x1, &y1, &x2, &y2); > XDrawLine(theDisplay, theNewWindow, theGC, x1, y1, x2, y2); > } See the FAQ, question #74. Briefly: the window does not necessarily appear on the screen immediately when you XMapWindow(). The window manager typically redirects the request and does the map itself at a slightly later time. All drawing done before the map actually happens will be lost. You should create the window with ExposureMask in the event-mask, then draw whenever you get an Expose event. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu