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 2 of 2

Thread: How to switch the light on scoreboard?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    5

    How to switch the light on scoreboard?

    I have two problems.
    First:
    When I make a move with the cursor the light is changing from pic1 to pic2.

    Second:
    The light is shinning on the gameboard see pic2, but it's not shinning on the scoreboard above. I tried different light positions, but nothing happend.

    void init(void)
    {
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    glEnable(GL_LIGHT2);
    glEnable(GL_LIGHT3);
    glEnable(GL_LIGHT4);
    glEnable(GL_LIGHT5);
    glEnable(GL_LIGHT6);
    glEnable(GL_DEPTH_TEST);
    glEnable (GL_COLOR_MATERIAL);
    glEnable(GL_NORMALIZE);
    }

    void display(void)
    {

    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);

    GLfloat mat_specular[] = { 0.1, 0.1, 0.1, 0.1 };

    GLfloat light_position0[] = { -4.5, -9.0, -16.0, 1.0 };
    GLfloat light_position1[] = { -10.0, 1.0, 1.0, 0.0 };
    GLfloat light_position2[] = { 0.4, 1.0, -1.0, 0.0 };
    GLfloat light_position3[] = { 0.5, 0.5, -0.5, 0.5 };
    GLfloat light_position4[] = { 0.5, 0.5, -0.5, 0.5 };
    GLfloat light_position6[] = { 0.5, 0.5, -0.5, 0.5 };
    GLfloat light_diffuse1[] = { 1.0, 0.4, 0.4, 1.0 };

    GLfloat light_diffuse0[] = { 0.4, 1.0, 0.4, 1.0 };
    GLfloat light_diffuse2[] = { 0.4, 0.4, 1.0, 1.0 };
    GLfloat light_diffuse3[] = { 0.4, 0.4, 0.5, 0.5 };
    glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
    glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 30);
    glLightfv(GL_LIGHT2, GL_POSITION, light_position2);
    glLightfv(GL_LIGHT2, GL_DIFFUSE, light_diffuse2);
    glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse1);
    glLightfv(GL_LIGHT3, GL_POSITION, light_position3);
    glLightfv(GL_LIGHT3, GL_DIFFUSE, light_diffuse3);
    glLightfv(GL_LIGHT4, GL_POSITION, light_position0);
    glLightf(GL_LIGHT4, GL_SPOT_CUTOFF, 30);
    glLightfv(GL_LIGHT6, GL_POSITION, light_position6);
    glLightfv(GL_LIGHT6, GL_SPECULAR, mat_specular);

    GLfloat light5_position[] ={1.0, 1.0, 1.0, 0.0};
    GLfloat light5_dir[] = {0, 0, 0, 1};
    }

  2. #2
    Intern Contributor Zenja's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, Australia
    Posts
    50

    Re: How to switch the light on scoreboard?

    OpenGL will multiply the light position you specify with the current modelview matrix. Lighting calculations are then done in EYE coordinates, which may be different from what you're expecting. If you reposition the camera, after setting the light position, then you will have weird lighting effects.

Posting Permissions

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