My Project
SpriteRenderer.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
5  struct TextureEntity;
6 
7  struct sprite_vertex
8  {
9  sprite_vertex() : tex(0.f, 0.f), col(0) {}
10  Vector3 pos;
11  DWORD col;
12  Vector2 tex;
13  };
14 
15  struct SpriteQuad
16  {
17  DeviceTexturePtr_type texture;
18  UINT texw, texh;
19  RECT rect;
20  Vector3 center;
21  Vector3 pos;
22  DWORD color;
23  Matrix4 transform;
24  };
25 
27  {
28  DeviceTexturePtr_type texture;
29  UINT texw, texh;
30  RECT rect;
31  Vector3 vertices[3];
32  DWORD color;
33  Matrix4 transform;
34  };
35 
37  {
38  DeviceTexturePtr_type texture;
39  UINT texw, texh;
40  RECT rect;
41  Vector3 vStart;
42  Vector3 vEnd;
43  DWORD color;
44  float Thickness;
45  Matrix4 transform;
46  public:
47  Vector3 normalVector();
51  static void normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny, float fLineWidth = 0.5f);
52  };
53 
56  {
57  public:
58  /* create based on current implementation. */
59  static CSpriteRenderer* Create();
60 
61  CSpriteRenderer();;
62  virtual ~CSpriteRenderer(){};
63 
64  public:
65  virtual HRESULT Begin(DWORD Flags);
66  virtual void End();
67  virtual void Flush();
68 
71  virtual bool BeginCustomShader(){ return true; };
72  virtual void EndCustomShader(){};
73 
74  virtual void UpdateShader(bool bForceUpdate = false) {};
75  virtual void SetNeedUpdateShader(bool bNeedUpdate) {};
76 
77  virtual HRESULT DrawRect(const RECT* pRect, Color color, float depth);
78 
79  virtual HRESULT DrawQuad(TextureEntity* pTexture, const RECT* pSrcRect, const Vector3* vCenter, const Vector3* pPosition, Color c);
80 
81  virtual HRESULT DrawLine(TextureEntity* pTexture, const RECT* pSrcRect, const Vector3& vStart, const Vector3& vEnd, float thickness, Color c);
82 
86  virtual HRESULT DrawTriangleList(TextureEntity* pTexture, const RECT* pSrcRect, const Vector3* pVertices, int nTriangleCount, Color c);
87 
88  virtual HRESULT SetTransform(const Matrix4& mat);
89  virtual void GetTransform(Matrix4& transform);
90  virtual const Matrix4& GetTransform() const;
91  virtual float GetFontScaling() const;
92 
93  virtual void InitDeviceObjects(){};
94  virtual void RestoreDeviceObjects(){};
95  virtual void InvalidateDeviceObjects(){};
96  virtual void DeleteDeviceObjects(){};
97 
99  virtual void SetTextMode(bool bIsTextMode = true) {};
100  virtual void PrepareDraw(){};
101  protected:
102  virtual void FlushThickLines();
103  virtual void FlushQuads();
104  virtual void FlushTriangles();
105  virtual void DrawTriangles(const sprite_vertex* pVertices, int nTriangleCount);
106  /*
107  The WORLD, VIEW, and PROJECTION transforms are NOT modified. The
108  transforms currently set to the device are used to transform the sprites
109  when the batch is drawn (at Flush or End). If this is not specified,
110  WORLD, VIEW, and PROJECTION transforms are modified so that sprites are
111  drawn in screen space coordinates.
112  */
113  bool IsUseObjectSpaceTransform();
114 
115  protected:
116  DWORD m_flags;
117  Matrix4 m_transform;
118  // cached vertices
119  std::vector<sprite_vertex> m_vertices;
120 
121  // all sprite thick lines
122  std::vector<SpriteThickLine> m_thickLines;
123 
124  // all sprite triangles
125  std::vector<SpriteTriangle> m_triangles;
126 
127 
128  // number of thick lines to be drawn
129  int m_thickline_count;
130 
131  // number of triangles to be drawn
132  int m_triangles_count;
133  };
134 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: ManagedDef.h:18
Definition: SpriteRenderer.h:15
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
virtual void SetTextMode(bool bIsTextMode=true)
whether to set text mode.
Definition: SpriteRenderer.h:99
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
virtual bool BeginCustomShader()
call BeginCustomShader and EndCustomShader.
Definition: SpriteRenderer.h:71
Definition: SpriteRenderer.h:26
Definition: SpriteRenderer.h:36
Definition: SpriteRenderer.h:7
Definition: ParaColor.h:275
base class for sprite renderer
Definition: SpriteRenderer.h:55