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:
authorDalai Felinto <dfelinto@gmail.com>2017-02-13 14:37:11 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-02-13 14:41:05 +0300
commitd4e9c27e4edc4f6771e0fff35f2c5aaa1cc0842f (patch)
tree5028e35a9f5122ec6cef72f8d262436275616458 /source/blender/editors/curve
parent4e641517874c63dc483c4a0153e5c3890deb48d1 (diff)
Immediate Mode: curve draw stroke
How to test this drawing: create and edit a curve and press shift + drag your mouse (or tablet). The Curve needs a Bevel Depth > 0.0. Note: The ideal solution would be to use a different shader, that takes no lighting. However according to Clément Foucault there is an assert preventing the same batch to me used with different attributes (or something like that). Il wait until the end of such resolution before revisiting this. That said, it is working fine. Part of T49043 Differential Revision: https://developer.blender.org/D2501
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r--source/blender/editors/curve/editcurve_paint.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 4720b76342c..01d9167cdb7 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -48,7 +48,9 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "GPU_batch.h"
#include "GPU_immediate.h"
+#include "GPU_matrix.h"
#include "curve_intern.h"
@@ -467,39 +469,48 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
Object *obedit = cdd->vc.obedit;
Curve *cu = obedit->data;
- UI_ThemeColor(TH_WIRE);
-
if (cu->ext2 > 0.0f) {
- GLUquadricObj *qobj = gluNewQuadric();
-
- gluQuadricDrawStyle(qobj, GLU_FILL);
-
BLI_mempool_iter iter;
const struct StrokeElem *selem;
const float location_zero[3] = {0};
const float *location_prev = location_zero;
+ float color[3];
+ UI_GetThemeColor3fv(TH_WIRE, color);
+
+ /* silly light-less shader, non-critical task, so it's fine */
+ float light[3] = {0.0f, 0.0f, 0.0f};
+
+ Batch *sphere = Batch_get_sphere(0);
+ Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING);
+ Batch_Uniform3fv(sphere, "color", color);
+ Batch_Uniform3fv(sphere, "light", light);
+
/* scale to edit-mode space */
- glPushMatrix();
- glMultMatrixf(obedit->obmat);
+ gpuMatrixBegin3D_legacy();
+ gpuPushMatrix();
+ gpuMultMatrix3D(obedit->obmat);
BLI_mempool_iternew(cdd->stroke_elem_pool, &iter);
for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) {
- glTranslatef(
+ gpuTranslate3f(
selem->location_local[0] - location_prev[0],
selem->location_local[1] - location_prev[1],
selem->location_local[2] - location_prev[2]);
location_prev = selem->location_local;
+
const float radius = stroke_elem_radius(cdd, selem);
- gluSphere(qobj, radius, 12, 8);
+
+ gpuScaleUniform(radius);
+ Batch_draw(sphere);
+ gpuScaleUniform(1.0f / radius);
location_prev = selem->location_local;
}
- glPopMatrix();
-
- gluDeleteQuadric(qobj);
+ gpuPopMatrix();
+ gpuMatrixEnd();
}
if (stroke_len > 1) {