Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2018-06-28 04:07:23 +0300
committerRay Molenkamp <github@lazydodo.com>2018-06-28 04:07:23 +0300
commit8e02106d0ddc7b31844d26037a824d56d3c65663 (patch)
treebfa1898220d74ac9610b8a1363a4087a44f7b41d /source/blender/editors/gpencil
parentfe258fd4451a7fb1ccdd85d1607b6dbd30442f28 (diff)
GLRefactor: partially remove gl calls from source/blender/editors.
This translates the gl calls to the new GPU_ wrappers from D3501. Given it's tedious and repetitive work, this patch does as much as it can with search + replace, the remainder of the gl calls will need to be manually dealt with on a case by case basis. This fixes 13 of the 28 failing editors when building without opengl. For the list of substitutions see D3502 Reviewers: brecht Differential Revision: https://developer.blender.org/D3502
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c41
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c9
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c13
3 files changed, 33 insertions, 30 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a30cb578046..a79a5052eb8 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.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"
@@ -215,7 +216,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);
gp_set_tpoint_varying_color(pt, ink, color);
@@ -225,7 +226,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);
@@ -245,7 +246,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 */
@@ -625,7 +626,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++) {
@@ -646,7 +647,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 */
@@ -941,7 +942,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 */
@@ -1005,7 +1006,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);
}
@@ -1090,7 +1091,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 */
@@ -1215,7 +1216,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
@@ -1329,7 +1330,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type)
}
/* turn on alpha-blending */
- glEnable(GL_BLEND);
+ GPU_blend(true);
for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
/* calculate parent position */
ED_gpencil_parent_location(tgpil->gpl, diff_mat);
@@ -1338,7 +1339,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type)
tgpil->gpl->thickness, 1.0f, color, true, true, diff_mat);
}
}
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
/* loop over gpencil data layers, drawing them */
@@ -1365,7 +1366,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,
@@ -1479,15 +1480,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);
}
}
@@ -1497,7 +1498,7 @@ static void gp_draw_data(
int offsx, int offsy, int winx, int winy, int cfra, int dflag)
{
/* turn on smooth lines (i.e. anti-aliasing) */
- glEnable(GL_LINE_SMOOTH);
+ GPU_line_smooth(true);
/* 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
@@ -1505,15 +1506,15 @@ static void gp_draw_data(
*/
/* 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(brush, alpha, gpd, offsx, offsy, winx, winy, cfra, dflag);
/* 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)
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 5eb3321b414..d877ea03c5d 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -78,6 +78,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
+#include "GPU_state.h"
#include "gpencil_intern.h"
@@ -988,8 +989,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
+ GPU_line_smooth(true);
+ GPU_blend(true);
/* Inner Ring: Light color for action of the brush */
/* TODO: toggle between add and remove? */
@@ -1002,8 +1003,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
immUnbindProgram();
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ GPU_blend(false);
+ GPU_line_smooth(false);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 800c899f9c2..0ae45a9fde8 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -73,6 +73,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
+#include "GPU_state.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -1878,9 +1879,9 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
const uint shdr_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ GPU_line_smooth(true);
+ GPU_blend(true);
+ GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
immUniformColor4ub(255, 100, 100, 20);
imm_draw_circle_fill_2d(shdr_pos, x, y, p->radius, 40);
@@ -1890,7 +1891,7 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
float viewport_size[4];
- glGetFloatv(GL_VIEWPORT, viewport_size);
+ GPU_viewport_size_getf(viewport_size);
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniformColor4f(1.0f, 0.39f, 0.39f, 0.78f);
@@ -1905,8 +1906,8 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
immUnbindProgram();
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
+ GPU_blend(false);
+ GPU_line_smooth(false);
}
}