2.9.16
Coherent GT
A modern user interface library for games
Coherent::UIGT::ViewRenderer Class Referenceabstract

Used for drawing a View To create a renderer for a View please use the UISystemRenderer::CreateViewRenderer method. More...

#include <Coherent/Coherent/UIGT/View.h>

Public Member Functions

virtual void Destroy ()=0
 Destroys the rendering resources for a View.
 
virtual unsigned Paint (unsigned frameId)=0
 Paints the frame with the supplied frame id in the user supplied texture. More...
 
virtual unsigned PaintToTexture (unsigned frameId, NativeRenderTarget nativeTextureTarget, unsigned width, unsigned height, unsigned sampleCount, unsigned destX, unsigned destY, unsigned destWidth, unsigned destHeight)=0
 Paints the frame with the supplied frame id in the supplied texture. Use only this paint method with the UISystemRenderer::CreateViewRenderer(View* view) API. More...
 
virtual void GetLastPaintedRects (PaintRect *rects, unsigned *count)=0
 Fills an array with the rects from the View that were last painted. More...
 
virtual void SetRenderTarget (NativeRenderTarget nativeTexture, unsigned width, unsigned height, unsigned sampleCount)=0
 Changes the current texture where the renderer is painting in. More...
 
virtual void GetCurrentRenderTarget (NativeRenderTarget &nativeTexture, unsigned &width, unsigned &height)=0
 Returns the parameters of the texture where the renderer will paint. More...
 
virtual void IssueMouseOnUIQuery (void *texture, float normX, float normY)=0
 Issues a query on the View to check if the mouse is on the user interface or not. More...
 
virtual ViewErrorType HasMouseQueryFinished ()=0
 Returns the status of the mouse query. More...
 
virtual void FetchMouseOnUIQuery ()=0
 Ends a mouse-on-UI query. Waits for the result. More...
 

Detailed Description

Used for drawing a View To create a renderer for a View please use the UISystemRenderer::CreateViewRenderer method.

Note
You must destroy the renderer before the View it draws
Methods can be called from a rendering thread

Member Function Documentation

◆ FetchMouseOnUIQuery()

virtual void Coherent::UIGT::ViewRenderer::FetchMouseOnUIQuery ( )
pure virtual

Ends a mouse-on-UI query. Waits for the result.

Note
Should be called as far apart from IssueMouseOnUIQuery in order to maximize the chances that the query has finished at the time of this call and no waiting will be performed

◆ GetCurrentRenderTarget()

virtual void Coherent::UIGT::ViewRenderer::GetCurrentRenderTarget ( NativeRenderTarget &  nativeTexture,
unsigned &  width,
unsigned &  height 
)
pure virtual

Returns the parameters of the texture where the renderer will paint.

Parameters
nativeTexturethe native texture to draw into
widththe width of the texture
heightthe height of the texture

◆ GetLastPaintedRects()

virtual void Coherent::UIGT::ViewRenderer::GetLastPaintedRects ( PaintRect rects,
unsigned *  count 
)
pure virtual

Fills an array with the rects from the View that were last painted.

Parameters
rectsan array of PaintRect structs that is big enough to contain all painted rects. If you pass nullptr, the parameter will be ignored but the count set in the count param.
countsize of the rects array. Will be reset to the count of painted rects

◆ HasMouseQueryFinished()

virtual ViewErrorType Coherent::UIGT::ViewRenderer::HasMouseQueryFinished ( )
pure virtual

Returns the status of the mouse query.

Returns
the result will be Success if the query has finished, QueryNotReady otherwise. If no query has been issued InvalidCall will be returned.

◆ IssueMouseOnUIQuery()

virtual void Coherent::UIGT::ViewRenderer::IssueMouseOnUIQuery ( void *  texture,
float  normX,
float  normY 
)
pure virtual

Issues a query on the View to check if the mouse is on the user interface or not.

Warning
Calling IsMouseOnView while a query is in-flight is an error and will be logged - the result returned by IsMouseOnView in that case is undefined.

Put as much processing as possible between IssueMouseOnUIQuery and the corresponding FetchMouseOnUIQuery, this allows leveraging the cost of the query and to reduce it to ~0. The best way to do this is call IssueMouseOnUIQuery early in the frame, perform all game rendering and the call FetchMouseOnUIQuery followed by IsMouseOnView to update the needed data.

Parameters
texturethe texture that will be used for the query
normXthe x coordinate of the mouse in the normalized space of the view [0..1]
normYthe y coordinate of the mouse in the normalized space of the view [0..1]
Warning
the texture passed in must have the same dimensions as the currently set render target
See also
Coherent::UIGT::ViewRenderer::SetRenderTarget
Warning
the texture passed in must not be multisampled

◆ Paint()

virtual unsigned Coherent::UIGT::ViewRenderer::Paint ( unsigned  frameId)
pure virtual

Paints the frame with the supplied frame id in the user supplied texture.

Note
Must be called only with ids provided by RecordRenderingCommands or Layout
Parameters
frameIdthe id of the recorded rendering commands to paint
Returns
the count of drawn rects

◆ PaintToTexture()

virtual unsigned Coherent::UIGT::ViewRenderer::PaintToTexture ( unsigned  frameId,
NativeRenderTarget  nativeTextureTarget,
unsigned  width,
unsigned  height,
unsigned  sampleCount,
unsigned  destX,
unsigned  destY,
unsigned  destWidth,
unsigned  destHeight 
)
pure virtual

Paints the frame with the supplied frame id in the supplied texture. Use only this paint method with the UISystemRenderer::CreateViewRenderer(View* view) API.

Note
Must be called only with ids provided by RecordRenderingCommands or Layout
Parameters
frameIdthe id of the recorded rendering commands to paint
nativeTextureTargetthe native texture to draw into
widththe width of the render target
heightthe height of the render target
sampleCountthe number of samples of the texture when using MSAA. Set to 1 if not using MSAA
destXthe left offset for the destination viewport within the render target
destYthe top offset for the destination viewport within the render target
destWidththe width of the destination viewport within the render target
destHeightthe height of the destination viewport within the render target
Returns
the count of drawn rects

◆ SetRenderTarget()

virtual void Coherent::UIGT::ViewRenderer::SetRenderTarget ( NativeRenderTarget  nativeTexture,
unsigned  width,
unsigned  height,
unsigned  sampleCount 
)
pure virtual

Changes the current texture where the renderer is painting in.

Note
Must be called after a resize with a new texture
Parameters
nativeTexturethe native texture to draw into
widththe width of the texture
heightthe height of the texture
sampleCountthe number of samples of the texture when using MSAA. Set to 1 if not using MSAA