diff --git a/indigo/indigo/src/main/scala/indigo/entry/ScenesFrameProcessor.scala b/indigo/indigo/src/main/scala/indigo/entry/ScenesFrameProcessor.scala index 4b58252f4..565f1378b 100644 --- a/indigo/indigo/src/main/scala/indigo/entry/ScenesFrameProcessor.scala +++ b/indigo/indigo/src/main/scala/indigo/entry/ScenesFrameProcessor.scala @@ -40,7 +40,8 @@ final class ScenesFrameProcessor[StartUpData, Model, ViewModel]( renderer: => Renderer ): Outcome[(Model, ViewModel, SceneUpdateFragment)] = { - val frameContext = new FrameContext[StartUpData](gameTime, dice, inputState, boundaryLocator, startUpData, renderer) + val frameContext = + new FrameContext[StartUpData](gameTime, dice, inputState, boundaryLocator, startUpData, renderer.captureScreen) val processSceneViewModel: (Model, ViewModel) => Outcome[ViewModel] = (m, vm) => globalEvents diff --git a/indigo/indigo/src/main/scala/indigo/entry/StandardFrameProcessor.scala b/indigo/indigo/src/main/scala/indigo/entry/StandardFrameProcessor.scala index aa69539b1..4d4361dad 100644 --- a/indigo/indigo/src/main/scala/indigo/entry/StandardFrameProcessor.scala +++ b/indigo/indigo/src/main/scala/indigo/entry/StandardFrameProcessor.scala @@ -35,7 +35,8 @@ final class StandardFrameProcessor[StartUpData, Model, ViewModel]( boundaryLocator: BoundaryLocator, renderer: => Renderer ): Outcome[(Model, ViewModel, SceneUpdateFragment)] = - val frameContext = new FrameContext[StartUpData](gameTime, dice, inputState, boundaryLocator, startUpData, renderer) + val frameContext = + new FrameContext[StartUpData](gameTime, dice, inputState, boundaryLocator, startUpData, renderer.captureScreen) Outcome.join( for { m <- processModel(frameContext, model, globalEvents) diff --git a/indigo/indigo/src/main/scala/indigo/platform/renderer/Renderer.scala b/indigo/indigo/src/main/scala/indigo/platform/renderer/Renderer.scala index 0d2f07c22..227181efa 100644 --- a/indigo/indigo/src/main/scala/indigo/platform/renderer/Renderer.scala +++ b/indigo/indigo/src/main/scala/indigo/platform/renderer/Renderer.scala @@ -30,19 +30,6 @@ trait Renderer: */ def captureScreen(captureConfig: Batch[ScreenCaptureConfig]): Batch[Either[String, AssetType.Image]] - /** Capture the screen as an image, with the specified configuration - * - * @param captureOption - * The configuration to use when capturing the screen - * @return - * The captured image, or an error message - */ - def captureScreen(captureConfig: ScreenCaptureConfig): Either[String, AssetType.Image] = - captureScreen(Batch(captureConfig)).headOption match { - case Some(v) => v - case None => Left("Could not capture image") - } - object Renderer: def blackHole = new Renderer { def renderingTechnology: RenderingTechnology = RenderingTechnology.WebGL1 diff --git a/indigo/indigo/src/main/scala/indigo/shared/FrameContext.scala b/indigo/indigo/src/main/scala/indigo/shared/FrameContext.scala index 7afd9de0e..f401dd469 100644 --- a/indigo/indigo/src/main/scala/indigo/shared/FrameContext.scala +++ b/indigo/indigo/src/main/scala/indigo/shared/FrameContext.scala @@ -1,6 +1,8 @@ package indigo.shared -import indigo.platform.renderer.Renderer +import indigo.platform.renderer.ScreenCaptureConfig +import indigo.shared.assets.AssetType +import indigo.shared.collections.Batch import indigo.shared.datatypes.Rectangle import indigo.shared.dice.Dice import indigo.shared.events.InputState @@ -31,11 +33,10 @@ final class FrameContext[StartUpData]( val inputState: InputState, val boundaryLocator: BoundaryLocator, _startUpData: => StartUpData, - _renderer: => Renderer + _captureScreen: Batch[ScreenCaptureConfig] => Batch[Either[String, AssetType.Image]] ): - lazy val startUpData = _startUpData - lazy private val renderer = _renderer + lazy val startUpData = _startUpData export gameTime.running export gameTime.delta @@ -44,4 +45,26 @@ final class FrameContext[StartUpData]( export inputState.gamepad export boundaryLocator.findBounds export boundaryLocator.bounds - export renderer.captureScreen + + /** Capture the screen as a number of images, each with the specified configuration + * + * @param captureConfig + * The configurations to use when capturing the screen + * @return + * A batch containing either the captured images, or error messages + */ + def captureScreen(captureConfig: Batch[ScreenCaptureConfig]): Batch[Either[String, AssetType.Image]] = + _captureScreen(captureConfig) + + /** Capture the screen as an image, with the specified configuration + * + * @param captureConfig + * The configuration to use when capturing the screen + * @return + * The captured image, or an error message + */ + def captureScreen(captureConfig: ScreenCaptureConfig): Either[String, AssetType.Image] = + captureScreen(Batch(captureConfig)).headOption match { + case Some(v) => v + case None => Left("Could not capture image") + } diff --git a/indigo/indigo/src/main/scala/indigo/shared/subsystems/SubSystemFrameContext.scala b/indigo/indigo/src/main/scala/indigo/shared/subsystems/SubSystemFrameContext.scala index 1af40b0e8..794a500d1 100644 --- a/indigo/indigo/src/main/scala/indigo/shared/subsystems/SubSystemFrameContext.scala +++ b/indigo/indigo/src/main/scala/indigo/shared/subsystems/SubSystemFrameContext.scala @@ -54,7 +54,7 @@ final case class SubSystemFrameContext[ReferenceData]( inputState, boundaryLocator, (), - Renderer.blackHole + Renderer.blackHole.captureScreen ) object SubSystemFrameContext {