Open 3D Engine LyShine Gem API Reference
24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
|
Implementation of IDraw2d interface for 2D drawing in screen space. More...
#include <Draw2d.h>
Inherits IDraw2d, and AZ::Render::Bootstrap::NotificationBus::Handler.
Classes | |
class | DeferredLine |
class | DeferredPrimitive |
class | DeferredQuad |
class | DeferredRectOutline |
class | DeferredText |
struct | Draw2dShaderData |
Public Member Functions | |
CDraw2d (AZ::RPI::ViewportContextPtr viewportContext=nullptr) | |
Constructor, constructed by the LyShine class. | |
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) override |
Draw a textured quad with the top left corner at the given position. More... | |
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) override |
Draw a textured quad where the position specifies the point specified by the alignment. More... | |
void | DrawQuad (AZ::Data::Instance< AZ::RPI::Image > image, VertexPosColUV *verts, Rounding pixelRounding=Rounding::Nearest, bool clamp=false, const RenderState &renderState=RenderState{}) override |
Draw a textured quad where the position, color and uv of each point is specified explicitly. More... | |
void | DrawLine (AZ::Vector2 start, AZ::Vector2 end, AZ::Color color, IDraw2d::Rounding pixelRounding=IDraw2d::Rounding::Nearest, const RenderState &renderState=RenderState{}) override |
Draw a line. More... | |
void | DrawLineTextured (AZ::Data::Instance< AZ::RPI::Image > image, VertexPosColUV *verts, IDraw2d::Rounding pixelRounding=IDraw2d::Rounding::Nearest, const RenderState &renderState=RenderState{}) override |
Draw a line with a texture so it can be dotted or dashed. More... | |
void | DrawText (const char *textString, AZ::Vector2 position, float pointSize, float opacity=1.0f, TextOptions *textOptions=nullptr) override |
Draw a text string. Only supports ASCII text. More... | |
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) override |
Draw a rectangular outline with a texture. More... | |
AZ::Vector2 | GetTextSize (const char *textString, float pointSize, TextOptions *textOptions=nullptr) override |
Get the width and height (in pixels) that would be used to draw the given text string. More... | |
float | GetViewportWidth () const override |
Get the width of the rendering viewport (in pixels). | |
float | GetViewportHeight () const override |
Get the height of the rendering viewport (in pixels). | |
float | GetViewportDpiScalingFactor () const override |
Get dpi scale factor. | |
const ImageOptions & | GetDefaultImageOptions () const override |
Get the default values that would be used if no image options were passed in. More... | |
const TextOptions & | GetDefaultTextOptions () const override |
Get the default values that would be used if no text options were passed in. More... | |
void | RenderDeferredPrimitives () override |
Render the primitives that have been deferred. | |
void | SetDeferPrimitives (bool deferPrimitives) override |
Specify whether to defer future primitives or render them right away. | |
bool | GetDeferPrimitives () override |
Return whether future primitives will be deferred or rendered right away. | |
void | SetSortKey (int64_t key) override |
Set sort key offset for following draws. | |
Public Member Functions inherited from IDraw2d | |
virtual | ~IDraw2d () |
Implement virtual destructor just for safety. | |
Static Public Member Functions | |
static AZ::Data::Instance< AZ::RPI::Image > | LoadTexture (const AZStd::string &pathName) |
Helper to load a texture. | |
Protected Types | |
enum | { MAX_VERTICES_IN_PRIM = 6 } |
Protected Member Functions | |
void | RotatePointsAboutPivot (AZ::Vector2 *points, int numPoints, AZ::Vector2 pivot, float angle) const |
Rotate an array of points around the z-axis at the pivot point. More... | |
void | DrawOrDeferQuad (const DeferredQuad *quad) |
Draw or defer a quad. | |
void | DrawOrDeferLine (const DeferredLine *line) |
Draw or defer a line. | |
void | DrawOrDeferTextString (const DeferredText *text) |
Draw or defer a text string. | |
void | DrawOrDeferRectOutline (const DeferredRectOutline *outlineRect) |
Draw or defer a rect outline. | |
AZ::RPI::ViewportContextPtr | GetViewportContext () const |
Get specified viewport context or default viewport context if not specified. | |
Protected Attributes | |
ImageOptions | m_defaultImageOptions |
The default image options used if nullptr is passed. | |
TextOptions | m_defaultTextOptions |
The default text options used if nullptr is passed. | |
bool | m_deferCalls |
True if the actual render of the primitives should be deferred to a RenderDeferredPrimitives call. | |
std::vector< DeferredPrimitive * > | m_deferredPrimitives |
AZ::RPI::ViewportContextPtr | m_viewportContext |
AZ::RHI::Ptr< AZ::RPI::DynamicDrawContext > | m_dynamicDraw |
Draw2dShaderData | m_shaderData |
Additional Inherited Members | |
Public Types inherited from IDraw2d | |
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 } |
Implementation of IDraw2d interface for 2D drawing in screen space.
The CDraw2d class implements the IDraw2d interface for drawing 2D images, shapes and text. Positions and sizes are specified in pixels in the associated 2D viewport.
|
overridevirtual |
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 |
Implements IDraw2d.
|
overridevirtual |
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 |
Implements IDraw2d.
|
overridevirtual |
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 |
Implements IDraw2d.
|
overridevirtual |
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 |
Implements IDraw2d.
|
overridevirtual |
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 |
Implements IDraw2d.
|
overridevirtual |
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 |
Implements IDraw2d.
|
overridevirtual |
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 |
Implements IDraw2d.
|
overridevirtual |
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
Implements IDraw2d.
|
overridevirtual |
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
Implements IDraw2d.
|
overridevirtual |
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
Implements IDraw2d.
|
protected |
Rotate an array of points around the z-axis at the pivot point.
Angle is in degrees counter-clockwise