title: OpenGL lighting position is fixed at undesired location
body: <p>I am trying to locate my light at position 0,0,0 but it always go bottom left of the box which has coords -20,-20,0 and I try to change light position to some arbitrary coordinates but it still stays at bottom left.</p>
  
  <p>I provided a picture where camera positioned at 0,0,40:</p>
  
  <p><a href="https://i.stack.imgur.com/EfnlU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EfnlU.png" alt="enter image description here"></a>
  <br></p>
  
  <pre><code>void initLighting()
  {
      // Enable lighting
      glEnable(GL_LIGHTING);
      glEnable(GL_NORMALIZE);
      glEnable(GL_COLOR_MATERIAL);
      glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
      //glEnable(GL_DEPTH_TEST);
      glShadeModel(GL_SMOOTH);
      glEnable(GL_LIGHT0);
  
      // Set lighting intensity and color
      glLightfv(GL_LIGHT0, GL_AMBIENT, value_ptr(lights.at(0).ambient));
      glLightfv(GL_LIGHT0, GL_DIFFUSE, value_ptr(lights.at(0).diffuse));
      glLightfv(GL_LIGHT0, GL_SPECULAR, value_ptr(lights.at(0).specular));
      glLightfv(GL_LIGHT0, GL_POSITION, value_ptr(vec4(lights.at(0).position, 1.0f)));
      ////////////////////////////////////////////////
      glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 15.0);// set cutoff angle
      glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, value_ptr(box.center));
      glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 1); // set focusing strength
  }
  
  void display(void)
  {
      glMatrixMode(GL_MODELVIEW);
      // clear the drawing buffer.
      glClear(GL_COLOR_BUFFER_BIT);
      // clear the identity matrix.
      glLoadIdentity();
  
      glPushMatrix();
      gluLookAt(camera.position.x, camera.position.y, camera.position.z, box.center.x, box.center.y, box.center.z,
      camera.upVector.x, camera.upVector.y, camera.upVector.z);
      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, value_ptr(materials.at(box.material).ambient));
      glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, value_ptr(materials.at(box.material).diffuse));
      glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, value_ptr(materials.at(box.material).specular));
      glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, materials.at(box.material).exponent);
      glBegin(GL_TRIANGLES);
      for (int i = 0; i &lt; box.indices.size(); i = i + 3)
      {
          glNormal3fv(value_ptr(box.vertices.at(box.indices.at(i)).Normal));
          glVertex3f(box.vertices.at(box.indices.at(i)).Position.x, box.vertices.at(box.indices.at(i)).Position.y, box.vertices.at(box.indices.at(i)).Position.z);
  
          glNormal3fv(value_ptr(box.vertices.at(box.indices.at(i + 1)).Normal));
          glVertex3f(box.vertices.at(box.indices.at(i + 1)).Position.x, box.vertices.at(box.indices.at(i + 1)).Position.y, box.vertices.at(box.indices.at(i + 1)).Position.z);
  
          glNormal3fv(value_ptr(box.vertices.at(box.indices.at(i + 2)).Normal));
          glVertex3f(box.vertices.at(box.indices.at(i + 2)).Position.x, box.vertices.at(box.indices.at(i + 2)).Position.y, box.vertices.at(box.indices.at(i + 2)).Position.z);
      }
      glEnd();
      glPopMatrix();
  
      glPushMatrix();
      gluLookAt(camera.position.x, camera.position.y, camera.position.z, box.center.x, box.center.y, box.center.z,
      camera.upVector.x, camera.upVector.y, camera.upVector.z);
      glLightfv(GL_LIGHT0, GL_POSITION, value_ptr(vec4(lights.at(0).position, 1.0f)));
      glPopMatrix();
  
      glFlush();
      glutSwapBuffers();
  }
  </code></pre>