示例#1
0
BOOL Initialize(GL_Window* window, Keys* keys)
{
	srand(GetTickCount());
	
	g_window = window;
	g_keys = keys;
	
	u.keys = keys->keyDown;

	//textures
	glEnable(GL_TEXTURE_2D);// Enable Texture Mapping
	glShadeModel(GL_SMOOTH);


	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);// Black Background
	glClearDepth(1.0f);// Depth Buffer Setup
	glDepthFunc(GL_LEQUAL);									// The Type Of Depth Testing (Less Or Equal)
	glEnable(GL_DEPTH_TEST);									// Enable Depth Testing
	glShadeModel(GL_SMOOTH);									// Select Smooth Shading
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			// Set Perspective Calculations To Most Accurate
		
	GLfloat LightAmbient[] = {0.5f, 0.5f, 0.5f, 1.0f};//Ambient Light Values ( NEW )
	GLfloat LightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};//Diffuse Light Values ( NEW )
	GLfloat LightPosition[] = {0.0f, 0.0f, 2.0f, 1.0f};//Light Position ( NEW )
	

	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);//Setup The Ambient Light	
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);//Setup The Diffuse Light		
	glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);//Position The Light
	
	glEnable(GL_LIGHT1);//Enable Light One

	glEnable(GL_LIGHTING);//Enable Lighting
	

	LoadWorld();
	s.Init();
	s.LoadMap();

	SendUI(&u);
	u.Init(&s, window->hDC);
	
	//BuildFont(window->hDC);
	
	return 1;												// Return TRUE (Initialization Successful)
}