Global Light problem

I’m trying to change the global light. But all changes I do to the rgb and intensity of the light have no effect :sorrow:

Any ideas? All help much appreciated.

This is part of a larger project so I’ll try to just post the important code. If some more is needed just ask :slight_smile:

The code I’m using (in DrawWorld) for it is


	glEnable(GL_LIGHTING);
	glShadeModel(GL_SMOOTH);

	GLfloat global_ambient[4] = { 0.5f, 0.0f, 1.0f, 0.5f };
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);

My main function is

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	glutInitWindowPosition (100, 100);
	glutCreateWindow("Car Race");
	glutDisplayFunc(HandleDisplayCallback);
	glutTimerFunc(SECONDS_PER_FRAME, HandleTimerCallback, GLUT_VISIBLE);
	glutReshapeFunc(HandleReshapeCallback);
	glutIgnoreKeyRepeat(GL_TRUE);
	glutKeyboardFunc(HandleKeyboadKeyDownCallback);
	glutKeyboardUpFunc(HandleKeyboadKeyUpCallback);
	glutSpecialFunc(HandleKeyboadSpecialKeyDownCallback);
	glutSpecialUpFunc(HandleKeyboadSpecialKeyUpCallback);
	world = new World();
	glutMainLoop();
	delete world;
	return 0;
}

My HandleDisplayCallback is

void HandleDisplayCallback()
{
	ConfigureViewportMain();
	DrawWorld();
	glutSwapBuffers();
}

And my DrawWorld is

void DrawWorld()
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearDepth(1.0f);


	glEnable(GL_LIGHTING);
	glShadeModel(GL_SMOOTH);

	GLfloat global_ambient[4] = { 0.5f, 0.0f, 1.0f, 0.5f };
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);


	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	world->Draw();
}

if i am not wrong you can use something like this
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);

glLightfv( GL_LIGHT0, GL_AMBIENT,
amb);
glLightfv( GL_LIGHT0, GL_POSITION,
pos);
//Material->Object like triangle etc etx
glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE,
dif);
glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, shi);

position of light can be good as at sun position(by your self)
and

if your game get completed send it to me pleeeeeeeeeeeeeeeeeeeeeeeeeeeease