public static void DrawRotatingObject <TPipeline, TCamera>(TPipeline pipeline, RenderEntity[] entitiesApply, TCamera camera, CharRenderBuffer <float> charBuffer) where TPipeline : IPipeline where TCamera : ICamera { float framerate = 60f; float time = 6f; int totalFrame = (int)(framerate * time); float angleStep = JMath.PI_TWO / totalFrame; int frameInterval = (int)(1000f / framerate); int elapsed; JTimer timer = new JTimer(); timer.Start(); for (int i = 0; i < totalFrame; i++) { CRenderer.UpdateRenderInfo(); pipeline.Draw(entitiesApply, camera); entitiesApply[0].Transform.Rotation.X += angleStep; entitiesApply[0].Transform.Rotation.Z += angleStep; elapsed = (int)timer.DeltaMS; if (elapsed < frameInterval) { Thread.Sleep(frameInterval - elapsed); } CRenderer.Render(charBuffer); } timer.Stop(); }
public static void DrawOneFrame <TPipeline, TCamera>(TPipeline pipeline, RenderEntity[] entitiesApply, TCamera camera, CharRenderBuffer <float> charBuffer) where TPipeline : IPipeline where TCamera : ICamera { CRenderer.UpdateRenderInfo(); pipeline.Draw(entitiesApply, camera); CRenderer.Render(charBuffer); }