summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongwon Kim <dongwon.kim@intel.com>2015-02-03 15:48:00 -0700
committerBrian Paul <brianp@vmware.com>2015-02-03 16:02:43 -0700
commita56afc865e95bfc5e9748d015f344ad58aafdc22 (patch)
tree8d2bf65030a56c3df6c9ad5223dd48096aa9c007
parent999b6950c644266bb871e79438751bdba2fa2a08 (diff)
downloadmesa-demos-a56afc865e95bfc5e9748d015f344ad58aafdc22.zip
mesa-demos-a56afc865e95bfc5e9748d015f344ad58aafdc22.tar.xz
torus.c: Lighting effect is distorted when object is scaled up/down
When torus object is scaled up/down via glScalef call the lighting effect is incorrectly expressed on render target because normals' length is also changed when vertices are scaled up/down. This patch enables "automatic normalization" of normals, which is one of well-known ways to avoid this kind of distortion. Reference: www.opengl.org/sdk/docs/man2/xhtml/glScale.xml Notes If scale factors other than 1 are applied to the modelview matrix and lighting is enabled, lighting often appears wrong. In that case, enable automatic normalization of normals by calling glEnable with the argument GL_NORMALIZE. Signed-off-by: Dongwon Kim <dongwon.kim@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--src/egl/opengles1/torus.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/egl/opengles1/torus.c b/src/egl/opengles1/torus.c
index 8f262b5..ccf53d1 100644
--- a/src/egl/opengles1/torus.c
+++ b/src/egl/opengles1/torus.c
@@ -358,6 +358,11 @@ init(void)
make_texture();
glEnable(GL_TEXTURE_2D);
+
+ /* Enable automatic normalizing to get proper lighting when torus is
+ * scaled down via glScalef
+ */
+ glEnable(GL_NORMALIZE);
}