From a56afc865e95bfc5e9748d015f344ad58aafdc22 Mon Sep 17 00:00:00 2001 From: Dongwon Kim Date: Tue, 3 Feb 2015 15:48:00 -0700 Subject: 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 Reviewed-by: Brian Paul --- src/egl/opengles1/torus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/egl/opengles1/torus.c b/src/egl/opengles1/torus.c index 8f262b53..ccf53d19 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); } -- cgit v1.2.3