void LightsourceManager::setLightsources(bool navigationEnabled,DisplayState* displayState,GLContextData& contextData) const
	{
	/* Get the lighting state tracker: */
	GLLightTracker* lt=contextData.getLightTracker();
	
	/* Process all physical light sources first: */
	GLsizei lightIndex=0;
	bool haveNavigationalLightsources=false;
	for(const LightsourceListItem* lsPtr=firstLightsource;lsPtr!=0&&lightIndex<lt->getMaxNumLights();lsPtr=lsPtr->succ)
		{
		if(lsPtr->isEnabled())
			{
			/* Only set light source now if it is physical, or if there is no navigation transformation: */
			if(lsPtr->physical||!navigationEnabled)
				{
				/* Set the light source in the light tracker and OpenGL: */
				lt->enableLight(lightIndex,lsPtr->getLight());
				
				/* Increment the light index: */
				++lightIndex;
				}
			else
				haveNavigationalLightsources=true;
			}
		}
	
	if(haveNavigationalLightsources)
		{
		/* Temporarily go to navigational coordinates: */
		glPushMatrix();
		glLoadIdentity();
		glMultMatrix(displayState->modelviewNavigational);
		
		/* Process all navigational light sources: */
		for(const LightsourceListItem* lsPtr=firstLightsource;lsPtr!=0&&lightIndex<lt->getMaxNumLights();lsPtr=lsPtr->succ)
			{
			if(lsPtr->isEnabled()&&!lsPtr->physical)
				{
				/* Set the light source in the light tracker and OpenGL: */
				lt->enableLight(lightIndex,lsPtr->getLight());
				
				/* Increment the light index: */
				++lightIndex;
				}
			}
		
		/* Return to physical coordinates: */
		glPopMatrix();
		}
	
	/* Disable all unused light sources that might still be enabled from the last pass: */
	while(lightIndex<lt->getMaxNumLights())
		{
		lt->disableLight(lightIndex);
		++lightIndex;
		}
	}