diff options
author | Dongwon Kim <dongwon.kim@intel.com> | 2015-02-03 15:48:00 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2015-02-03 16:02:43 -0700 |
commit | a56afc865e95bfc5e9748d015f344ad58aafdc22 (patch) | |
tree | 8d2bf65030a56c3df6c9ad5223dd48096aa9c007 | |
parent | 999b6950c644266bb871e79438751bdba2fa2a08 (diff) |
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.c | 5 |
1 files changed, 5 insertions, 0 deletions
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); } |