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:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-12-30 22:30:13 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-12-30 22:30:13 +0400
commitd342e3ef0f0d864133ae1d40481c309b366bbec0 (patch)
treed92f024f2ab6fcd6149e50704a54c12c9b5ebade /source/blender/gpu
parent6ded71fb62e7f8e6791bd5a6d721b1bd9efe0b85 (diff)
Use GPU_Buffers to draw wireframe when in dynamic-topology sculpt mode
This adds an override to the CDDM edge drawing function that switches to GPU_Buffers drawing for PBVHes of type PBVH_BMESH. Within the GPU_Buffers code, glPolygonMode() is used to draw lines instead of faces.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_buffers.h3
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c21
2 files changed, 18 insertions, 6 deletions
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 70ca44c2a3a..9f6f80585ab 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -184,7 +184,8 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, struct CCGElem **grids,
int *grid_indices, int totgrid, const struct CCGKey *key,
int show_diffuse_color);
-void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial);
+void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial,
+ int wireframe);
int GPU_buffers_diffuse_changed(GPU_Buffers *buffers, int show_diffuse_color);
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index ba090137118..5f9f68e9c99 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -2312,7 +2312,8 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers)
}
}
-void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
+void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial,
+ int wireframe)
{
if (buffers->totface) {
const MFace *f = &buffers->mface[buffers->face_indices[0]];
@@ -2329,14 +2330,19 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
if (buffers->vert_buf) {
glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- gpu_colors_enable(VBO_ENABLED);
+ if (!wireframe) {
+ glEnableClientState(GL_NORMAL_ARRAY);
+ gpu_colors_enable(VBO_ENABLED);
+ }
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf);
if (buffers->index_buf)
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf);
+ if (wireframe)
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
if (buffers->tot_quad) {
char *offset = 0;
int i, last = buffers->has_hidden ? 1 : buffers->totgrid;
@@ -2369,13 +2375,18 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial)
glDrawArrays(GL_TRIANGLES, 0, totelem);
}
+ if (wireframe)
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
if (buffers->index_buf)
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
- gpu_colors_disable(VBO_ENABLED);
+ if (!wireframe) {
+ glDisableClientState(GL_NORMAL_ARRAY);
+ gpu_colors_disable(VBO_ENABLED);
+ }
}
/* fallbacks if we are out of memory or VBO is disabled */
else if (buffers->totface) {