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

Thread: LIGHTING Problem?!

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

    LIGHTING Problem?!

    Hello,

    I am programming a board game -> Othello
    and I have a problem with the light. After I move the frame the light is switching off, and only the tokens are visible with a 3d effect. The game board and the score board are not visible anymore.

    Does anybody see my mistake?


    void init(void)
    {
    GLfloat mat_specular[] = { -4.5, -9.0, -50.0, 1.0 };
    GLfloat mat_shininess[] = { 50.0 };
    GLfloat light_position0[] = { -4.5, -9.0, -16.0, 1.0 };
    GLfloat light_position1[] = { -1.0, 1.0, 1.0, 1.0 };
    GLfloat light_position2[] = { 0.0, 1.0, -1.0, 1.0 };
    GLfloat light_position3[] = { 0.5, 0.5, -0.5, 0.5 };
    GLfloat light_diffuse1[] = { 1.0, 0.0, 0.0, 1.0 };
    GLfloat light_diffuse0[] = { 0.0, 1.0, 0.0, 1.0 };
    GLfloat light_diffuse2[] = { 0.0, 0.0, 1.0, 1.0 };
    GLfloat light_diffuse3[] = { 0.0, 0.0, 0.5, 0.5 };


    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_SMOOTH);

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

    glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
    glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
    glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);

    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);


    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    glEnable(GL_LIGHT2);
    glEnable(GL_LIGHT3);
    glEnable(GL_DEPTH_TEST);
    glEnable (GL_COLOR_MATERIAL);
    glEnable(GL_NORMALIZE);
    }

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2010
    Location
    Brazil, Rio de Janeiro
    Posts
    147

    Re: LIGHTING Problem?!

    Can you post your display function?

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

    Re: LIGHTING Problem?!

    @McLeary, this was my mistake. I had to position the light in the display function. Now it works

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

    Re: LIGHTING Problem?!

    I still have one problem. The scoreboard which is hanging above the gameboard is dark. I tried already some different light positions, but nothing happened. It is still dark.

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

    Re: LIGHTING Problem?!

    Does anybody have a handy hint? I don't know what to do.

Posting Permissions

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