/// <summary> /// Ajaa yhden päivityksen ja tallentaa ruudun tiedostoon. /// </summary> /// <param name="bmpOutName">Bmp file to write to.</param> public void RunOneFrame(string bmpOutName) { //base.RunOneFrame(); Screencap.SaveBmp(bmpOutName); OnExiting(this, EventArgs.Empty); //UnloadContent(); Exit(); }
/// <summary> /// Ajaa yhden päivityksen ja tallentaa ruudun tiedostoon. /// </summary> /// <param name="bmpOutName">Bmp file to write to.</param> public void RunOneFrame(string bmpOutName) { base.RunOneFrame(); FileStream screenFile = new FileStream(bmpOutName, FileMode.Create); Screencap.WriteBmp(screenFile, Screen.Image); screenFile.Close(); OnExiting(this, EventArgs.Empty); UnloadContent(); Exit(); }
protected void Draw(Time gameTime) { UpdateFps(gameTime); GraphicsDevice.SetRenderTarget(Screen.RenderTarget); GraphicsDevice.Clear(Level.BackgroundColor); if (Level.Background.Image != null && !Level.Background.MovesWithCamera) { GraphicsDevice.BindTexture(Level.Background.Image); Graphics.BasicTextureShader.Use(); Graphics.BasicTextureShader.SetUniform("world", Matrix.Identity); GraphicsDevice.DrawPrimitives(Rendering.PrimitiveType.OpenGlTriangles, Graphics.TextureVertices, 6, true); } // The world matrix adjusts the position and size of objects according to the camera angle. var worldMatrix = Matrix.CreateTranslation((float)-Camera.Position.X, (float)-Camera.Position.Y, 0) * Matrix.CreateScale((float)Camera.ZoomFactor, (float)Camera.ZoomFactor, 1f); // If the background should move with camera, draw it here. Level.Background.Draw(worldMatrix, Matrix.Identity); // Draw the layers containing the GameObjects DynamicLayers.ForEach(l => l.Draw(Camera)); // TODO: Tätä ei tarvitsisi tehdä, jos valoja ei käytetä. // Yhdistetään valotekstuuri ja objektien tekstuuri. GraphicsDevice.DrawLights(worldMatrix); // Piirretään käyttöliittymäkomponentit valojen päälle StaticLayers.ForEach(l => l.Draw(Camera)); // Draw on the canvas Graphics.Canvas.Begin(ref worldMatrix, Level); Paint(Graphics.Canvas); Graphics.Canvas.End(); // Draw the debug information screen DrawDebugScreen(); // Render the scene on screen Screen.Render(); if (SaveOutput) { if (FrameCounter != 0) // Ekaa framea ei voi tallentaa? { if (skipcounter == 0) { Screencap.SaveBmp(CurrentFrameStream); skipcounter = FramesToSkip; SavedFrameCounter++; } else { skipcounter--; } } } if (TotalFramesToRun != 0 && FrameCounter == TotalFramesToRun) { OnExiting(this, EventArgs.Empty); //UnloadContent(); Exit(); } FrameCounter++; }