void RenderScene(void) {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	glEnable( GL_DEPTH_TEST ) ;
	glUseProgram(shader);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	float angle = timer.GetElapsedSeconds();

	M3DVector3f eye = {cos(angle)*4.0f,sin(angle)*4.0,sin(angle)*4.0f}; 
	M3DVector3f at = {0,0,0}; 
	M3DVector3f up = {0.0f,0.0f,1.0f};

	GLFrame cameraFrame;
	LookAt(cameraFrame, eye, at, up);
	cameraFrame.GetCameraMatrix(cameraMatrix);
	
	m3dMatrixMultiply44(matrix, viewFrustum.GetProjectionMatrix(), cameraMatrix);

	M3DMatrix44f tMatrix;
	m3dTranslationMatrix44(tMatrix, 0, 0, 0);
	m3dMatrixMultiply44(matrix, tMatrix, matrix);

	if((sin(angle) < 0 && sin(angle-0.003) > 0) || (sin(angle) > 0 && sin(angle-0.003) < 0)) {
		debugMatrix44(matrix);
	}

	glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrix);

//	drawGrid(0.1);
	drawPyramid();

	glutSwapBuffers();
	glutPostRedisplay();
}
void RenderScence(void)
{

	static CStopWatch rotTimer;
	float yRot = rotTimer.GetElapsedSeconds() * 60.0f;//每秒旋转60度?

	//Clear the window and the depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	M3DMatrix44f mTranslate, mRotate, mModelView, mModelViewProjection;

	//生成一个平移矩阵,用于将花环移回视野中,有个问题,1.0f会是什么效果?1.0会看不见花托。有可能截头体是世界坐标1.0-1000.0f是指距离camera的。所以此矩阵是相对于摄像机的操作,移到摄像机面前2.5f深度距离处
	//即摄像机所在的地方为原点(0,0,0)
	m3dTranslationMatrix44(mTranslate, 0.0f, 0.0f, -2.5f);

	//生成旋转矩阵 以y为轴,旋转时间t产生的旋转角 yRot
	m3dRotationMatrix44(mRotate, m3dDegToRad(yRot), 0.0f, 1.0f, 0.0f);

	//组合为模型变换矩阵,而原模型矩阵在最右边,即先旋转再平移 ?
	m3dMatrixMultiply44(mModelView, mTranslate, mRotate);

	//组合成模型投影矩阵,而原模型矩阵在最右边,先做模型变换再投影 ?
	m3dMatrixMultiply44(mModelViewProjection, viewFrustum.GetProjectionMatrix(), mModelView);

	GLfloat vBlack[] = { 1.0f, 1.0f, 1.0f, 1.0f };

	//选择要配置的渲染操作类型,非smooth,每种模式对应的参数要熟悉才能正确使用
	shaderManger.UseStockShader(GLT_SHADER_FLAT, mModelViewProjection, vBlack);//黑色背景?不是,是设置当前画笔颜色

	torusBatch.Draw();

	glutSwapBuffers();

	glutPostRedisplay();

	//整个流程是:先旋转在平移,然后进行投影剪裁,最后光栅化。UseStockShader 和draw函数之前的变换管线还是不清晰
}