Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/drawgpencil.c
| Context not available. | |||||
| glColor4fv(gpl->color); | glColor4fv(gpl->color); | ||||
| } | } | ||||
| /* draw grease-pencil datablock */ | static void gp_draw_data_layers(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) | ||||
| static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) | |||||
| { | { | ||||
| bGPDlayer *gpl; | bGPDlayer *gpl; | ||||
| /* reset line drawing style (in case previous user didn't reset) */ | |||||
| setlinestyle(0); | |||||
| /* turn on smooth lines (i.e. anti-aliasing) */ | |||||
| glEnable(GL_LINE_SMOOTH); | |||||
| glEnable(GL_POLYGON_SMOOTH); | |||||
| glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); | |||||
| /* turn on alpha-blending */ | |||||
| glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | |||||
| glEnable(GL_BLEND); | |||||
| /* loop over layers, drawing them */ | |||||
| for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| bGPDframe *gpf; | bGPDframe *gpf; | ||||
| Context not available. | |||||
| short lthick = gpl->thickness; | short lthick = gpl->thickness; | ||||
| /* don't draw layer if hidden */ | /* don't draw layer if hidden */ | ||||
| if (gpl->flag & GP_LAYER_HIDE) | if (gpl->flag & GP_LAYER_HIDE) | ||||
| continue; | continue; | ||||
| /* get frame to draw */ | /* get frame to draw */ | ||||
| gpf = gpencil_layer_getframe(gpl, cfra, 0); | gpf = gpencil_layer_getframe(gpl, cfra, 0); | ||||
| if (gpf == NULL) | if (gpf == NULL) | ||||
| continue; | continue; | ||||
| /* set color, stroke thickness, and point size */ | /* set color, stroke thickness, and point size */ | ||||
| glLineWidth(lthick); | glLineWidth(lthick); | ||||
| glPointSize((float)(gpl->thickness + 2)); | glPointSize((float)(gpl->thickness + 2)); | ||||
| /* Add layer drawing settings to the set of "draw flags" | /* Add layer drawing settings to the set of "draw flags" | ||||
| * NOTE: If the setting doesn't apply, it *must* be cleared, | * NOTE: If the setting doesn't apply, it *must* be cleared, | ||||
| * as dflag's carry over from the previous layer | * as dflag's carry over from the previous layer | ||||
| */ | */ | ||||
| Context not available. | |||||
| /* draw the strokes already in active frame */ | /* draw the strokes already in active frame */ | ||||
| gp_draw_strokes(gpf, offsx, offsy, winx, winy, dflag, debug, lthick, gpl->color, gpl->fill); | gp_draw_strokes(gpf, offsx, offsy, winx, winy, dflag, debug, lthick, gpl->color, gpl->fill); | ||||
| /* Draw verts of selected strokes | /* Draw verts of selected strokes | ||||
| * - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering | * - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering | ||||
| * - locked layers can't be edited, so there's no point showing these verts | * - locked layers can't be edited, so there's no point showing these verts | ||||
| * as they will have no bearings on what gets edited | * as they will have no bearings on what gets edited | ||||
| Context not available. | |||||
| */ | */ | ||||
| /* XXX: perhaps we don't want to show these when users are drawing... */ | /* XXX: perhaps we don't want to show these when users are drawing... */ | ||||
| if ((G.f & G_RENDER_OGL) == 0 && | if ((G.f & G_RENDER_OGL) == 0 && | ||||
| (gpl->flag & GP_LAYER_LOCKED) == 0 && | (gpl->flag & GP_LAYER_LOCKED) == 0 && | ||||
| (gpd->flag & GP_DATA_STROKE_EDITMODE)) | (gpd->flag & GP_DATA_STROKE_EDITMODE)) | ||||
| { | { | ||||
| gp_draw_strokes_edit(gpf, offsx, offsy, winx, winy, dflag, | gp_draw_strokes_edit(gpf, offsx, offsy, winx, winy, dflag, | ||||
| (gpl->color[3] < 0.95f) ? gpl->color : NULL); | (gpl->color[3] < 0.95f) ? gpl->color : NULL); | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| /* draw grease-pencil datablock */ | |||||
| static void gp_draw_data(Scene *scene, bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) | |||||
| { | |||||
| /* reset line drawing style (in case previous user didn't reset) */ | |||||
| setlinestyle(0); | |||||
| /* turn on smooth lines (i.e. anti-aliasing) */ | |||||
| glEnable(GL_LINE_SMOOTH); | |||||
| glEnable(GL_POLYGON_SMOOTH); | |||||
| glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); | |||||
| /* turn on alpha-blending */ | |||||
| glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | |||||
| glEnable(GL_BLEND); | |||||
| /* loop over layers, drawing them */ | |||||
| gp_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag); | |||||
| /* we always want to draw gpencil data of the active scene! So if the | |||||
| * data we've just drawn is not the one from the scene (that means it | |||||
| * is from an object), draw it now */ | |||||
| if (scene && scene->gpd && scene->gpd != gpd) { | |||||
aligorith: This will be problematic.
Grease Pencil can be used from editors other than the 3D view… | |||||
SeverinAuthorUnsubmitted Not Done Inline ActionsAgree here. Wanted to test that before submitting, but got distracted :/ Lesson learned: don't submit diffs after 2AM :S Severin: Agree here. Wanted to test that before submitting, but got distracted :/ Lesson learned: don't… | |||||
| gp_draw_data_layers(scene->gpd, offsx, offsy, winx, winy, cfra, dflag); | |||||
| } | |||||
| /* turn off alpha blending, then smooth lines */ | /* turn off alpha blending, then smooth lines */ | ||||
| glDisable(GL_BLEND); // alpha blending | glDisable(GL_BLEND); // alpha blending | ||||
| Context not available. | |||||
| /* draw it! */ | /* draw it! */ | ||||
| gp_draw_data(gpd, offsx, offsy, sizex, sizey, CFRA, dflag); | gp_draw_data(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag); | ||||
| } | } | ||||
| /* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly | /* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly | ||||
| Context not available. | |||||
| /* draw it! */ | /* draw it! */ | ||||
| if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS); | if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS); | ||||
| gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag); | gp_draw_data(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag); | ||||
| } | } | ||||
| /* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly | /* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly | ||||
| Context not available. | |||||
| /* draw it! */ | /* draw it! */ | ||||
| if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); | if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); | ||||
| gp_draw_data(gpd, offsx, offsy, winx, winy, CFRA, dflag); | gp_draw_data(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag); | ||||
| } | } | ||||
| void ED_gpencil_draw_ex(bGPdata *gpd, int winx, int winy, const int cfra) | void ED_gpencil_draw_ex(Scene *scene, bGPdata *gpd, int winx, int winy, const int cfra) | ||||
| { | { | ||||
| int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D; | int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D; | ||||
| gp_draw_data(gpd, 0, 0, winx, winy, cfra, dflag); | gp_draw_data(scene, gpd, 0, 0, winx, winy, cfra, dflag); | ||||
| } | } | ||||
| /* ************************************************** */ | /* ************************************************** */ | ||||
| Context not available. | |||||
This will be problematic.
Grease Pencil can be used from editors other than the 3D view (namely, sequencer preview, image editor, nodes editor, and clip editor). The drawings made in the 3d view and attached to the scene are not suitable for use in any other editor. So, doing this is not really the best way of doing what is essentially a 3d view feature.