diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-12-30 22:30:13 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-12-30 22:30:13 +0400 |
commit | d342e3ef0f0d864133ae1d40481c309b366bbec0 (patch) | |
tree | d92f024f2ab6fcd6149e50704a54c12c9b5ebade /source/blender/gpu/intern/gpu_buffers.c | |
parent | 6ded71fb62e7f8e6791bd5a6d721b1bd9efe0b85 (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/intern/gpu_buffers.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 21 |
1 files changed, 16 insertions, 5 deletions
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) { |