Ejemplo n.º 1
0
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	glTranslatef(trans.x, trans.y, trans.z);
	glRotatef(rot.x, 1.0f, 0.0f, 0.0f);
	glRotatef(rot.y, 0.0f, 1.0f, 0.0f);
	glRotatef(rot.z, 0.0f, 0.0f, 1.0f);
	glPushMatrix();
	glScalef(50.0f, 30.0f, 40.0f);
	glutWireCube(1.0f);
	glPopMatrix();

	solver.Update();
	i++;
	//cout << i << endl;

	float3* temp = solver.GetPos();

	for (int index = 0; index < 16 * 1024; index++)
	{
		glPushMatrix();
		glTranslatef(temp[index].x-25.0f, temp[index].y-15.0f, temp[index].z-20.0f);
		glutSolidSphere(0.5f, 10, 10);
		glPopMatrix();
	}

	st = clock();

	float dura = float(st - en) / 1000.0f;

	//cout << dura << endl;

	en = st;

	//char fname[12];
	//sprintf(fname, "%d.jpg", cycle);

	//SaveBMPFromOpenGl(fname);

	char text[32];
	sprintf_s(text, "The frame is %f: ", 1.0f / dura);
	glutSetWindowTitle(text);

	glutSwapBuffers();
}