Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cDXSprite.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cDXSprite_H
7 #define _INC_cDXSprite_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cDXBase.h"
15 
16 #ifdef USE_DXX
22 
23 namespace Gray3D
24 {
25  class cDXTextureBase;
26 
27  class GRAY3D_LINK cDXSpriteElem
28  {
32 
33  friend class cDXSpriteDC;
34 
35  public:
36  cIUnkPtr<ID3DTexture> m_pDXTexture;
37  cRectI m_ElemRect;
38 
39  private:
40  cColorDX m_Color;
41 
42  cVector2f m_vScaling;
43 
44  cVector2f m_vRotationCenter;
45  RADIANf_t m_Rotation;
46 
47  protected:
48  HRESULT UpdateTexureSize();
49 
50  public:
51  cDXSpriteElem(ID3DTexture* pTex = nullptr);
52  cDXSpriteElem(const cDXSpriteElem& Sprite);
53  ~cDXSpriteElem(void);
54 
55  bool SetCopyElem(const cDXSpriteElem& src);
56 
57  bool isTextureSet() const
58  {
59  if (m_pDXTexture == nullptr)
60  return false;
61  return true;
62  }
63  ID3DTexture* get_Texture() const
64  {
65  return m_pDXTexture;
66  }
67  HRESULT put_Texture(ID3DTexture* pDXTexture);
68 
69  virtual cRectI get_ElemRect(void) const
70  {
72  return m_ElemRect;
73  }
74  void put_ElemRect(const cRectI& ElemRect)
75  {
77  m_ElemRect = ElemRect;
78  }
79  PIXELS_t get_ElemWidth(void) const
80  {
82  return m_ElemRect.Width() ;
83  }
84  PIXELS_t get_ElemHeight(void) const
85  {
86  return m_ElemRect.Height() ;
87  }
88 
90  D3DCOLOR get_SpriteColor(void) const
91  {
92  return m_Color;
93  }
94  D3DCOLOR put_SpriteColor(D3DCOLOR color);
95  void put_ObjectColor(D3DCOLOR Hue, COLOR_ELEM_t HuePercent);
96  COLOR_ELEM_t get_Alpha() const noexcept
97  {
98  return m_Color.get_A() ;
99  }
100  void put_Alpha(COLOR_ELEM_t bVal)
101  {
103  m_Color.put_A(bVal);
104  }
105 
107  const cVector2f& get_Scaling(void) const
108  {
110  return m_vScaling;
111  }
112  void put_Scaling(const cVector2f& vScaling)
113  {
115  m_vScaling = vScaling;
116  }
117  void SetScalingDest(PIXELS_t cx, PIXELS_t cy);
118 
120  cVector2f get_RotationCenter(void) const
121  {
122  return m_vRotationCenter;
123  }
124  void put_RotationCenter(cVector2f vRotationCenter)
125  {
126  m_vRotationCenter = vRotationCenter;
127  }
128  RADIANf_t get_Rotation(void) const
129  {
130  return m_Rotation;
131  }
132  void put_Rotation(RADIANf_t Rotation)
133  {
134  m_Rotation = Rotation;
135  }
136  };
137 
138  class GRAY3D_LINK cDXSpriteDC : public cDXBaseT<ID3DXSprite>
139  {
142 
143  typedef cDXBaseT<ID3DXSprite> SUPER_t;
144 
145  private:
146  bool m_bDrawOpen;
147  DWORD m_dwDrawOpenFlags;
148 
149  public:
150  // DECLARE_HEAP_ALIGNED_ALLOC(cDXSpriteDC);
151  cDXSpriteDC();
152  ~cDXSpriteDC();
153 
154  ID3DXSprite* get_Sprite() const
155  {
156  return m_pDXObj;
157  }
158 
159  HRESULT MakeTransform(const cPoint2i& ptDst, const cDXSpriteElem& SpriteElem);
160 
161  HRESULT DrawBegin(DWORD dwFlags);
162  HRESULT DrawBeginText();
163  HRESULT DrawElem(const cPoint2i& ptDst, const cDXSpriteElem& SpriteElem);
164  HRESULT DrawEnd();
165  HRESULT DrawEndBatch(); // end the current batch!
166 
167  // Begin, Draw, End in one function.
168  HRESULT DrawFull(const cPoint2i& ptDst, const cDXSpriteElem& SpriteElem);
169 
170  HRESULT InitDeviceObjects(cDXDevice* pDXDev);
171  virtual HRESULT OnLostDeviceX(void)
172  {
173  ASSERT(!m_bDrawOpen);
174  return SUPER_t::OnLostDeviceX();
175  }
176  };
177 
178  class GRAY3D_LINK cDXSpriteDrawBatch
179  {
180  };
181  class GRAY3D_LINK cDXSpriteDraw
182  {
183  };
184 }
185 
186 #endif // USE_DXX
187 #endif // _INC_cDXSprite_H
#define GRAY3D_LINK
Definition: Gray3D.h:15
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
DWORD D3DCOLOR
Stuff normally defined in windows.h or DirectX headers.
Definition: cColorRef.h:24
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: IUnknown.h:68
Definition: Gray3D.cpp:12
BYTE COLOR_ELEM_t
A single 8 bit color element. alpha, red, green, or blue intensity as 0-255.
Definition: cColorRef.h:34
float RADIANf_t
type is float radians
Definition: Calc.h:27
int PIXELS_t
Count of pixels in a dimension of some image/surface.
Definition: cSurfaceInfo.h:20
const cDebugSourceLine & src
Definition: cDebugAssert.h:51