Example #1
0
/* draw a set of strokes */
static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag,  
							 short debug, short lthick, float color[4])
{
	bGPDstroke *gps;
	
	/* set color first (may need to reset it again later too) */
	glColor4f(color[0], color[1], color[2], color[3]);
	
	for (gps= gpf->strokes.first; gps; gps= gps->next) {
		/* check if stroke can be drawn - checks here generally fall into pairs */
		if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE))
			continue;
		if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE))
			continue;
		if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE))
			continue;
		if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE))
			continue;
		if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE))
			continue;
		if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE))
			continue;
		if ((gps->points == 0) || (gps->totpoints < 1))
			continue;
		
		/* check which stroke-drawer to use */
		if (gps->totpoints == 1)
			gp_draw_stroke_point(gps->points, lthick, gps->flag, offsx, offsy, winx, winy);
		else if (dflag & GP_DRAWDATA_ONLY3D)
			gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, winx, winy);
		else if (gps->totpoints > 1)	
			gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
	}
}
Example #2
0
/* draw a set of strokes */
static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag,
                             short debug, short lthick, float color[4])
{
    bGPDstroke *gps;

    /* set color first (may need to reset it again later too) */
    glColor4fv(color);

    for (gps= gpf->strokes.first; gps; gps= gps->next) {
        /* check if stroke can be drawn - checks here generally fall into pairs */
        if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE))
            continue;
        if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE))
            continue;
        if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE))
            continue;
        if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE))
            continue;
        if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE))
            continue;
        if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE))
            continue;
        if ((gps->points == NULL) || (gps->totpoints < 1))
            continue;

        /* check which stroke-drawer to use */
        if (gps->totpoints == 1)
            gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
        else if (dflag & GP_DRAWDATA_ONLY3D) {
            const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY);
            int mask_orig = 0;

            if (no_xray) {
                glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
                glDepthMask(0);
                glEnable(GL_DEPTH_TEST);

                /* first arg is normally rv3d->dist, but this isn't available here and seems to work quite well without */
                bglPolygonOffset(1.0f, 1.0f);
#if 0
                glEnable(GL_POLYGON_OFFSET_LINE);
                glPolygonOffset(-1.0f, -1.0f);
#endif
            }

            gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug);

            if (no_xray) {
                glDepthMask(mask_orig);
                glDisable(GL_DEPTH_TEST);

                bglPolygonOffset(0.0, 0.0);
#if 0
                glDisable(GL_POLYGON_OFFSET_LINE);
                glPolygonOffset(0, 0);
#endif
            }
        }
        else if (gps->totpoints > 1)
            gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
    }
}