CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    10

    How to change the light position?????

    Hi,
    I want to change the light position but I don't know how to do that? I know that you have to use GL_POSITION or something
    like that but I don't know how to change it properly. Also do you know how to change the color of
    the light to make it with red,blue, or green shades.


  2. #2
    Join Date
    May 1999
    Posts
    69

    Re: How to change the light position?????

    This is how I'm doing it


    // Set up the values (these variables may be global)
    GLfloat global_ambient[4]= {0.2, 0.2, 0.2, 1.0};
    GLfloat light0pos[4] = {0.0, 0.0, 0.0, 1.0};
    GLfloat light0ambient[4] = {0.25, 0.25, 0.25, 1.0};
    GLfloat light0diffuse[4] = {0.55, 0.55, 0.55, 1.0};
    GLfloat light0specular[4]= {0.15, 0.15, 0.15, 1.0};

    // Call this in OnCreate()of your window/view or any intitalization fn.
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE , 0);
    glLightfv(GL_LIGHT0, GL_AMBIENT, light0ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light0diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light0specular);
    glLightfv(GL_LIGHT0, GL_POSITION, light0pos);




    There are other ways of doing this, but this way seems to be convenient


  3. #3
    Join Date
    Apr 1999
    Posts
    10

    Re: How to change the light position?????

    Thanks alot man. This helped me out alot.


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured