/* XXX don't use this, it doesn't dither correctly */ static void draw_points_ANY_pixmap( struct gl_context *ctx, const SWvertex *vert ) { XMesaContext xmesa = XMESA_CONTEXT(ctx); XMesaDisplay *dpy = xmesa->xm_visual->display; XMesaDrawable buffer = xmesa->xm_buffer->buffer; XMesaGC gc = xmesa->xm_buffer->gc; if (xmesa->xm_visual->mesa_visual.RGBAflag) { register int x, y; const GLubyte *color = vert->color; unsigned long pixel = xmesa_color_to_pixel( xmesa, color[0], color[1], color[2], color[3], xmesa->pixelformat); XMesaSetForeground( dpy, gc, pixel ); x = (GLint) vert->win[0]; y = YFLIP( xrb, (GLint) vert->win[1] ); XMesaDrawPoint( dpy, buffer, gc, x, y); } else { /* Color index mode */ register int x, y; XMesaSetForeground( dpy, gc, vert->index ); x = (GLint) vert->win[0]; y = YFLIP( xrb, (GLint) vert->win[1] ); XMesaDrawPoint( dpy, buffer, gc, x, y); } }
static void clear_index( GLcontext *ctx, GLuint index ) { if (ctx->DrawBuffer->Name == 0) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); xmesa->clearpixel = (unsigned long) index; XMesaSetForeground( xmesa->display, xmbuf->cleargc, (unsigned long) index ); } }
/* * Bind buffer b to context c and make c the current rendering context. */ PUBLIC GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, XMesaBuffer readBuffer ) { if (c) { if (!drawBuffer || !readBuffer) return GL_FALSE; /* must specify buffers! */ if (&(c->mesa) == _mesa_get_current_context() && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer && c->mesa.ReadBuffer == &readBuffer->mesa_buffer && XMESA_BUFFER(c->mesa.DrawBuffer)->wasCurrent) { /* same context and buffer, do nothing */ return GL_TRUE; } c->xm_buffer = drawBuffer; /* Call this periodically to detect when the user has begun using * GL rendering from multiple threads. */ _glapi_check_multithread(); xmesa_check_and_update_buffer_size(c, drawBuffer); if (readBuffer != drawBuffer) xmesa_check_and_update_buffer_size(c, readBuffer); _mesa_make_current(&(c->mesa), &drawBuffer->mesa_buffer, &readBuffer->mesa_buffer); /* * Must recompute and set these pixel values because colormap * can be different for different windows. */ c->clearpixel = xmesa_color_to_pixel( &c->mesa, c->clearcolor[0], c->clearcolor[1], c->clearcolor[2], c->clearcolor[3], c->xm_visual->undithered_pf); XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel); /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */ drawBuffer->wasCurrent = GL_TRUE; } else { /* Detach */ _mesa_make_current( NULL, NULL, NULL ); } return GL_TRUE; }
/** * Draw fast, XOR line with XDrawLine in front color buffer. * WARNING: this isn't fully OpenGL conformant because different pixels * will be hit versus using the other line functions. * Don't use the code in X server GLcore module since we need a wrapper * for the XSetLineAttributes() function call. */ static void xor_line(struct gl_context *ctx, const SWvertex *vert0, const SWvertex *vert1) { 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 = (GLint) vert0->attrib[VARYING_SLOT_POS][0]; int y0 = YFLIP(xrb, (GLint) vert0->attrib[VARYING_SLOT_POS][1]); int x1 = (GLint) vert1->attrib[VARYING_SLOT_POS][0]; int y1 = YFLIP(xrb, (GLint) vert1->attrib[VARYING_SLOT_POS][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 */ }
static void clear_color( GLcontext *ctx, const GLfloat color[4] ) { if (ctx->DrawBuffer->Name == 0) { const XMesaContext xmesa = XMESA_CONTEXT(ctx); XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]); CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]); xmesa->clearpixel = xmesa_color_to_pixel( ctx, xmesa->clearcolor[0], xmesa->clearcolor[1], xmesa->clearcolor[2], xmesa->clearcolor[3], xmesa->xm_visual->undithered_pf ); _glthread_LOCK_MUTEX(_xmesa_lock); XMesaSetForeground( xmesa->display, xmbuf->cleargc, xmesa->clearpixel ); _glthread_UNLOCK_MUTEX(_xmesa_lock); } }