Commit: 6798809c7ec8388509f541a64359b3d107e6fd3f Author: Alexander Romanov Date: Mon May 16 11:13:21 2016 +0300 Branches: master https://developer.blender.org/rB6798809c7ec8388509f541a64359b3d107e6fd3f
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 =================================================================== M source/blender/blenkernel/intern/DerivedMesh.c M source/blender/blenkernel/intern/cdderivedmesh.c M source/blender/blenkernel/intern/editderivedmesh.c M source/blender/blenkernel/intern/subsurf_ccg.c M source/blender/editors/gpencil/drawgpencil.c M source/blender/editors/interface/interface_draw.c M source/blender/editors/interface/interface_icons.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/interface/interface_widgets.c M source/blender/editors/space_sequencer/sequencer_draw.c M source/blender/editors/space_view3d/drawanimviz.c M source/blender/editors/space_view3d/drawarmature.c M source/blender/editors/space_view3d/drawmesh.c M source/blender/editors/space_view3d/drawobject.c M source/blender/editors/space_view3d/view3d_draw.c M source/blender/editors/uvedit/uvedit_draw.c M source/blender/gpu/GPU_basic_shader.h M source/blender/gpu/intern/gpu_basic_shader.c M source/blender/gpu/intern/gpu_buffers.c M source/blender/gpu/intern/gpu_draw.c M source/blender/gpu/shaders/gpu_shader_basic_frag.glsl M source/blender/gpu/shaders/gpu_shader_basic_vert.glsl =================================================================== diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 0de0e4d..d590a35 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 392a387..267f7a6 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 8df07c5..6b81c47 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 88bc3fb..b0d1932 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) diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 0329598..79a2c49 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -763,6 +763,7 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness } glEnd(); + glShadeModel(GL_SMOOTH); } /* draw debug points of curve on top? (original stroke points) */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 8fbc545..d78b418 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -181,7 +181,6 @@ void UI_draw_roundbox_shade_x( coldown[1] = max_ff(0.0f, color[1] + shadedown); coldown[2] = max_ff(0.0f, color[2] + shadedown); - glShadeModel(GL_SMOOTH); glBegin(mode); /* start with corner right-bottom */ @@ -260,7 +259,6 @@ void UI_draw_roundbox_shade_x( } glEnd(); - glShadeModel(GL_FLAT); } /* linear vertical shade within button or in outline */ @@ -291,7 +289,6 @@ void UI_draw_roundbox_shade_y( colRight[1] = max_ff(0.0f, color[1] + shadeRight); colRight[2] = max_ff(0.0f, color[2] + shadeRight); - glShadeModel(GL_SMOOTH); glBegin(mode); /* start with corner right-bottom */ @@ -367,7 +364,6 @@ void UI_draw_roundbox_shade_y( } glEnd(); - glShadeModel(GL_FLAT); } /* plain antialiased unfilled rectangle */ @@ -531,7 +527,6 @@ static void histogram_draw_one( } else { /* under the curve */ - glShadeModel(GL_FLAT); glBegin(GL_TRIANGLE_STRIP); glVertex2f(x, y); glVertex2f(x, y + (data[0] * h)); @@ -1087,7 +1082,6 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); /* layer: color ramp */ - glShadeModel(GL_FLAT); glEnable(GL_BLEND); CBData *cbd = coba->data; @@ -1133,7 +1127,6 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti glEnd(); glDisable(GL_BLEND); - glShadeModel(GL_SMOOTH); /* layer: box outline */ glColor4f(0.0, 0.0, 0.0, 1.0); @@ -1212,9 +1205,9 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); - glShadeModel(GL_SMOOTH); + int bound_options = GPU_basic_shader_bound_options(); + GPU_basic_shader_bind(bound_options); gluSphere(qobj, 100.0, 32, 24); - glShadeModel(GL_FLAT); gluDeleteQuadric(qobj); glEndList(); @@ -1677,7 +1670,6 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy) { glEnable(GL_BLEND); - glShadeModel(GL_SMOOTH); glBegin(GL_QUADS); @@ -1689,7 +1681,6 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, glEnd(); glDisable(GL_BLEND); - glShadeModel(GL_FLAT); } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 222b036..6dc60f1 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -368,7 +368,6 @@ static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h), viconutil_set_point(pts[1], cx - d2, cy - d); viconutil_set_point(pts[2], cx + d2, cy); - glShadeModel(GL_SMOOTH); glBegin(GL_TRIANGLES); glColor4f(0.8f, 0.8f, 0.8f, alpha); glVertex2iv(pts[0]); @@ -376,7 +375,6 @@ static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h), glColor4f(0.3f, 0.3f, 0.3f, alpha); glVertex2iv(pts[2]); glEnd(); - glShadeModel(GL_FLAT); glColor4f(0.0f, 0.0f, 0.0f, 1); viconutil_draw_lineloop_smooth(pts, 3); @@ -395,13 +393,11 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float glColor4f(0.2f, 0.2f, 0.2f, alpha); - glShadeModel(GL_SMOOTH); glBegin(GL_TRIANGLES); glVertex2iv(pts[0]); glVertex2iv(pts[1]); glVertex2iv(pts[2]); glEnd(); - glShadeModel(GL_FLAT); } static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), float alpha) @@ -415,7 +411,6 @@ static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), f viconutil_set_point(pts[1], cx - d, cy + d2); viconutil_set_point(pts[2], cx, cy - d2); - glShadeModel(GL_SMOOTH); glBegin(GL_TRIANGLES); glColor4f(0.8f, 0.8f, 0.8f, alpha); glVertex2iv(pts[0]); @@ -423,7 +418,6 @@ static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), f glColor4f(0.3f, 0.3f, @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs