Example #1
0
/**
 * 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 */
}
Example #2
0
static swrast_tri_func get_triangle_func( GLcontext *ctx )
{
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    XMesaContext xmesa = XMESA_CONTEXT(ctx);
    int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
    GET_XRB(xrb);

#ifdef DEBUG
    triFuncName = NULL;
#endif

    if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
            & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
        return (swrast_tri_func) NULL;
    if (ctx->RenderMode != GL_RENDER)  return (swrast_tri_func) NULL;
    if (ctx->Polygon.SmoothFlag)       return (swrast_tri_func) NULL;
    if (ctx->Texture._EnabledUnits)    return (swrast_tri_func) NULL;
    if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_tri_func) NULL;
    if (ctx->Polygon.CullFlag &&
            ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
        return (swrast_tri_func) NULL;

    if (xrb->ximage) {
        if (   ctx->Light.ShadeModel==GL_SMOOTH
                && swrast->_RasterMask==DEPTH_BIT
                && ctx->Depth.Func==GL_LESS
                && ctx->Depth.Mask==GL_TRUE
                && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
                && ctx->Polygon.StippleFlag==GL_FALSE) {
            switch (xmesa->pixelformat) {
            case PF_Truecolor:
                USE(smooth_TRUECOLOR_z_triangle);
            case PF_8A8B8G8R:
                USE(smooth_8A8B8G8R_z_triangle);
            case PF_8A8R8G8B:
                USE(smooth_8A8R8G8B_z_triangle);
            case PF_8R8G8B:
                USE(smooth_8R8G8B_z_triangle);
            case PF_8R8G8B24:
                USE(smooth_8R8G8B24_z_triangle);
            case PF_Dither_True:
                USE(smooth_TRUEDITHER_z_triangle);
            case PF_5R6G5B:
                USE(smooth_5R6G5B_z_triangle);
            case PF_Dither_5R6G5B:
                USE(smooth_DITHER_5R6G5B_z_triangle);
            case PF_HPCR:
                USE(smooth_HPCR_z_triangle);
            case PF_Dither:
                if (depth == 8)
                    USE(smooth_DITHER8_z_triangle);
                else
                    USE(smooth_DITHER_z_triangle);
            case PF_Lookup:
                if (depth == 8)
                    USE(smooth_LOOKUP8_z_triangle);
                else
                    return (swrast_tri_func) NULL;
            default:
                return (swrast_tri_func) NULL;
            }
        }
        if (   ctx->Light.ShadeModel==GL_FLAT
                && swrast->_RasterMask==DEPTH_BIT
                && ctx->Depth.Func==GL_LESS
                && ctx->Depth.Mask==GL_TRUE
                && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS
                && ctx->Polygon.StippleFlag==GL_FALSE) {
            switch (xmesa->pixelformat) {
            case PF_Truecolor:
                USE(flat_TRUECOLOR_z_triangle);
            case PF_8A8B8G8R:
                USE(flat_8A8B8G8R_z_triangle);
            case PF_8A8R8G8B:
                USE(flat_8A8R8G8B_z_triangle);
            case PF_8R8G8B:
                USE(flat_8R8G8B_z_triangle);
            case PF_8R8G8B24:
                USE(flat_8R8G8B24_z_triangle);
            case PF_Dither_True:
                USE(flat_TRUEDITHER_z_triangle);
            case PF_5R6G5B:
                USE(flat_5R6G5B_z_triangle);
            case PF_Dither_5R6G5B:
                USE(flat_DITHER_5R6G5B_z_triangle);
            case PF_HPCR:
                USE(flat_HPCR_z_triangle);
            case PF_Dither:
                if (depth == 8)
                    USE(flat_DITHER8_z_triangle);
                else
                    USE(flat_DITHER_z_triangle);
            case PF_Lookup:
                if (depth == 8)
                    USE(flat_LOOKUP8_z_triangle);
                else
                    return (swrast_tri_func) NULL;
            default:
                return (swrast_tri_func) NULL;
            }
        }
        if (   swrast->_RasterMask==0   /* no depth test */
                && ctx->Light.ShadeModel==GL_SMOOTH
                && ctx->Polygon.StippleFlag==GL_FALSE) {
            switch (xmesa->pixelformat) {
            case PF_Truecolor:
                USE(smooth_TRUECOLOR_triangle);
            case PF_8A8B8G8R:
                USE(smooth_8A8B8G8R_triangle);
            case PF_8A8R8G8B:
                USE(smooth_8A8R8G8B_triangle);
            case PF_8R8G8B:
                USE(smooth_8R8G8B_triangle);
            case PF_8R8G8B24:
                USE(smooth_8R8G8B24_triangle);
            case PF_Dither_True:
                USE(smooth_TRUEDITHER_triangle);
            case PF_5R6G5B:
                USE(smooth_5R6G5B_triangle);
            case PF_Dither_5R6G5B:
                USE(smooth_DITHER_5R6G5B_triangle);
            case PF_HPCR:
                USE(smooth_HPCR_triangle);
            case PF_Dither:
                if (depth == 8)
                    USE(smooth_DITHER8_triangle);
                else
                    USE(smooth_DITHER_triangle);
            case PF_Lookup:
                if (depth == 8)
                    USE(smooth_LOOKUP8_triangle);
                else
                    return (swrast_tri_func) NULL;
            default:
                return (swrast_tri_func) NULL;
            }
        }

        if (   swrast->_RasterMask==0   /* no depth test */
                && ctx->Light.ShadeModel==GL_FLAT
                && ctx->Polygon.StippleFlag==GL_FALSE) {
            switch (xmesa->pixelformat) {
            case PF_Truecolor:
                USE(flat_TRUECOLOR_triangle);
            case PF_Dither_True:
                USE(flat_TRUEDITHER_triangle);
            case PF_8A8B8G8R:
                USE(flat_8A8B8G8R_triangle);
            case PF_8A8R8G8B:
                USE(flat_8A8R8G8B_triangle);
            case PF_8R8G8B:
                USE(flat_8R8G8B_triangle);
            case PF_8R8G8B24:
                USE(flat_8R8G8B24_triangle);
            case PF_5R6G5B:
                USE(flat_5R6G5B_triangle);
            case PF_Dither_5R6G5B:
                USE(flat_DITHER_5R6G5B_triangle);
            case PF_HPCR:
                USE(flat_HPCR_triangle);
            case PF_Dither:
                if (depth == 8)
                    USE(flat_DITHER8_triangle);
                else
                    USE(flat_DITHER_triangle);
            case PF_Lookup:
                if (depth == 8)
                    USE(flat_LOOKUP8_triangle);
                else
                    return (swrast_tri_func) NULL;
            default:
                return (swrast_tri_func) NULL;
            }
        }

        return (swrast_tri_func) NULL;
    }
    else {
        /* draw to pixmap */
        return (swrast_tri_func) NULL;
    }
}