[Bf-blender-cvs] [60d2ff134ec] greasepencil-object: Cleanup: Use GPU_* calls instead of gl* in annotate_draw.c
Joshua Leung
noreply at git.blender.org
Mon Jul 9 14:21:20 CEST 2018
Commit: 60d2ff134ecfb374e4760e0c923b84284f5d1165
Author: Joshua Leung
Date: Mon Jul 9 23:28:02 2018 +1200
Branches: greasepencil-object
https://developer.blender.org/rB60d2ff134ecfb374e4760e0c923b84284f5d1165
Cleanup: Use GPU_* calls instead of gl* in annotate_draw.c
===================================================================
M source/blender/editors/gpencil/annotate_draw.c
===================================================================
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index 4248ceccd61..c128ae364f7 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -64,6 +64,7 @@
#include "GPU_immediate.h"
#include "GPU_draw.h"
+#include "GPU_state.h"
#include "ED_gpencil.h"
#include "ED_screen.h"
@@ -145,7 +146,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
if (totpoints == 1) {
/* if drawing a single point, draw it larger */
- glPointSize((float)(thickness + 2) * points->pressure);
+ GPU_point_size((float)(thickness + 2) * points->pressure);
immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
immBegin(GWN_PRIM_POINTS, 1);
immAttrib4ub(color, F2UB(ink[0]), F2UB(ink[1]), F2UB(ink[2]), F2UB(ink[3]));
@@ -155,7 +156,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
float oldpressure = points[0].pressure;
/* draw stroke curve */
- glLineWidth(max_ff(oldpressure * thickness, 1.0));
+ GPU_line_width(max_ff(oldpressure * thickness, 1.0));
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints);
@@ -175,7 +176,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
immEnd();
draw_points = 0;
- glLineWidth(max_ff(pt->pressure * thickness, 1.0f));
+ GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
@@ -293,7 +294,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
/* TODO: implement this with a geometry shader to draw one continuous tapered stroke */
/* draw stroke curve */
- glLineWidth(max_ff(curpressure * thickness, 1.0f));
+ GPU_line_width(max_ff(curpressure * thickness, 1.0f));
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add);
const bGPDspoint *pt = points;
for (int i = 0; i < totpoints; i++, pt++) {
@@ -313,7 +314,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
draw_points = 0;
curpressure = pt->pressure;
- glLineWidth(max_ff(curpressure * thickness, 1.0f));
+ GPU_line_width(max_ff(curpressure * thickness, 1.0f));
immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
/* need to roll-back one point to ensure that there are no gaps in the stroke */
@@ -580,7 +581,7 @@ static void gp_draw_strokes(
if (no_xray) {
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
glDepthMask(0);
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
/* first arg is normally rv3d->dist, but this isn't
* available here and seems to work quite well without */
@@ -598,7 +599,7 @@ static void gp_draw_strokes(
if (no_xray) {
glDepthMask(mask_orig);
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
bglPolygonOffset(0.0, 0.0);
}
@@ -636,7 +637,7 @@ static void gp_draw_strokes_edit(
if (no_xray) {
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
glDepthMask(0);
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
/* first arg is normally rv3d->dist, but this isn't
* available here and seems to work quite well without */
@@ -741,7 +742,7 @@ static void gp_draw_strokes_edit(
if (dflag & GP_DRAWDATA_ONLY3D) {
if (no_xray) {
glDepthMask(mask_orig);
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
bglPolygonOffset(0.0, 0.0);
#if 0
@@ -773,7 +774,7 @@ static void gp_draw_data_layers(
continue;
/* set basic stroke thickness */
- glLineWidth(lthick);
+ GPU_line_width(lthick);
/* Add layer drawing settings to the set of "draw flags"
* NOTE: If the setting doesn't apply, it *must* be cleared,
@@ -861,15 +862,15 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
/* grease pencil icon... */
// XXX: is this too intrusive?
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
+ GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ GPU_blend(true);
xco -= U.widget_unit;
yco -= (int)printable_size[1] / 2;
UI_icon_draw(xco, yco, ICON_GREASEPENCIL);
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
}
@@ -879,23 +880,18 @@ static void gp_draw_data(
int cfra, int dflag, float alpha)
{
/* turn on smooth lines (i.e. anti-aliasing) */
- glEnable(GL_LINE_SMOOTH);
-
- /* XXX: turn on some way of ensuring that the polygon edges get smoothed
- * GL_POLYGON_SMOOTH is nasty and shouldn't be used, as it ends up
- * creating internal white rays due to the ways it accumulates stuff
- */
+ GPU_line_smooth(true);
/* turn on alpha-blending */
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
+ GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ GPU_blend(true);
/* draw! */
gp_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag, alpha);
/* turn off alpha blending, then smooth lines */
- glDisable(GL_BLEND); // alpha blending
- glDisable(GL_LINE_SMOOTH); // smooth lines
+ GPU_blend(false); // alpha blending
+ GPU_line_smooth(false); // smooth lines
}
/* if we have strokes for scenes (3d view)/clips (movie clip editor)
More information about the Bf-blender-cvs
mailing list