Changes in double side lighting usage

Disabled double-side lighting by default and changed areas which are using
double sided lighting to switch it off just after doing stuff which requires
double side.

This makes code a bit more simple to follow (no all that disabling double side
lighting all over the code and so).

This change also fixes crash of blender caused by intel gme965 driver which
leads to stack corruption in some place when double side lighting isn't
disabled (probably driver still kind of using double side in some areas or so).

Hopefully it'll also fix #30293: Converting Text to Mesh

Thanks to Campbell to assist writing this patch!
This commit is contained in:
2012-02-25 18:09:39 +00:00
parent 3fc2fbc333
commit 79f9964cdb
2 changed files with 7 additions and 5 deletions

View File

@@ -3021,6 +3021,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
glFrontFace(GL_CCW);
glDisable(GL_LIGHTING);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
}
// Setup for drawing wire over, disable zbuffer
@@ -3365,6 +3366,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
glFrontFace(GL_CCW);
glDisable(GL_LIGHTING);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
if (base->flag & SELECT) {
UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT);
}
@@ -3804,7 +3807,6 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
if (!glsl) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
glEnable(GL_LIGHTING);
dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
glDisable(GL_LIGHTING);
@@ -3866,7 +3868,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
}
else {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
drawDispListsolid(lb, ob, 0);
GPU_end_object_materials();
}
@@ -3904,7 +3905,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
}
else {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
drawDispListsolid(lb, ob, 0);
GPU_end_object_materials();
}
@@ -3929,7 +3929,6 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas
}
else {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
drawDispListsolid(lb, ob, 0);
GPU_end_object_materials();
}
@@ -7329,7 +7328,6 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r
glDisable(GL_COLOR_MATERIAL);
}
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
glEnable(GL_LIGHTING);

View File

@@ -179,6 +179,10 @@ void GPU_extensions_init(void)
GG.npotdisabled = 1;
}
/* make sure double side isn't used by defautl and only getting enabled in places where it's
* really needed to prevent different unexpected behaviors like with intel gme965 card (sergey) */
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
GG.os = GPU_OS_UNIX;
#ifdef _WIN32
GG.os = GPU_OS_WIN;