diff options
author | Alexander Romanov <a.romanov@blend4web.com> | 2016-05-16 11:13:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-06-09 22:38:17 +0300 |
commit | 6798809c7ec8388509f541a64359b3d107e6fd3f (patch) | |
tree | cab8d4b80cfca2974814af7598248edd6368b6e5 /source/blender/blenkernel/intern | |
parent | d733826708f9b562687b78424e5c0835cba8c3c9 (diff) |
Flat shading for basic shader
The purpose of the patch is to replace deprecated glShadeModel.
To decrease glShadeModel calls I've set GL_SMOOTH by default
Reviewers: merwin, brecht
Reviewed By: brecht
Subscribers: blueprintrandom, Evgeny_Rodygin, AlexKowel, yurikovelenov
Differential Revision: https://developer.blender.org/D1958
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 3 |
4 files changed, 2 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 0de0e4d7797..d590a35bb57 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3881,7 +3881,6 @@ static void navmesh_drawColored(DerivedMesh *dm) /* if (GPU_buffer_legacy(dm) ) */ /* TODO - VBO draw code, not high priority - campbell */ { DEBUG_VBO("Using legacy code. drawNavMeshColored\n"); - //glShadeModel(GL_SMOOTH); glBegin(glmode = GL_QUADS); for (a = 0; a < dm->numTessFaceData; a++, mface++) { int new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 392a38773e7..267f7a65e00 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -464,7 +464,6 @@ static void cdDM_drawFacesSolid( BKE_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, setMaterial, false, false); - glShadeModel(GL_FLAT); return; } } @@ -472,7 +471,6 @@ static void cdDM_drawFacesSolid( GPU_vertex_setup(dm); GPU_normal_setup(dm); GPU_triangle_setup(dm); - glShadeModel(GL_SMOOTH); for (a = 0; a < dm->drawObject->totmaterial; a++) { if (!setMaterial || setMaterial(dm->drawObject->materials[a].mat_nr + 1, NULL)) { GPU_buffer_draw_elements( @@ -481,8 +479,6 @@ static void cdDM_drawFacesSolid( } } GPU_buffers_unbind(); - - glShadeModel(GL_FLAT); } static void cdDM_drawFacesTex_common( @@ -553,8 +549,7 @@ static void cdDM_drawFacesTex_common( if (mloopcol) { GPU_color_setup(dm, colType); } - - glShadeModel(GL_SMOOTH); + /* lastFlag = 0; */ /* UNUSED */ for (mat_index = 0; mat_index < dm->drawObject->totmaterial; mat_index++) { GPUBufferMaterial *bufmat = dm->drawObject->materials + mat_index; @@ -633,7 +628,6 @@ static void cdDM_drawFacesTex_common( } GPU_buffers_unbind(); - glShadeModel(GL_FLAT); } @@ -742,9 +736,6 @@ static void cdDM_drawMappedFaces( } } } - - - glShadeModel(GL_SMOOTH); tot_tri_elem = dm->drawObject->tot_triangle_point; @@ -841,7 +832,6 @@ static void cdDM_drawMappedFaces( } GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); - glShadeModel(GL_FLAT); GPU_buffers_unbind(); @@ -929,8 +919,6 @@ static void cdDM_drawMappedFacesGLSL( matnr = -1; do_draw = false; - glShadeModel(GL_SMOOTH); - if (setDrawOptions != NULL) { DMVertexAttribs attribs; DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n"); @@ -1153,8 +1141,6 @@ static void cdDM_drawMappedFacesGLSL( MEM_freeN(mat_orig_to_new); MEM_freeN(matconv); } - - glShadeModel(GL_FLAT); } static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial) @@ -1203,8 +1189,6 @@ static void cdDM_drawMappedFacesMat( matnr = -1; - glShadeModel(GL_SMOOTH); - memset(&attribs, 0, sizeof(attribs)); glBegin(GL_TRIANGLES); @@ -1260,8 +1244,6 @@ static void cdDM_drawMappedFacesMat( cddm_draw_attrib_vertex(&attribs, mvert, a, vtri[2], ltri[2], 2, ln3, smoothnormal); } glEnd(); - - glShadeModel(GL_FLAT); } static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData) diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 8df07c5f3f4..6b81c47765b 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1240,8 +1240,6 @@ static void emDM_drawFacesTex_common( // dummylcol.r = dummylcol.g = dummylcol.b = dummylcol.a = 255; /* UNUSED */ /* always use smooth shading even for flat faces, else vertex colors wont interpolate */ - glShadeModel(GL_SMOOTH); - BM_mesh_elem_index_ensure(bm, BM_FACE); /* call again below is ok */ @@ -1388,8 +1386,6 @@ static void emDM_drawFacesTex_common( } } } - - glShadeModel(GL_FLAT); } static void emDM_drawFacesTex( @@ -1528,8 +1524,6 @@ static void emDM_drawMappedFacesGLSL( vertexNos = bmdm->vertexNos; polyNos = bmdm->polyNos; - /* always use smooth shading even for flat faces, else vertex colors wont interpolate */ - glShadeModel(GL_SMOOTH); BM_mesh_elem_index_ensure(bm, (BM_VERT | BM_FACE) | (lnors ? BM_LOOP : 0)); for (i = 0; i < em->tottri; i++) { @@ -1640,8 +1634,6 @@ static void emDM_drawMappedFacesMat( vertexNos = bmdm->vertexNos; polyNos = bmdm->polyNos; - /* always use smooth shading even for flat faces, else vertex colors wont interpolate */ - glShadeModel(GL_SMOOTH); BM_mesh_elem_index_ensure(bm, (BM_VERT | BM_FACE) | (lnors ? BM_LOOP : 0)); for (i = 0; i < em->tottri; i++) { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 88bc3fb9854..b0d19320230 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2619,7 +2619,6 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) if (BKE_pbvh_has_faces(ccgdm->pbvh)) { BKE_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, setMaterial, false, fast); - glShadeModel(GL_FLAT); } return; @@ -3164,7 +3163,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, MEM_freeN(matconv); } - glShadeModel(GL_FLAT); + glShadeModel(GL_SMOOTH); } static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial) |