[Bf-blender-cvs] [09ad684249] blender2.8: cleanup use of GPU matrix API
Mike Erwin
noreply at git.blender.org
Thu Mar 23 06:53:15 CET 2017
Commit: 09ad6842499f638ecd944714c0a82ba8deebb073
Author: Mike Erwin
Date: Thu Mar 23 01:45:46 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB09ad6842499f638ecd944714c0a82ba8deebb073
cleanup use of GPU matrix API
Take advantage of 2D functions, rotation about the X Y or Z axis, uniform scale factors.
We no longer need to call gpuMatrixBegin_legacy() before using the new API locally in functions.
related to T49450
===================================================================
M source/blender/blenfont/intern/blf.c
M source/blender/editors/armature/editarmature_sketch.c
M source/blender/editors/curve/editcurve_paint.c
M source/blender/editors/interface/interface_draw.c
M source/blender/editors/interface/interface_widgets.c
M source/blender/editors/mesh/editmesh_loopcut.c
M source/blender/editors/space_time/space_time.c
M source/blender/editors/space_view3d/drawarmature.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform_manipulator.c
===================================================================
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 17b353d48c..d4bd150241 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -552,7 +552,7 @@ static void blf_draw_gl__start(FontBLF *font)
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- gpuMatrixBegin3D_legacy();
+ gpuPushMatrix();
if (font->flags & BLF_MATRIX)
gpuMultMatrix3D(font->m);
@@ -563,7 +563,7 @@ static void blf_draw_gl__start(FontBLF *font)
gpuScale3fv(font->aspect);
if (font->flags & BLF_ROTATION) /* radians -> degrees */
- gpuRotateAxis(RAD2DEG(font->angle), 'Z');
+ gpuRotateAxis(RAD2DEG(font->angle), 'Z'); /* TODO: use gpuRotate2D here? */
#ifndef BLF_STANDALONE
VertexFormat *format = immVertexFormat();
@@ -584,7 +584,7 @@ static void blf_draw_gl__start(FontBLF *font)
static void blf_draw_gl__end(void)
{
- gpuMatrixEnd();
+ gpuPopMatrix();
#ifndef BLF_STANDALONE
immUnbindProgram();
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index feabac9d88..f42ce14743 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -1988,8 +1988,6 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
- gpuMatrixBegin3D_legacy();
-
if (with_names) {
int id;
for (id = 1, stk = sketch->strokes.first; stk; id++, stk = stk->next) {
@@ -2058,8 +2056,6 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
float gesture_rgb[3] = { 0, 0.5, 1 };
sk_drawStroke(sketch->gesture, -1, gesture_rgb, -1, -1);
}
-
- gpuMatrixEnd();
}
static int sk_finish_stroke(bContext *C, SK_Sketch *sketch)
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index c2c85e2017..cf7cfec513 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -475,7 +475,6 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
Batch_Uniform3fv(sphere, "color", color);
/* scale to edit-mode space */
- gpuMatrixBegin3D_legacy();
gpuPushMatrix();
gpuMultMatrix3D(obedit->obmat);
@@ -489,15 +488,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
const float radius = stroke_elem_radius(cdd, selem);
+ gpuPushMatrix();
gpuScaleUniform(radius);
Batch_draw(sphere);
- gpuScaleUniform(1.0f / radius);
+ gpuPopMatrix();
location_prev = selem->location_local;
}
gpuPopMatrix();
- gpuMatrixEnd();
}
if (stroke_len > 1) {
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 842cb40563..6a568567b3 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -930,7 +930,6 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
}
if (scopes->ok && scopes->waveform_1 != NULL) {
- gpuMatrixBegin3D_legacy();
glBlendFunc(GL_ONE, GL_ONE);
glPointSize(1.0);
@@ -939,8 +938,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
float col[3] = {alpha, alpha, alpha};
gpuPushMatrix();
- gpuTranslate3f(rect.xmin, yofs, 0.0f);
- gpuScale3f(w, h, 0.0f);
+ gpuTranslate2f(rect.xmin, yofs);
+ gpuScale2f(w, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col);
@@ -961,8 +960,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
/* RGB (3 channel) */
else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) {
gpuPushMatrix();
- gpuTranslate3f(rect.xmin, yofs, 0.0f);
- gpuScale3f(w, h, 0.0f);
+ gpuTranslate2f(rect.xmin, yofs);
+ gpuScale2f(w, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]);
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]);
@@ -981,15 +980,15 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
gpuPushMatrix();
- gpuTranslate3f(rect.xmin, yofs, 0.0f);
- gpuScale3f(w3, h, 0.0f);
+ gpuTranslate2f(rect.xmin, yofs);
+ gpuScale2f(w3, h);
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
- gpuTranslate3f(1.0f, 0.0f, 0.0f);
+ gpuTranslate2f(1.0f, 0.0f);
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
- gpuTranslate3f(1.0f, 0.0f, 0.0f);
+ gpuTranslate2f(1.0f, 0.0f);
waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
gpuPopMatrix();
@@ -1013,7 +1012,6 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
immEnd();
}
}
- gpuMatrixEnd();
}
immUnbindProgram();
@@ -1174,15 +1172,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
glBlendFunc(GL_ONE, GL_ONE);
glPointSize(1.0);
- gpuMatrixBegin3D_legacy();
gpuPushMatrix();
- gpuTranslate3f(centerx, centery, 0.0f);
- gpuScale3f(diam, diam, 0.0f);
+ gpuTranslate2f(centerx, centery);
+ gpuScaleUniform(diam);
waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col);
gpuPopMatrix();
- gpuMatrixEnd();
}
immUnbindProgram();
@@ -1454,7 +1450,6 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
ui_but_v3_get(but, light);
/* transform to button */
- gpuMatrixBegin3D_legacy();
gpuPushMatrix();
if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
@@ -1462,8 +1457,8 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
else
size = 0.5f * BLI_rcti_size_y(rect);
- gpuTranslate3f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f);
- gpuScale3f(size, size, size);
+ gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
+ gpuScaleUniform(size);
Batch *sphere = Batch_get_sphere(2);
Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING);
@@ -1488,7 +1483,6 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
/* matrix after circle */
gpuPopMatrix();
- gpuMatrixEnd();
immUnbindProgram();
}
@@ -1801,7 +1795,6 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
}
if (!ok && scopes->track_preview) {
- gpuMatrixBegin3D_legacy();
gpuPushMatrix();
/* draw content of pattern area */
@@ -1821,7 +1814,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL);
/* draw cross for pixel position */
- gpuTranslate3f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1], 0.0f);
+ gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
glScissor(ar->winrct.xmin + rect.xmin,
ar->winrct.ymin + rect.ymin,
BLI_rctf_size_x(&rect),
@@ -1860,7 +1853,6 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
}
gpuPopMatrix();
- gpuMatrixEnd();
ok = true;
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 475541f411..e0b16776ef 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -765,11 +765,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
- gpuMatrixBegin3D_legacy();
-
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
for (j = 0; j < WIDGET_AA_JITTER; j++) {
- gpuTranslate3f(jit[j][0], jit[j][1], 0.0f);
+ gpuTranslate2fv(jit[j]);
/* outline */
immUniformColor4ubv(tcol);
@@ -784,11 +782,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
}
}
- gpuTranslate3f(-jit[j][0], -jit[j][1], 0.0f);
+ gpuTranslate2f(-jit[j][0], -jit[j][1]);
}
immUnbindProgram();
-
- gpuMatrixEnd();
}
/* decoration */
@@ -802,11 +798,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ubv(tcol);
- gpuMatrixBegin3D_legacy();
-
/* for each AA step */
for (j = 0; j < WIDGET_AA_JITTER; j++) {
- gpuTranslate3f(jit[j][0], jit[j][1], 0.0f);
+ gpuTranslate2fv(jit[j]);
if (wtb->tria1.tot)
widget_trias_draw(&wtb->tria1, pos);
@@ -814,11 +808,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
if (wtb->tria2.tot)
widget_trias_draw(&wtb->tria2, pos);
- gpuTranslate3f(-jit[j][0], -jit[j][1], 0.0f);
+ gpuTranslate2f(-jit[j][0], -jit[j][1]);
}
- gpuMatrixEnd();
-
immUnbindProgram();
}
@@ -4151,9 +4143,8 @@ void ui_draw_pie_center(uiBlock *block)
float angle = atan2f(pie_dir[1], pie_dir[0]);
float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4;
- gpuMatrixBegin3D_legacy();
gpuPushMatrix();
- gpuTranslate3f(cx, cy, 0.0f);
+ gpuTranslate2f(cx, cy);
glEnable(GL_BLEND);
if (btheme->tui.wcol_pie_menu.shaded) {
@@ -4200,7 +4191,6 @@ void ui_draw_pie_center(uiBlock *block)
glDisable(GL_BLEND);
gpuPopMatrix();
- gpuMatrixEnd();
}
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 6d8a220dd8..1c9c516f1d 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -105,7 +105,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
if
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list