- XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- int i, state, state0, new_state, len, offs;
- int tbit;
- char *dptr;
- int n_segments = 0;
- char dashes[20];
- int line_width, line_style;
-
- /*** Line Stipple ***/
- if (ctx->Line.StippleFlag) {
- const int pattern = ctx->Line.StipplePattern;
-
- dptr = dashes;
- state0 = state = ((pattern & 1) != 0);
-
- /* Decompose the pattern */
- for (i=1,tbit=2,len=1;i<16;++i,tbit=(tbit<<1))
- {
- new_state = ((tbit & pattern) != 0);
- if (state != new_state)
- {
- *dptr++ = ctx->Line.StippleFactor * len;
- len = 1;
- state = new_state;
- }
- else
- ++len;
- }
- *dptr = ctx->Line.StippleFactor * len;
- n_segments = 1 + (dptr - dashes);
-
- /* ensure an even no. of segments, or X may toggle on/off for consecutive patterns */
- /* if (n_segments & 1) dashes [n_segments++] = 0; value of 0 not allowed in dash list */
-
- /* Handle case where line style starts OFF */
- if (state0 == 0)
- offs = dashes[0];
- else
- offs = 0;
-
-#if 0
-fprintf (stderr, "input pattern: 0x%04x, offset %d, %d segments:", pattern, offs, n_segments);
-for (i = 0; i < n_segments; i++)
-fprintf (stderr, " %d", dashes[i]);
-fprintf (stderr, "\n");
-#endif
-
- XMesaSetDashes( xmesa->display, xmesa->xm_buffer->gc1,
- offs, dashes, n_segments );
- XMesaSetDashes( xmesa->display, xmesa->xm_buffer->gc2,
- offs, dashes, n_segments );
-
- line_style = LineOnOffDash;
- }
- else {
- line_style = LineSolid;
- }
-
- /*** Line Width ***/
- line_width = (int) (ctx->Line.Width+0.5F);
- if (line_width < 2) {
- /* Use fast lines when possible */
- line_width = 0;
- }
-
- /*** Set GC attributes ***/
- XMesaSetLineAttributes( xmesa->display, xmesa->xm_buffer->gc1,
- line_width, line_style, CapButt, JoinBevel);
- XMesaSetLineAttributes( xmesa->display, xmesa->xm_buffer->gc2,
- line_width, line_style, CapButt, JoinBevel);
- XMesaSetFillStyle( xmesa->display, xmesa->xm_buffer->gc1, FillSolid );
- XMesaSetFillStyle( xmesa->display, xmesa->xm_buffer->gc2, FillSolid );
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ GET_XRB(xrb);
+ unsigned long pixel = xmesa_color_to_pixel(ctx,
+ vert1->color[0], vert1->color[1],
+ vert1->color[2], vert1->color[3],
+ xmesa->pixelformat);
+ int x0 = (int) vert0->win[0];
+ int y0 = YFLIP(xrb, (GLint) vert0->win[1]);
+ int x1 = (int) vert1->win[0];
+ int y1 = YFLIP(xrb, (GLint) vert1->win[1]);
+ XMesaSetForeground(dpy, gc, pixel);
+ XMesaSetFunction(dpy, gc, GXxor);
+ XSetLineAttributes(dpy, gc, (int) ctx->Line.Width,
+ LineSolid, CapButt, JoinMiter);
+ XDrawLine(dpy, xrb->pixmap, gc, x0, y0, x1, y1);
+ XMesaSetFunction(dpy, gc, GXcopy); /* this gc is used elsewhere */