/////////////////////
//GLUT Callback 関数
/////////////////////
////////////
//gl.Idle()
////////////
void gl_Idle() {

	gl.ReDisp();		//再描画命令
}

///////////////
//gl.Display()
///////////////
void gl_Display() {

	const static GLfloat material_ambient[4] = {0.24725, 0.1995, 0.0745, 1.0};		//質感設定（初期値−0.2 , 0.2 , 0.2 , 1)
	const static GLfloat material_diffuse[4] = {0.75164, 0.60648, 0.22648, 1.0};	//質感設定（初期値−0.8 , 0.8 , 0.8 , 1)
	const static GLfloat material_specular[4] = {0.24725, 0.1995, 0.0745, 1.0};		//質感設定（初期値−0 , 0 , 0, 1)
	const static GLfloat material_shininess = 48;

	gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	//ウィンドウを塗りつぶす
	glMatrixMode(GL_MODELVIEW);		//描画コマンド設定(https://learn.microsoft.com/ja-jp/windows/win32/opengl/glmatrixmode)
	glLoadIdentity();				//視点の変換行列の初期化

	if(g_light) {
		glLightfv(g_lightno[g_selected], GL_POSITION, g_lightpos);						//光源の位置を設定
		glLightfv(g_lightno[g_selected], g_kind[g_selected], g_lightcolor[g_selected]);	//RGBA強度設定
	}
	else {
		gl.Color(g_Red, g_Green, g_Blue, g_Alpha);	//色の設定(R, G, B, A = 1.0)
	}

	glPushMatrix();
		gl.Rotate(g_r, g_x, g_y, g_z);
		if(g_light) {
			glMaterialfv(GL_FRONT, GL_AMBIENT, material_ambient);
			glMaterialfv(GL_FRONT, GL_SPECULAR, material_specular);
			glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse);
			glMaterialf(GL_FRONT, GL_SHININESS, material_shininess);
		}
		gl.DrawObject();			//3Dオブジェクトの描画
	glPopMatrix();
	glFlush();						//バッファー コマンド実行と開放
	 glutSwapBuffers();				//バッファを交換
	if(g_rotate) {					//常時回転フラグ
		g_r += 0.1;
		if(g_r >= 360.0)
			g_r = 0.0;
	}
}

///////////////
//gl.Reshape()
///////////////
void gl_Resize(int w, int h) {

	gl.Resize(w, h);
}
