|
CeresEngine 0.2.0
A game development framework
|
An object that represents a graphics context. More...
#include <CeresEngine/Graphics/GraphicsContext.hpp>
Public Member Functions | |
| GraphicsContext (GraphicsCommandBuffer &commandBuffer, const AffineTransform &transform=AffineTransform()) | |
| GraphicsContext (GraphicsContext &parent, const AffineTransform &transform=AffineTransform()) | |
| void | setClipRect (const Rect2 &area) |
| Defines the area that will be clipped by subsequent draw calls. | |
| void | resetClipRect () |
| Resets the clip rect area. | |
| void | clear (const Rect2 &target, const Color &color=Color::zero) |
Clears the given target region with the given color. | |
| void | drawOverlay (const Rect2 &area) |
| Draws an overlay that helps debugging views. | |
| void | draw (const HTexture &texture, const Rect2 &rect, const Color &tintColor=Color::white) |
| Renders an texture within the given graphics context. | |
| void | draw (const TexturePtr &texture, const Rect2 &rect, const Color &tintColor=Color::white) |
| Renders an texture within the given graphics context. | |
| void | draw (const Shape &shape) |
| Draws a shape within the given graphics context. | |
| void | draw (Shape &&shape) |
| Draws a shape within the given graphics context. | |
| void | fill (BezierPath &&path, const Paint &paint, Shape::BlendMode blendMode=Shape::BlendMode::Normal) |
Paints the region enclosed by the path. | |
| void | fill (const BezierPath &path, const Paint &paint, Shape::BlendMode blendMode=Shape::BlendMode::Normal) |
Paints the region enclosed by the path. | |
| void | stroke (BezierPath &&path, const Paint &paint, double lineWidth=1.0, Shape::BlendMode blendMode=Shape::BlendMode::Normal, Shape::LineCapStyle lineCapStyle=Shape::LineCapStyle::Butt, Shape::LineJoinStyle lineJoinStyle=Shape::LineJoinStyle::Miter, double miterLimit=10.0) |
Draws a line along the path using the given stroke color and drawing attributes. | |
| void | stroke (const BezierPath &path, const Paint &paint, double lineWidth=1.0, Shape::BlendMode blendMode=Shape::BlendMode::Normal, Shape::LineCapStyle lineCapStyle=Shape::LineCapStyle::Butt, Shape::LineJoinStyle lineJoinStyle=Shape::LineJoinStyle::Miter, double miterLimit=10.0) |
Draws a line along the path using the given stroke color and drawing attributes. | |
| void | draw (TextLayoutManager &layoutManager, Vector2 offset=Vector2(0.0), const Color &tintColor=Color::white) |
| Draws a text within the given graphics context. | |
| void | draw (RawGraphicsCommand::Command &&command) |
| Submits a custom command that will be run by the renderer before a new frame recording begins. | |
Public Attributes | |
| AnyAllocatorReference | allocator |
| The allocator the user can use to amortize the cost the allocating memory for either temporary allocations or for data that will be stored inside the graphics context command buffer. | |
| GraphicsCommandBuffer & | mCommandBuffer |
| The render context object. | |
| GraphicsContext * | mParent = nullptr |
| If this is a sub-view, points to the graphics context of the parent view. | |
| GraphicsState | mState |
| A structure that contains the graphics state for the context. | |
An object that represents a graphics context.
You can think of a graphics context as a destination to which drawing and graphics state operations are sent for execution. Each graphics context contains its own graphics environment and state.
The Graphics Context is created uniquely for each UIView and all draw calls are issued on the view coordinate system. If necessary, the graphics context will perform any necessary coordinate system conversion that might be necessary to render the requested element.
Each UIView::draw method will receive a new GraphicsContext instance that it should use to fill commands necessary for rendering it`s visual elements.
|
explicit |
|
explicit |
| void CeresEngine::GraphicsContext::clear | ( | const Rect2 & | target, |
| const Color & | color = Color::zero |
||
| ) |
Clears the given target region with the given color.
| target | The target area do be cleared. |
| color | The color to be written over the cleared area. |
|
inline |
Renders an texture within the given graphics context.
| texture | The texture to be drawn. This texture will be uploaded to the GPU, then sent to a shader and sampled from the GPU while rendering the . |
| rect | The rectangle that represents the size and position the texture should be drawn to. |
| tintColor | An optional tint color to apply to the sampled texture. Allows easy color changing the . |
Draws a shape within the given graphics context.
The shape must be in the view's coordinate space, and the system will automatically convert the shape to the appropriate coordinate space upon drawing.
| shape | A shape to be drawn on the graphics context. |
| void CeresEngine::GraphicsContext::draw | ( | const TexturePtr & | texture, |
| const Rect2 & | rect, | ||
| const Color & | tintColor = Color::white |
||
| ) |
Renders an texture within the given graphics context.
| texture | The texture to be drawn. This texture will be uploaded to the GPU, then sent to a shader and sampled from the GPU while rendering the . |
| rect | The rectangle that represents the size and position the texture should be drawn to. |
| tintColor | An optional tint color to apply to the sampled texture. Allows easy color changing the . |
| void CeresEngine::GraphicsContext::draw | ( | RawGraphicsCommand::Command && | command | ) |
Submits a custom command that will be run by the renderer before a new frame recording begins.
Can be used to submit generic draw commands like a scene draw.
Draws a shape within the given graphics context.
The shape must be in the view's coordinate space, and the system will automatically convert the shape to the appropriate coordinate space upon drawing.
| shape | A shape to be drawn on the graphics context. |
| void CeresEngine::GraphicsContext::draw | ( | TextLayoutManager & | layoutManager, |
| Vector2 | offset = Vector2(0.0), |
||
| const Color & | tintColor = Color::white |
||
| ) |
Draws a text within the given graphics context.
| layoutManager | The layout manager that contains the laidout text. |
| offset | An offset to be applied to the text rendering. |
| tintColor | A tint color to be applied to the entire text. |
Draws an overlay that helps debugging views.
| area | The area over which the debug overlay should be drawn on. |
| void CeresEngine::GraphicsContext::fill | ( | BezierPath && | path, |
| const Paint & | paint, | ||
| Shape::BlendMode | blendMode = Shape::BlendMode::Normal |
||
| ) |
Paints the region enclosed by the path.
This method fills the path using the given fill color and the receiver's current winding rule. If the path contains any open subpaths, this method implicitly closes them before painting the fill region.
The painted region includes the pixels right up to, but not including, the path line itself. For paths with large line widths, this can result in overlap between the fill region and the stroked path (which is itself centered on the path line).
| path | The path to be filled. |
| paint | The color to fill the path with. |
| void CeresEngine::GraphicsContext::fill | ( | const BezierPath & | path, |
| const Paint & | paint, | ||
| Shape::BlendMode | blendMode = Shape::BlendMode::Normal |
||
| ) |
Paints the region enclosed by the path.
This method fills the path using the given fill color and the receiver's current winding rule. If the path contains any open subpaths, this method implicitly closes them before painting the fill region.
The painted region includes the pixels right up to, but not including, the path line itself. For paths with large line widths, this can result in overlap between the fill region and the stroked path (which is itself centered on the path line).
| path | The path to be filled. |
| paint | The color to fill the path with. |
| void CeresEngine::GraphicsContext::resetClipRect | ( | ) |
Resets the clip rect area.
Defines the area that will be clipped by subsequent draw calls.
| area | The area to be clipped. |
| void CeresEngine::GraphicsContext::stroke | ( | BezierPath && | path, |
| const Paint & | paint, | ||
| double | lineWidth = 1.0, |
||
| Shape::BlendMode | blendMode = Shape::BlendMode::Normal, |
||
| Shape::LineCapStyle | lineCapStyle = Shape::LineCapStyle::Butt, |
||
| Shape::LineJoinStyle | lineJoinStyle = Shape::LineJoinStyle::Miter, |
||
| double | miterLimit = 10.0 |
||
| ) |
Draws a line along the path using the given stroke color and drawing attributes.
The drawn line is centered on the path with its sides parallel to the path segment. This method uses the current drawing attributes associated with the receiver. If a particular attribute is not set for the receiver, this method uses the corresponding default attribute.
| path | The path to be stroked. |
| paint | The paint to stroke the path with. |
| void CeresEngine::GraphicsContext::stroke | ( | const BezierPath & | path, |
| const Paint & | paint, | ||
| double | lineWidth = 1.0, |
||
| Shape::BlendMode | blendMode = Shape::BlendMode::Normal, |
||
| Shape::LineCapStyle | lineCapStyle = Shape::LineCapStyle::Butt, |
||
| Shape::LineJoinStyle | lineJoinStyle = Shape::LineJoinStyle::Miter, |
||
| double | miterLimit = 10.0 |
||
| ) |
Draws a line along the path using the given stroke color and drawing attributes.
The drawn line is centered on the path with its sides parallel to the path segment. This method uses the current drawing attributes associated with the receiver. If a particular attribute is not set for the receiver, this method uses the corresponding default attribute.
| path | The path to be stroked. |
| paint | The paint to stroke the path with. |
| AnyAllocatorReference CeresEngine::GraphicsContext::allocator |
The allocator the user can use to amortize the cost the allocating memory for either temporary allocations or for data that will be stored inside the graphics context command buffer.
| GraphicsCommandBuffer& CeresEngine::GraphicsContext::mCommandBuffer |
The render context object.
Recorded commands will be included into this context for rendering later.
| GraphicsContext* CeresEngine::GraphicsContext::mParent = nullptr |
If this is a sub-view, points to the graphics context of the parent view.
This may not be set, for instance if doing a partial redraw on an opaque view or if a view that performs internal caching of the contents.
| GraphicsState CeresEngine::GraphicsContext::mState |
A structure that contains the graphics state for the context.