From 263f4cd3426f19eccde79f6eeeec758c03a234ac Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 23 Nov 2015 21:42:17 +0100 Subject: OpenGL: rename GPU_enable_material to better indicate it's binding shaders. --- source/blender/editors/space_view3d/drawmesh.c | 18 ++++---- source/blender/editors/space_view3d/drawobject.c | 52 ++++++++++++------------ source/blender/gpu/GPU_draw.h | 6 +-- source/blender/gpu/intern/gpu_draw.c | 10 ++--- 4 files changed, 43 insertions(+), 43 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 728890a6dbc..afc48d2ff5e 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -815,7 +815,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) /* TEXFACE */ if (glsl) { - GPU_enable_material(matnr + 1, &gattribs); + GPU_object_material_bind(matnr + 1, &gattribs); for (i = 0; i < gattribs.totlayer; i++) { if (gattribs.layer[i].type == CD_MTFACE) { @@ -967,7 +967,7 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d } else if (draw_flags & DRAW_FACE_SELECT) { if (ob->mode & OB_MODE_WEIGHT_PAINT) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_object_material_bind, NULL, me, DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH | DM_DRAW_SKIP_HIDDEN); else { drawTFace_userData userData; @@ -1024,7 +1024,7 @@ static void tex_mat_set_material_cb(void *UNUSED(userData), int mat_nr, void *at * that the GLSL code will give different result depending on the drawtype, * in texture draw mode it will output the active texture node, in material * draw mode it will show the full material. */ - GPU_enable_material(mat_nr, attribs); + GPU_object_material_bind(mat_nr, attribs); } static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs) @@ -1048,7 +1048,7 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs) NodeTexBase *texbase = node->storage; /* disable existing material */ - GPU_disable_material(); + GPU_object_material_unbind(); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero); glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 0); @@ -1087,7 +1087,7 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs) glDisable(GL_COLOR_MATERIAL); /* draw single color */ - GPU_enable_material(mat_nr, attribs); + GPU_object_material_bind(mat_nr, attribs); } } @@ -1212,7 +1212,7 @@ static void draw_mesh_paint_light_begin(void) { const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f}; - GPU_enable_material(0, NULL); + GPU_object_material_bind(0, NULL); /* but set default spec */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); @@ -1228,13 +1228,13 @@ static void draw_mesh_paint_light_end(void) glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); - GPU_disable_material(); + GPU_object_material_unbind(); } void draw_mesh_paint_weight_faces(DerivedMesh *dm, const bool use_light, void *facemask_cb, void *user_data) { - DMSetMaterial setMaterial = GPU_object_materials_check() ? GPU_enable_material : NULL; + DMSetMaterial setMaterial = GPU_object_materials_check() ? GPU_object_material_bind : NULL; if (use_light) { draw_mesh_paint_light_begin(); @@ -1252,7 +1252,7 @@ void draw_mesh_paint_vcolor_faces(DerivedMesh *dm, const bool use_light, void *facemask_cb, void *user_data, const Mesh *me) { - DMSetMaterial setMaterial = GPU_object_materials_check() ? GPU_enable_material : NULL; + DMSetMaterial setMaterial = GPU_object_materials_check() ? GPU_object_material_bind : NULL; if (use_light) { draw_mesh_paint_light_begin(); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 78e3ff1477b..9ab93b18cc1 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3797,16 +3797,16 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, /* use the cageDM since it always overlaps the editmesh faces */ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); cageDM->drawMappedFaces(cageDM, draw_em_fancy__setFaceOpts, - GPU_enable_material, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN); + GPU_object_material_bind, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } else if (check_object_draw_texture(scene, v3d, dt)) { if (draw_glsl_material(scene, ob, v3d, dt)) { glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material, + finalDM->drawMappedFacesGLSL(finalDM, GPU_object_material_bind, draw_em_fancy__setGLSLFaceOpts, em); - GPU_disable_material(); + GPU_object_material_unbind(); glFrontFace(GL_CCW); } @@ -3821,7 +3821,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, glEnable(GL_LIGHTING); glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, GPU_enable_material, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN); + finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, GPU_object_material_bind, NULL, me->edit_btmesh, DM_DRAW_SKIP_HIDDEN); glFrontFace(GL_CCW); glDisable(GL_LIGHTING); @@ -3985,7 +3985,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, if (dt > OB_WIRE) { glDepthMask(1); ED_view3d_polygon_offset(rv3d, 0.0); - GPU_disable_material(); + GPU_object_material_unbind(); } #if 0 /* currently not needed */ else if (use_occlude_wire) { @@ -4008,9 +4008,9 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) * drawFacesSolid() doesn't draw the transparent faces */ if (ob->dtx & OB_DRAWTRANSP) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - GPU_disable_material(); + GPU_object_material_unbind(); } else { dm->drawEdges(dm, 0, 1); @@ -4120,18 +4120,18 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } - GPU_enable_material(1, &gattribs); + GPU_object_material_bind(1, &gattribs); dm->drawFacesSolid(dm, fpl, fast, NULL); draw_loose = false; } else - dm->drawFacesGLSL(dm, GPU_enable_material); + dm->drawFacesGLSL(dm, GPU_object_material_bind); #if 0 /* XXX */ if (BKE_bproperty_object_get(ob, "Text")) draw_mesh_text(ob, 1); #endif - GPU_disable_material(); + GPU_object_material_unbind(); glFrontFace(GL_CCW); @@ -4155,7 +4155,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) { - dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); } else { const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f}; @@ -4173,7 +4173,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* materials arent compatible with vertex colors */ GPU_end_object_materials(); - GPU_enable_material(0, NULL); + GPU_object_material_bind(0, NULL); /* set default spec */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); @@ -4187,7 +4187,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); - GPU_disable_material(); + GPU_object_material_unbind(); } } else { @@ -4220,12 +4220,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } - dm->drawFacesSolid(dm, fpl, fast, GPU_enable_material); + dm->drawFacesSolid(dm, fpl, fast, GPU_object_material_bind); } else - dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); - GPU_disable_material(); + GPU_object_material_unbind(); glFrontFace(GL_CCW); glDisable(GL_LIGHTING); @@ -4588,7 +4588,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag, case DL_SURF: if (dl->index) { - GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL); + GPU_object_material_bind(dl->col + 1, (use_glsl) ? &gattribs : NULL); if (dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); @@ -4602,7 +4602,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag, break; case DL_INDEX3: - GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL); + GPU_object_material_bind(dl->col + 1, (use_glsl) ? &gattribs : NULL); glVertexPointer(3, GL_FLOAT, 0, dl->verts); @@ -4622,7 +4622,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag, break; case DL_INDEX4: - GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL); + GPU_object_material_bind(dl->col + 1, (use_glsl) ? &gattribs : NULL); glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, 0, dl->verts); @@ -4667,11 +4667,11 @@ static bool drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, if (!glsl) { glEnable(GL_LIGHTING); - dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); glDisable(GL_LIGHTING); } else - dm->drawFacesGLSL(dm, GPU_enable_material); + dm->drawFacesGLSL(dm, GPU_object_material_bind); GPU_end_object_materials(); } @@ -7938,10 +7938,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } else { if (dt > OB_WIRE) - GPU_enable_material(0, NULL); /* we use default material */ + GPU_object_material_bind(0, NULL); /* we use default material */ empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, false); if (dt > OB_WIRE) - GPU_disable_material(); + GPU_object_material_unbind(); } } break; @@ -8540,7 +8540,7 @@ static void bbs_mesh_solid_verts(Scene *scene, Object *ob) DM_update_materials(dm, ob); - dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, GPU_enable_material, NULL, me, DM_DRAW_SKIP_HIDDEN); + dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, GPU_object_material_bind, NULL, me, DM_DRAW_SKIP_HIDDEN); bbs_obmode_mesh_verts(ob, dm, 1); bm_vertoffs = me->totvert + 1; @@ -8676,11 +8676,11 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r glEnable(GL_LIGHTING); if (dm) { - dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); GPU_end_object_materials(); } else if (edm) - edm->drawMappedFaces(edm, NULL, GPU_enable_material, NULL, NULL, 0); + edm->drawMappedFaces(edm, NULL, GPU_object_material_bind, NULL, NULL, 0); glDisable(GL_LIGHTING); } diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 0992f8e9d21..ce30f7460a1 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -63,7 +63,7 @@ void GPU_state_init(void); * - first the state is initialized by a particular object and * it's materials * - after this, materials can be quickly enabled by their number, - * GPU_enable_material returns 0 if drawing should be skipped + * GPU_object_material_bind returns 0 if drawing should be skipped * - after drawing, the material must be disabled again */ void GPU_begin_object_materials(struct View3D *v3d, struct RegionView3D *rv3d, @@ -71,8 +71,8 @@ void GPU_begin_object_materials(struct View3D *v3d, struct RegionView3D *rv3d, void GPU_end_object_materials(void); bool GPU_object_materials_check(void); -int GPU_enable_material(int nr, void *attribs); -void GPU_disable_material(void); +int GPU_object_material_bind(int nr, void *attribs); +void GPU_object_material_unbind(void); void GPU_begin_dupli_object(struct DupliObject *dob); void GPU_end_dupli_object(void); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index aaf4037197e..46924a36327 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1414,7 +1414,7 @@ static struct GPUMaterialState { int totmat; /* set when called inside GPU_begin_object_materials / GPU_end_object_materials - * otherwise calling GPU_enable_material returns zero */ + * otherwise calling GPU_object_material_bind returns zero */ bool is_enabled; Material **gmatbuf; @@ -1668,7 +1668,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O } /* let's start with a clean state */ - GPU_disable_material(); + GPU_object_material_unbind(); } static int GPU_get_particle_info(GPUParticleInfo *pi) @@ -1701,7 +1701,7 @@ static int GPU_get_particle_info(GPUParticleInfo *pi) return 0; } -int GPU_enable_material(int nr, void *attribs) +int GPU_object_material_bind(int nr, void *attribs) { GPUVertexAttribs *gattribs = attribs; GPUMaterial *gpumat; @@ -1824,7 +1824,7 @@ int GPU_get_material_alpha_blend(void) return GMS.lastalphablend; } -void GPU_disable_material(void) +void GPU_object_material_unbind(void) { GMS.lastmatnr = -1; GMS.lastretval = 1; @@ -1868,7 +1868,7 @@ bool GPU_object_materials_check(void) void GPU_end_object_materials(void) { - GPU_disable_material(); + GPU_object_material_unbind(); GMS.is_enabled = false; -- cgit v1.2.3