2D camera that defines what region is shown on screen
View defines a camera in the 2D scene.
This is a very powerful concept: you can scroll, rotate or zoom the entire scene without altering the way that your drawable objects are drawn.
A view is composed of a source rectangle, which defines what part of the 2D scene is shown, and a target viewport, which defines where the contents of the source rectangle will be displayed on the render target (window or texture).
The viewport allows to map the scene to a custom part of the render target, and can be used for split-screen or for displaying a minimap, for example. If the source rectangle doesn't have the same size as the viewport, its contents will be stretched to fit in.
The scissor rectangle allows for specifying regions of the render target to which modifications can be made by draw and clear operations. Only pixels that are within the region will be able to be modified. Pixels outside of the region will not be modified by draw or clear operations.
Certain effects can be created by either using the viewport or scissor rectangle. While the results appear identical, there can be times where one method should be preferred over the other. Viewport transformations are applied during the vertex processing stage of the graphics pipeline, before the primitives are rasterized into fragments for fragment processing. Since viewport processing has to be performed and cannot be disabled, effects that are performed using the viewport transform are basically free performance-wise. Scissor testing is performed in the per-sample processing stage of the graphics pipeline, after fragment processing has been performed. Because per-sample processing is performed at the last stage of the pipeline, fragments that are discarded at this stage will cause the highest waste of GPU resources compared to any method that would have discarded vertices or fragments earlier in the pipeline. There are situations in which scissor testing has to be used to control whether fragments are discarded or not. An example of such a situation is when performing the viewport transform on vertices is necessary but a subset of the generated fragments should not have an effect on the stencil buffer or blend with the color buffer.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any