Class for 2D drawing in screen space. More...
#include <IDraw2d.h>
Inherited by CDraw2d.
Classes | |
struct | ImageOptions |
Struct used to pass additional image options. More... | |
struct | RenderState |
struct | TextOptions |
Struct used to pass additional text options - mostly ones that do not change from call to call. More... | |
struct | VertexPosColUV |
Used to pass in arrays of vertices (e.g. to DrawQuad) More... | |
Public Types | |
enum class | HAlign { Left , Center , Right } |
Horizontal alignment can be used for both text and image drawing. | |
enum class | VAlign { Top , Center , Bottom } |
Vertical alignment can be used for both text and image drawing. | |
enum class | Rounding { None , Nearest , Down , Up } |
Used for specifying how to round positions to an exact pixel position for pixel-perfect rendering. | |
enum | { MAX_TEXT_STRING_LENGTH = 1024 } |
Public Member Functions | |
virtual | ~IDraw2d () |
Implement virtual destructor just for safety. | |
virtual void | DrawImage (AZ::Data::Instance< AZ::RPI::Image > image, AZ::Vector2 position, AZ::Vector2 size, float opacity=1.0f, float rotation=0.0f, const AZ::Vector2 *pivotPoint=nullptr, const AZ::Vector2 *minMaxTexCoords=nullptr, ImageOptions *imageOptions=nullptr)=0 |
Draw a textured quad with the top left corner at the given position. | |
virtual void | DrawImageAligned (AZ::Data::Instance< AZ::RPI::Image > image, AZ::Vector2 position, AZ::Vector2 size, HAlign horizontalAlignment, VAlign verticalAlignment, float opacity=1.0f, float rotation=0.0f, const AZ::Vector2 *minMaxTexCoords=nullptr, ImageOptions *imageOptions=nullptr)=0 |
Draw a textured quad where the position specifies the point specified by the alignment. | |
virtual void | DrawQuad (AZ::Data::Instance< AZ::RPI::Image > image, VertexPosColUV *verts, Rounding pixelRounding=Rounding::Nearest, bool clamp=false, const RenderState &renderState=RenderState{})=0 |
Draw a textured quad where the position, color and uv of each point is specified explicitly. | |
virtual void | DrawLine (AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, IDraw2d::Rounding pixelRounding=IDraw2d::Rounding::Nearest, const RenderState &renderState=RenderState{})=0 |
Draw a line. | |
virtual void | DrawLineTextured (AZ::Data::Instance< AZ::RPI::Image > image, VertexPosColUV *verts, IDraw2d::Rounding pixelRounding=IDraw2d::Rounding::Nearest, const RenderState &renderState=RenderState{})=0 |
Draw a line with a texture so it can be dotted or dashed. | |
virtual void | DrawText (const char *textString, AZ::Vector2 position, float pointSize, float opacity=1.0f, TextOptions *textOptions=nullptr)=0 |
Draw a text string. Only supports ASCII text. | |
virtual void | DrawRectOutlineTextured (AZ::Data::Instance< AZ::RPI::Image > image, UiTransformInterface::RectPoints points, AZ::Vector2 rightVec, AZ::Vector2 downVec, AZ::Color color, uint32_t lineThickness=0)=0 |
Draw a rectangular outline with a texture. | |
virtual AZ::Vector2 | GetTextSize (const char *textString, float pointSize, TextOptions *textOptions=nullptr)=0 |
Get the width and height (in pixels) that would be used to draw the given text string. | |
virtual float | GetViewportWidth () const =0 |
Get the width of the rendering viewport (in pixels). | |
virtual float | GetViewportHeight () const =0 |
Get the height of the rendering viewport (in pixels). | |
virtual float | GetViewportDpiScalingFactor () const =0 |
Get dpi scale factor. | |
virtual const ImageOptions & | GetDefaultImageOptions () const =0 |
Get the default values that would be used if no image options were passed in. | |
virtual const TextOptions & | GetDefaultTextOptions () const =0 |
Get the default values that would be used if no text options were passed in. | |
virtual void | RenderDeferredPrimitives ()=0 |
Render the primitives that have been deferred. | |
virtual void | SetDeferPrimitives (bool deferPrimitives)=0 |
Specify whether to defer future primitives or render them right away. | |
virtual bool | GetDeferPrimitives ()=0 |
Return whether future primitives will be deferred or rendered right away. | |
virtual void | SetSortKey (int64_t key)=0 |
Set sort key offset for following draws. | |
Class for 2D drawing in screen space.
The IDraw2d interface allows drawing images and text in 2D. Positions and sizes are specified in pixels in the current 2D viewport. The BeginDraw2d method should be called before calling the Draw methods to enter 2D mode and the EndDraw2d method should be called after calling the Draw methods to exit 2D mode. There is a helper class Draw2dHelper that encapsulates this in its constructor and destructor.
anonymous enum |
|
pure virtual |
Draw a textured quad with the top left corner at the given position.
The image is drawn with the color specified by SetShapeColor and the opacity passed as an argument. If rotation is non-zero then the quad is rotated. If the pivot point is provided then the points of the quad are rotated about that point, otherwise they are rotated about the top left corner of the quad.
texId | The texture ID returned by ITexture::GetTextureID() |
position | Position of the top left corner of the quad (before rotation) in pixels |
size | The width and height of the quad. Use texture width and height to avoid minification, magnification or stretching (assuming the minMaxTexCoords are left to the default) |
opacity | The alpha value used when blending |
rotation | Angle of rotation in degrees counter-clockwise |
pivotPoint | The point about which the quad is rotated |
minMaxTexCoords | An optional two component array. The first component is the UV coord for the top left point of the quad and the second is the UV coord of the bottom right point of the quad |
imageOptions | Optional struct specifying options that tend to be the same from call to call |
Implemented in CDraw2d.
|
pure virtual |
Draw a textured quad where the position specifies the point specified by the alignment.
Rotation is always around the position.
texId | The texture ID returned by ITexture::GetTextureID() |
position | Position align point of the quad (before rotation) in pixels |
size | The width and height of the quad. Use texture width and height to avoid minification, magnification or stretching (assuming the minMaxTexCoords are left to the default) |
horizontalAlignment | Specifies how the quad is horizontally aligned to the given position |
verticalAlignment | Specifies how the quad is vertically aligned to the given position |
opacity | The alpha value used when blending |
rotation | Angle of rotation in degrees counter-clockwise |
minMaxTexCoords | An optional two component array. The first component is the UV coord for the top left point of the quad and the second is the UV coord of the bottom right point of the quad |
imageOptions | Optional struct specifying options that tend to be the same from call to call |
Implemented in CDraw2d.
|
pure virtual |
Draw a line.
start | The start position |
end | The end position |
color | The color of the line |
pixelRounding | Whether and how to round pixel coordinates |
renderState | Blend mode and depth state |
Implemented in CDraw2d.
|
pure virtual |
Draw a line with a texture so it can be dotted or dashed.
texId | The texture ID returned by ITexture::GetTextureID() |
verts | An array of 2 vertices for the start and end points of the line |
pixelRounding | Whether and how to round pixel coordinates |
renderState | Blend mode and depth state |
Implemented in CDraw2d.
|
pure virtual |
Draw a textured quad where the position, color and uv of each point is specified explicitly.
texId | The texture ID returned by ITexture::GetTextureID() |
verts | An array of 4 vertices, in clockwise order (e.g. top left, top right, bottom right, bottom left) |
pixelRounding | Whether and how to round pixel coordinates |
renderState | Blend mode and depth state |
Implemented in CDraw2d.
|
pure virtual |
Draw a rectangular outline with a texture.
image | The texture to be used for drawing the outline |
points | The rect's vertices (top left, top right, bottom right, bottom left) |
rightVec | Right vector. Specified because the rect's width/height could be 0 |
downVec | Down vector. Specified because the rect's width/height could be 0 |
color | The color of the outline |
lineThickness | The thickness in pixels of the outline. If 0, it will be based on image height |
Implemented in CDraw2d.
|
pure virtual |
Draw a text string. Only supports ASCII text.
The font and effect used to render the text are specified in the textOptions structure
textString | A null terminated ASCII text string. May contain characters |
position | Position of the text in pixels. Alignment values in textOptions affect actual position |
pointSize | The size of the font to use |
opacity | The opacity (alpha value) to use to draw the text |
textOptions | Pointer to an options struct. If null the default options are used |
Implemented in CDraw2d.
|
pure virtual |
Get the default values that would be used if no image options were passed in.
This is a convenient way to initialize the imageOptions struct
Implemented in CDraw2d.
|
pure virtual |
Get the default values that would be used if no text options were passed in.
This is a convenient way to initialize the textOptions struct
Implemented in CDraw2d.
|
pure virtual |
Return whether future primitives will be deferred or rendered right away.
Implemented in CDraw2d.
|
pure virtual |
Get the width and height (in pixels) that would be used to draw the given text string.
Pass the same parameter values that would be used to draw the string
Implemented in CDraw2d.
|
pure virtual |
Get dpi scale factor.
Implemented in CDraw2d.
|
pure virtual |
Get the height of the rendering viewport (in pixels).
Implemented in CDraw2d.
|
pure virtual |
Get the width of the rendering viewport (in pixels).
Implemented in CDraw2d.
|
pure virtual |
Render the primitives that have been deferred.
Implemented in CDraw2d.
|
pure virtual |
Specify whether to defer future primitives or render them right away.
Implemented in CDraw2d.
|
pure virtual |
Set sort key offset for following draws.
Implemented in CDraw2d.