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:
authorCampbell Barton <ideasman42@gmail.com>2017-04-20 19:18:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-04-20 21:23:28 +0300
commit677aa36632c6ed61815e9cbe04e317b290620b59 (patch)
tree654cfa1b889b83d08eaffa04fb3d048d15863594 /source/blender/draw/modes/edit_curve_mode.c
parent9d1421c06961f7f302fcb25ef0faae76f65fa466 (diff)
Curve: draw curve/surface/text geometry
Note that displists will be removed, but this wont be hard to replace. Signed-off-by: Campbell Barton <ideasman42@gmail.com>
Diffstat (limited to 'source/blender/draw/modes/edit_curve_mode.c')
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index 5f12bfeec73..2a76f1ea403 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -30,6 +30,7 @@
/* If builtin shaders are needed */
#include "GPU_shader.h"
+#include "GPU_batch.h"
#include "draw_common.h"
@@ -60,6 +61,7 @@ typedef struct EDIT_CURVE_PassList {
/* Declare all passes here and init them in
* EDIT_CURVE_cache_init().
* Only contains (DRWPass *) */
+ struct DRWPass *surface_pass;
struct DRWPass *wire_pass;
struct DRWPass *overlay_edge_pass;
struct DRWPass *overlay_vert_pass;
@@ -105,6 +107,8 @@ static struct {
* Add sources to source/blender/draw/modes/shaders
* init in EDIT_CURVE_engine_init();
* free in EDIT_CURVE_engine_free(); */
+ struct GPUShader *surface_sh;
+
struct GPUShader *wire_sh;
struct GPUShader *overlay_edge_sh; /* handles and nurbs control cage */
@@ -116,6 +120,8 @@ typedef struct g_data {
/* This keeps the references of the shading groups for
* easy access in EDIT_CURVE_cache_populate() */
+ DRWShadingGroup *surface_shgrp;
+
/* resulting curve as 'wire' for curves (and optionally normals) */
DRWShadingGroup *wire_shgrp;
@@ -151,6 +157,11 @@ static void EDIT_CURVE_engine_init(void *vedata)
* tex, 2);
*/
+
+ if (!e_data.surface_sh) {
+ e_data.surface_sh = GPU_shader_get_builtin_shader(GPU_SHADER_SIMPLE_LIGHTING);
+ }
+
if (!e_data.wire_sh) {
e_data.wire_sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
}
@@ -180,6 +191,12 @@ static void EDIT_CURVE_cache_init(void *vedata)
}
{
+ /* Surface */
+ psl->surface_pass = DRW_pass_create(
+ "Surface",
+ DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
+ stl->g_data->surface_shgrp = DRW_shgroup_create(e_data.surface_sh, psl->surface_pass);
+
/* Center-Line (wire) */
psl->wire_pass = DRW_pass_create(
"Curve Wire",
@@ -222,7 +239,13 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
/* Get geometry cache */
struct Batch *geom;
-// geom = DRW_cache_mesh_surface_get(ob);
+ geom = DRW_cache_curve_surface_get(ob);
+ if (geom) {
+ Batch_set_builtin_program(geom, GPU_SHADER_SIMPLE_LIGHTING);
+ Batch_Uniform4f(geom, "color", 1, 1, 1, 1);
+ Batch_Uniform3f(geom, "light", 0, 0, 1);
+ DRW_shgroup_call_add(stl->g_data->surface_shgrp, geom, ob->obmat);
+ }
geom = DRW_cache_curve_edge_wire_get(ob);
DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat);
@@ -276,6 +299,7 @@ static void EDIT_CURVE_draw_scene(void *vedata)
*/
/* ... or just render passes on default framebuffer. */
+ DRW_draw_pass(psl->surface_pass);
DRW_draw_pass(psl->wire_pass);
DRW_draw_pass(psl->overlay_edge_pass);
DRW_draw_pass(psl->overlay_vert_pass);