Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: why the highlight spot of a sphere doesn't change while i'm moving camera?

  1. #1
    Newbie Newbie
    Join Date
    Jun 2013
    Posts
    2

    Exclamation why the highlight spot of a sphere doesn't change while i'm moving camera?

    before:


    after (camera moved to the right side of the room):


    The position of the lights didn't change while the camera is moving (In fact, the white ball and the red cone represent where the lights are).

    The highlight spot of the sphere (circled) is really strange. I thought the spot would change when I looked at it at a different position (changing the camera), because it's Specular Reflection! But it just didn't.

    I checked my code and found nothing. Can anyone please give some tips?
    Last edited by bluebleam; 06-01-2013 at 03:07 AM.

  2. #2
    Newbie Newbie
    Join Date
    Jun 2013
    Posts
    2
    Well, I now know what happened. I use glLookAt while glMatrixMode(GL_PROJECTION)!
    Let me get this straight:
    before:
    glMatrixMode(GL_PROJECTION)->gluPerspective(...)->gluLookAt(...)
    after (fixed):
    glMatrixMode(GL_PROJECTION)->gluPerspective(...)->glMatrixMode(GL_MODELVIEW)->gluLookAt(...)

    so, gluLookAt cannot be used under projection matrix!
    But now I don't quite understand while the wrong was like that. Though it was wrong, When I set "gluLookAt", the camera position did changed! Why just the highlight spot turned out like that?

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,109
    read this http://www.songho.ca/opengl/gl_transform.html to understand how the matrices work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •