This shows you the differences between two versions of the page.
gamedev:canvassysten:capture [2015/06/17 23:44] – created dragonlord | gamedev:canvassysten:capture [2015/06/17 23:46] (current) – removed dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | gamedev: | ||
- | <WRAP youarehere> | ||
- | [[: | ||
- | </ | ||
- | |||
- | ====== Capture Canvas ====== | ||
- | Render of graphics modules is allowed to be asynchronous and for performance reasons this is usually the case. This has implications for handling capturing of canvas. All kinds of off-screen rendering inside the graphic module is handled by the graphic module in whatever way it sees fitting. If the game scripts desire though to obtain a screenshot for example the data crosses the influence sphere of the graphic module. For this reason capturing a canvas has to be done using [[http:// | ||
- | |||
- | ====== Capture Process ====== | ||
- | Capturing using this class is a two-phase process. First and formost you can create and store a capture canvas to use it only when needed. It is not required to time the creation of capture canvas since capturing is only started if all requirements are set. To start a capture set the [[http:// | ||
- | |||
- | The following code snippet shows the basic flow: | ||
- | |||
- | < | ||
- | // during frame update called by the game engine | ||
- | |||
- | // if the capturing finished | ||
- | if not captureRequest.getCapture() ) | ||
- | // do something with captureRequest.getImage() | ||
- | end | ||
- | |||
- | // do your frame update | ||
- | |||
- | // do we have a capture request? | ||
- | if doCaptureCanvas | ||
- | // start capture canvas | ||
- | captureRequest.setCanvas( canvasToCapture ) | ||
- | captureRequest.setImage( canvasToCapture.getWidth(), | ||
- | captureRequest.setCapture( true ) | ||
- | end | ||
- | </ | ||
- | |||
- | ====== Screenshot Creator (DragonScript) ====== | ||
- | The DragonScript module simplifies this process of creating a screenshot by providing the [[http:// | ||
- | |||
- | < | ||
- | // during initialization time | ||
- | var ScreenshotCreator screenshotCreator = ScreenshotCreator.new() | ||
- | screenshotCreator.setConsole( gameConsole ) // for logging purpose | ||
- | |||
- | // during frame update called by the game engine | ||
- | screenshotCreator.update() | ||
- | |||
- | // to request a screenshot somewhere in the game scripts | ||
- | screenshotCreator.takeScreenshot() | ||
- | |||
- | // once done the screenshit will be saved as < | ||
- | </ | ||