Add check for GPU materials enable state

This commit is contained in:
Campbell Barton 2015-07-18 05:29:34 +10:00
parent 32f7b4a358
commit b45749727c
2 changed files with 10 additions and 0 deletions

View File

@ -69,6 +69,7 @@ void GPU_state_init(void);
void GPU_begin_object_materials(struct View3D *v3d, struct RegionView3D *rv3d,
struct Scene *scene, struct Object *ob, bool glsl, bool *do_alpha_after);
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);

View File

@ -1407,6 +1407,8 @@ static struct GPUMaterialState {
GPUMaterialFixed (*matbuf);
GPUMaterialFixed matbuf_fixed[FIXEDMAT];
int totmat;
/* set when called inside GPU_begin_object_materials / GPU_end_object_materials */
bool is_enabled;
Material **gmatbuf;
Material *gmatbuf_fixed[FIXEDMAT];
@ -1526,6 +1528,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
/* DupliObject must be restored */
dob = GMS.dob;
memset(&GMS, 0, sizeof(GMS));
GMS.is_enabled = true;
GMS.dob = dob;
GMS.lastmatnr = -1;
GMS.lastretval = -1;
@ -1824,11 +1827,17 @@ bool GPU_material_use_matcaps_get(void)
return GMS.use_matcaps;
}
bool GPU_object_materials_check(void)
{
return GMS.is_enabled;
}
void GPU_end_object_materials(void)
{
GPU_disable_material();
GMS.is_enabled = false;
if (GMS.matbuf && GMS.matbuf != GMS.matbuf_fixed) {
MEM_freeN(GMS.matbuf);
MEM_freeN(GMS.gmatbuf);