My Project
|
base class for a surface to paint to. More...
#include <Painter.h>
Public Types | |
enum | CompositionMode { CompositionMode_SourceBlend, CompositionMode_SourceOver, CompositionMode_DestinationOver, CompositionMode_Clear, CompositionMode_Source, CompositionMode_Destination, CompositionMode_SourceIn, CompositionMode_DestinationIn, CompositionMode_SourceOut, CompositionMode_DestinationOut, CompositionMode_SourceAtop, CompositionMode_DestinationAtop, CompositionMode_Xor, CompositionMode_Plus, CompositionMode_PlusSourceBlend, RasterOp_SourceOrDestination, RasterOp_SourceAndDestination, RasterOp_SourceXorDestination, RasterOp_NotSourceAndNotDestination, RasterOp_NotSourceOrNotDestination, RasterOp_NotSourceXorDestination, RasterOp_NotSource, RasterOp_NotSourceAndDestination, RasterOp_SourceAndNotDestination, RasterOp_NotSourceOrDestination, RasterOp_SourceOrNotDestination, RasterOp_ClearDestination, RasterOp_SetDestination, RasterOp_NotDestination } |
![]() | |
typedef ParaEngine::weak_ptr< IObject, IAttributeFields > | WeakPtr_type |
![]() | |
typedef ParaEngine::weak_ptr< IObject > | WeakPtr_type |
Public Member Functions | |
CPainter (CPaintDevice *pd) | |
ATTRIBUTE_DEFINE_CLASS (CPainter) | |
virtual int | InstallFields (CAttributeClass *pClass, bool bOverride) |
this class should be implemented if one wants to add new attribute. More... | |
ATTRIBUTE_METHOD1 (CPainter, GetCompositionMode_s, int *) | |
ATTRIBUTE_METHOD1 (CPainter, SetCompositionMode_s, int) | |
ATTRIBUTE_METHOD1 (CPainter, GetOpacity_s, float *) | |
ATTRIBUTE_METHOD1 (CPainter, SetOpacity_s, float) | |
ATTRIBUTE_METHOD1 (CPainter, IsAutoLineWidth_s, bool *) | |
ATTRIBUTE_METHOD1 (CPainter, EnableAutoLineWidth_s, bool) | |
ATTRIBUTE_METHOD1 (CPainter, IsSpriteUseWorldMatrix_s, bool *) | |
ATTRIBUTE_METHOD1 (CPainter, SetSpriteUseWorldMatrix_s, bool) | |
ATTRIBUTE_METHOD (CPainter, Save_s) | |
ATTRIBUTE_METHOD (CPainter, Restore_s) | |
ATTRIBUTE_METHOD (CPainter, Flush_s) | |
ATTRIBUTE_METHOD (CPainter, BeginNativePainting_s) | |
ATTRIBUTE_METHOD (CPainter, EndNativePainting_s) | |
ATTRIBUTE_METHOD (CPainter, ResetTransform_s) | |
ATTRIBUTE_METHOD1 (CPainter, GetMatrixMode_s, int *) | |
ATTRIBUTE_METHOD1 (CPainter, SetMatrixMode_s, int) | |
ATTRIBUTE_METHOD (CPainter, PushMatrix_s) | |
ATTRIBUTE_METHOD (CPainter, PopMatrix_s) | |
ATTRIBUTE_METHOD (CPainter, LoadCurrentMatrix_s) | |
ATTRIBUTE_METHOD (CPainter, LoadIdentityMatrix_s) | |
ATTRIBUTE_METHOD (CPainter, LoadBillboardMatrix_s) | |
ATTRIBUTE_METHOD3 (CPainter, TranslateMatrix_s, float) | |
ATTRIBUTE_METHOD4 (CPainter, RotateMatrix_s, float) | |
ATTRIBUTE_METHOD3 (CPainter, ScaleMatrix_s, float) | |
ATTRIBUTE_METHOD1 (CPainter, LoadMatrix_s, const Matrix4 &) | |
ATTRIBUTE_METHOD1 (CPainter, MultiplyMatrix_s, const Matrix4 &) | |
ATTRIBUTE_METHOD1 (CPainter, GetCurrentMatrix_s, Matrix4 *) | |
ATTRIBUTE_METHOD1 (CPainter, GetScaling_s, Vector3 *) | |
CPaintDevice * | device () const |
bool | begin (CPaintDevice *pd) |
bool | end () |
bool | isActive () const |
void | initFrom (const CPaintDevice *device) |
CPaintEngine * | paintEngine () const |
bool | IsScissorRectSupported () const |
bool | IsStencilSupported () const |
void | setCompositionMode (CompositionMode mode) |
CompositionMode | compositionMode () const |
int | GetPendingAssetCount () |
number of texture between begin() end() that is not available at the time of drawing. More... | |
bool | IsAutoLineWidth () const |
whether we will render line so that they are at least 1 pixel width automatically adjust line width according to camera to world distance. | |
void | EnableAutoLineWidth (bool val) |
float | FromUnitSpaceX (float fUnitspaceX) |
get screen space coordinate from a unit space x parameter. More... | |
float | FromUnitSpaceY (float fUnitspaceY) |
const QFont & | font () const |
void | setFont (const QFont &f) |
void | setPen (const Color &color) |
void | setPen (const QPen &pen) |
void | setPen (PenStyle style) |
const QPen & | pen () const |
void | setBrush (const QBrush &brush) |
void | setBrush (BrushStyle style) |
const QBrush & | brush () const |
QPoint | brushOrigin () const |
void | setBrushOrigin (int x, int y) |
void | setBrushOrigin (const QPoint &) |
void | setBrushOrigin (const QPointF &) |
void | setBackground (const QBrush &bg) |
const QBrush & | background () const |
float | opacity () const |
void | setOpacity (float opacity) |
QRegion | clipRegion () const |
QPainterPath | clipPath () const |
void | setClipRect (const QRectF &, ClipOperation op=ReplaceClip) |
void | setClipRect (const QRect &, ClipOperation op=ReplaceClip) |
void | setClipRect (int x, int y, int w, int h, ClipOperation op=ReplaceClip) |
void | setClipRegion (const QRegion &, ClipOperation op=ReplaceClip) |
void | setClipPath (const QPainterPath &path, ClipOperation op=ReplaceClip) |
void | setClipping (bool enable) |
bool | hasClipping () const |
QRectF | clipBoundingRect () const |
void | save () |
void | restore () |
void | beginNativePainting () |
native painting is supported by default. More... | |
void | endNativePainting () |
void | Flush () |
void | setWorldTransform (const QTransform &matrix, bool combine=false) |
Sets the world transformation matrix. More... | |
const QTransform & | worldTransform () const |
const QTransform & | deviceTransform () const |
void | resetTransform () |
Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldTransform(), setViewport() | |
QTransform | combinedTransform () const |
Returns the transformation matrix combining the current window/viewport and world transformation. | |
void | setWorldMatrixEnabled (bool enabled) |
bool | worldMatrixEnabled () const |
void | scale (float sx, float sy) |
void | shear (float sh, float sv) |
void | rotate (float a) |
void | translate (const QPointF &offset) |
void | translate (const QPoint &offset) |
void | translate (float dx, float dy) |
QRect | viewport () const |
void | setViewport (const QRect &viewport) |
QPointF | UIScaling () const |
void | setUIScaling (const QPointF &uiScaling) |
called automatically according to paint device | |
void | setViewTransformEnabled (bool enable) |
bool | viewTransformEnabled () const |
void | drawPoints (const QPointF *points, int pointCount) |
void | drawPoints (const QPoint *points, int pointCount) |
void | drawLines (const QLineF *lines, int lineCount) |
void | drawLines (const QPointF *pointPairs, int lineCount) |
void | drawLines (const QLine *lines, int lineCount) |
void | drawLines (const QPoint *pointPairs, int lineCount) |
void | drawLines (const Vector3 *vertices, int nLineCount) |
void | drawRects (const QRectF *rects, int rectCount) |
void | drawRects (const QRect *rects, int rectCount) |
void | drawTriangles (const Vector3 *vertices, int nTriangleCount) |
void | drawPoint (const QPointF &pt) |
void | drawPoint (const QPoint &p) |
void | drawPoint (int x, int y) |
void | drawLine (const QLineF &line) |
void | drawLine (const QLine &line) |
void | drawLine (int x1, int y1, int x2, int y2) |
void | drawLine (const QPoint &p1, const QPoint &p2) |
void | drawLine (const QPointF &p1, const QPointF &p2) |
void | drawLines (const std::vector< QLineF > &lines) |
void | drawLines (const std::vector< QPointF > &pointPairs) |
void | drawLines (const std::vector< QLine > &lines) |
void | drawLines (const std::vector< QPoint > &pointPairs) |
void | drawRect (const QRectF &rect) |
void | drawRect (int x1, int y1, int w, int h) |
void | drawRect (const QRect &rect) |
void | drawRects (const std::vector< QRectF > &rectangles) |
void | drawRects (const std::vector< QRect > &rectangles) |
void | drawPolyline (const QPointF *points, int pointCount) |
void | drawPolyline (const QPolygonF &polyline) |
void | drawPolyline (const QPoint *points, int pointCount) |
void | drawPolyline (const QPolygon &polygon) |
void | drawPolygon (const QPointF *points, int pointCount, FillRule fillRule=OddEvenFill) |
void | drawPolygon (const QPolygonF &polygon, FillRule fillRule=OddEvenFill) |
void | drawPolygon (const QPoint *points, int pointCount, FillRule fillRule=OddEvenFill) |
void | drawPolygon (const QPolygon &polygon, FillRule fillRule=OddEvenFill) |
void | drawTexture (const QPointF &p, TextureEntity *pTexture, float fDepth=0.f) |
void | drawTexture (const QRectF &targetRect, TextureEntity *pTexture, const QRectF &sourceRect, float fDepth=0.f) |
void | drawTexture (const QRect &targetRect, TextureEntity *pTexture, const QRect &sourceRect, float fDepth=0.f) |
void | drawTexture (int x, int y, int w, int h, TextureEntity *pTexture, int sx, int sy, int sw, int sh, float fDepth=0.f) |
void | drawTexture (int x, int y, TextureEntity *pTexture, int sx, int sy, int sw, int sh, float fDepth=0.f) |
void | drawTexture (const QPointF &p, TextureEntity *pTexture, const QRectF &sr, float fDepth=0.f) |
void | drawTexture (const QPoint &p, TextureEntity *pTexture, const QRect &sr, float fDepth=0.f) |
void | drawTexture (const QPoint &p, TextureEntity *pTexture, float fDepth=0.f) |
void | drawTexture (int x, int y, TextureEntity *pTexture, float fDepth=0.f) |
void | drawTexture (const QRect &r, TextureEntity *pTexture, float fDepth=0.f) |
void | drawTexture (int x, int y, int w, int h, TextureEntity *pTexture, float fDepth=0.f) |
void | drawText (const QPointF &p, const std::string &s) |
void | drawText (const QRectF &r, const std::string &text, const QTextOption &o=QTextOption()) |
void | drawText (const QPoint &p, const std::string &s) |
void | drawText (int x, int y, const std::string &s) |
void | DrawSceneObject (CBaseObject *pObj, int nOption=0) |
draw a scene object More... | |
void | SetSpriteTransform (const Matrix4 *pMatrix=NULL) |
set the global transform to sprite object. More... | |
HRESULT | DrawSprite (GUITextureElement *pElement, RECT *prcDest, float depth) |
rotate sprite at a rect | |
HRESULT | DrawSprite (GUITextureElement *pElement, RECT *prcDest, Matrix4 matTransform, float depth) |
HRESULT | DrawSprite (GUITextureElement *pElement, RECT *prcDest, const Vector2 &vRotOrigin, float fRadian, const Vector2 *vScaling, const Vector2 *vTranslation, const DWORD *dwColorMask, float depth) |
rotate prcDest with an origin. | |
HRESULT | DrawSprite (GUITextureElement *pElement, RECT *prcDest, int n, float depth) |
we only support n*¦Ð/2 angle rotation. | |
HRESULT | DrawRect (RECT *pRect, Color color, float depth) |
HRESULT | DrawText (const char16_t *strText, GUIFontElement *pElement, RECT *prcDest, float depth, bool bShadow=false, int nCount=-1, int shadowQuality=0, Color shadowColor=0) |
HRESULT | DrawText (const char16_t *strText, GUIFontElement *pElement, RECT *prcDest, const Vector2 &vRotOrigin, float fRadian, const Vector2 *vScaling, const Vector2 *vTranslation, const DWORD *dwColorMask, float depth, bool bShadow=false, int nCount=-1, int shadowQuality=0, Color shadowColor=0) |
rotate prcDest with an origin. | |
HRESULT | DrawText (const char16_t *strText, GUIFontElement *pElement, RECT *prcDest, const Matrix4 &mat, const DWORD *dwColorMask, float depth, bool bShadow=false, int nCount=-1, int shadowQuality=0, Color shadowColor=0) |
HRESULT | CalcTextRect (const char16_t *strText, GUIFontElement *pElement, RECT *prcDest, float depth, int nCount=-1) |
void | SetUse3DTransform (bool bUse3DSpaceTransform) |
by default, transforms are in 2d screen space. More... | |
bool | IsUse3DTransform () |
return false by default. More... | |
void | SetSpriteUseWorldMatrix (bool bEnable) |
set sprite use world matrix. More... | |
bool | IsSpriteUseWorldMatrix () |
void | SetHelperDevice (CPaintDevice *val) |
currently only used for text size calculation. More... | |
void | SetMatrixMode (int nMode) |
similar to glMatrixMode() in opengl. More... | |
int | GetMatrixMode () const |
void | PushMatrix () |
similar to glPushMatrix() in opengl. More... | |
void | PopMatrix () |
similar to glPopMatrix() in opengl. More... | |
void | LoadCurrentMatrix () |
retrieve the current matrix. More... | |
void | LoadIdentityMatrix () |
load identity matrix | |
void | LoadBillboardMatrix () |
load a matrix so that everything rendered faces the camera. More... | |
void | LoadMatrix (const Matrix4 &mat) |
we use row-major matrix | |
void | MultiplyMatrix (const Matrix4 &mat) |
multiply the current matrix with the specified matrix. More... | |
void | TranslateMatrix (float x, float y, float z) |
multiply the current matrix by a translation matrix | |
void | RotateMatrix (float angle, float x, float y, float z) |
multiply the current matrix by a rotation matrix | |
void | ScaleMatrix (float x, float y, float z) |
multiply the current matrix by a scaling matrix | |
const ParaEngine::Matrix4 & | GetCurMatrix () const |
get current world matrix. More... | |
Vector3 | GetScaling () |
get the current world matrix's scaling. More... | |
![]() | |
virtual int | GetAttributeClassID () |
attribute class ID should be identical, unless one knows how overriding rules work. More... | |
virtual const char * | GetAttributeClassName () |
a static string, describing the attribute class object's name | |
virtual const char * | GetAttributeClassDescription () |
a static string, describing the attribute class object | |
virtual int | GetChildAttributeColumnCount () |
we support multi-dimensional child object. More... | |
virtual int | GetChildAttributeObjectCount (int nColumnIndex=0) |
get the number of child objects (row count) in the given column. More... | |
virtual IAttributeFields * | GetChildAttributeObject (int nRowIndex, int nColumnIndex=0) |
virtual IAttributeFields * | GetChildAttributeObject (const std::string &sName) |
get attribute by child object. More... | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetName_s, const char **) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetName_s, const char *) | |
ATTRIBUTE_METHOD (IAttributeFields, PrintObject_s) | |
ATTRIBUTE_METHOD (IAttributeFields, AddRef_s) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetRefCount_s, int *) | |
ATTRIBUTE_METHOD1 (IAttributeFields, SetTime_s, int) | |
ATTRIBUTE_METHOD1 (IAttributeFields, GetTime_s, int *) | |
ATTRIBUTE_METHOD (IAttributeFields, Release_s) | |
virtual const std::string & | GetIdentifier () |
virtual void | SetIdentifier (const std::string &sID) |
virtual bool | IsModified () |
whether some of the fields are modified.It is up to the implementation class to provide this functionality if necessary. More... | |
virtual void | SetModified (bool bModified) |
set whether any field has been modified. More... | |
virtual bool | ValidateFields () |
validate all fields and return true if validation passed. More... | |
virtual string | GetValidationMessage () |
get the recent validation message due to the most recent call to ValidateFields() | |
virtual bool | ResetField (int nFieldID) |
Reset the field to its initial or default value. More... | |
virtual bool | InvokeEditor (int nFieldID, const std::string &sParameters) |
Invoke an (external) editor for a given field. More... | |
virtual bool | AddChildAttributeObject (IAttributeFields *pChild, int nRowIndex=-1, int nColumnIndex=0) |
add child object. More... | |
virtual void * | QueryObjectByName (const std::string &sObjectType) |
convert to object of a given type. More... | |
virtual void * | QueryObject (int nObjectType) |
convert to object of a given type. More... | |
virtual int | GetTime () |
get the current local time in case it is animated in milli seconds frames. More... | |
virtual void | SetTime (int nTime) |
virtual CDynamicAttributeField * | GetDynamicField (const std::string &sName) |
Get a dynamic field with a given name. More... | |
virtual CDynamicAttributeField * | GetDynamicField (int nIndex) |
Get a dynamic field with a given index. More... | |
virtual const char * | GetDynamicFieldNameByIndex (int nIndex) |
get field name by index | |
virtual int | GetDynamicFieldCount () |
how many dynamic field this object currently have. More... | |
virtual int | SetDynamicField (const std::string &sName, const CVariable &value) |
set a dynamic field with a given name. More... | |
virtual int | AddDynamicField (const std::string &sName, ATTRIBUTE_FIELDTYPE dwType) |
add dynamic field and return field index | |
virtual void | RemoveAllDynamicFields () |
remove all dynamic fields | |
virtual int | SaveDynamicFieldsToString (std::string &output) |
save only text dynamic fields to fieldname = value text strings. More... | |
virtual int | LoadDynamicFieldsFromString (const std::string &input) |
load only text dynamic fields from string More... | |
CAttributeClass * | GetAttributeClass () |
get the main attribute class object. More... | |
void | PrintObject () |
print the content of this object to a text file at temp/doc/[ClassName].txt. More... | |
![]() | |
virtual void | Clone (IObject *obj) const |
Clone the object's contains to a pointer. More... | |
virtual IObject * | Clone () const |
Clone the object's contains and return a pointer to the newly created object. More... | |
virtual bool | Equals (const IObject *obj) const |
Compare the object with another object. More... | |
virtual const IType * | GetType () const |
virtual std::string | ToString () const |
WeakPtr_type & | GetWeakReference () |
get weak reference object. More... | |
virtual int | ProcessObjectEvent (const ObjectEvent &event) |
this function is only used to backward compatibility of ParaObject:AddEvent() function. More... | |
![]() | |
void | addref () const |
add reference count of the object. More... | |
bool | delref () const |
decrease reference count of the object. More... | |
int | GetRefCount () const |
get the reference count | |
virtual int | Release () |
CRefCounted * | AddToAutoReleasePool () |
addref and releases the ownership sometime soon automatically (usually at the end of the current frame). More... | |
Additional Inherited Members | |
![]() | |
static HRESULT | GetAttributeClassID_s (IAttributeFields *cls, int *p1) |
static HRESULT | GetAttributeClassName_s (IAttributeFields *cls, const char **p1) |
static bool | OpenWithDefaultEditor (const char *sFilename, bool bWaitOnReturn=false) |
Open a given file with the default registered editor in the game engine. More... | |
![]() | |
virtual CAttributeClass * | CreateAttributeClass () |
initialize fields | |
virtual CDynamicAttributesSet * | GetDynamicAttributes (bool bCreateIfNotExist=false) |
![]() | |
WeakPtr_type | m_weak_reference |
![]() | |
int | m_refcount |
base class for a surface to paint to.
The CRenderTarget subclass this.
—++ On Coordinate System The 2D API uses Y axis downward coordinate; where as the 3D API uses Y axis. Both APIs can be used together. The final world matrix is calculated as thus: finalMatrix = mat2DFinal * matInvertY * mat3DFinal; mat2DFinal is the final matrix by all the 2d api like scale, translate, rotate mat3DFinal is the final matrix by all the 3d api like PushMatrix, TranslateMatrix, etc. Please note, mat3DFinal only takes effect when 3d mode is enabled, such as during rendering head on display or overlays. When you are rendering 3D triangles mixed with 2D GUI, it is good practice to restore mat2DFinal to identity matrix after drawing 2D GUI.
void ParaEngine::CPainter::beginNativePainting | ( | ) |
native painting is supported by default.
however, one need to call SetUse3DTransform(true) before begin(). this function does nothing here.
CPaintDevice * ParaEngine::CPainter::device | ( | ) | const |
Returns the paint device on which this painter is currently painting, or 0 if the painter is not active.
void ParaEngine::CPainter::DrawSceneObject | ( | CBaseObject * | pObj, |
int | nOption = 0 |
||
) |
draw a scene object
obj | can be a character or model object. |
nOption | default to 0, which renders using the transform of the scene object. |
float ParaEngine::CPainter::FromUnitSpaceX | ( | float | fUnitspaceX | ) |
get screen space coordinate from a unit space x parameter.
It will take UI scaling into consideration
fUnitspaceX | [0,1], where 0 is left most, 1 is right most. |
const ParaEngine::Matrix4 & ParaEngine::CPainter::GetCurMatrix | ( | ) | const |
get current world matrix.
int ParaEngine::CPainter::GetPendingAssetCount | ( | ) |
number of texture between begin() end() that is not available at the time of drawing.
we generally make the paint device dirty if there is painted with at least one pending asset.
Vector3 ParaEngine::CPainter::GetScaling | ( | ) |
get the current world matrix's scaling.
|
virtual |
this class should be implemented if one wants to add new attribute.
This function is always called internally.
Reimplemented from ParaEngine::IAttributeFields.
bool ParaEngine::CPainter::IsUse3DTransform | ( | ) |
return false by default.
void ParaEngine::CPainter::LoadBillboardMatrix | ( | ) |
load a matrix so that everything rendered faces the camera.
it will only do so by a rotation.
void ParaEngine::CPainter::LoadCurrentMatrix | ( | ) |
retrieve the current matrix.
void ParaEngine::CPainter::MultiplyMatrix | ( | const Matrix4 & | mat | ) |
multiply the current matrix with the specified matrix.
we use row-major matrix
void ParaEngine::CPainter::PopMatrix | ( | ) |
similar to glPopMatrix() in opengl.
void ParaEngine::CPainter::PushMatrix | ( | ) |
similar to glPushMatrix() in opengl.
void ParaEngine::CPainter::SetHelperDevice | ( | CPaintDevice * | val | ) |
currently only used for text size calculation.
void ParaEngine::CPainter::SetMatrixMode | ( | int | nMode | ) |
similar to glMatrixMode() in opengl.
nMode | 0 is world, 1 is view, 2 is projection. default to 0. |
void ParaEngine::CPainter::SetSpriteTransform | ( | const Matrix4 * | pMatrix = NULL | ) |
set the global transform to sprite object.
void ParaEngine::CPainter::SetSpriteUseWorldMatrix | ( | bool | bEnable | ) |
set sprite use world matrix.
void ParaEngine::CPainter::SetUse3DTransform | ( | bool | bUse3DSpaceTransform | ) |
by default, transforms are in 2d screen space.
However, we can also specify using 3d transform, such as when rendering GUI onto 3D scenes. Call this before begin()
void ParaEngine::CPainter::setWorldTransform | ( | const QTransform & | matrix, |
bool | combine = false |
||
) |
Sets the world transformation matrix.
If combine is true, the specified matrix is combined with the current matrix; otherwise it replaces the current matrix.