My Project
GDIGraphics.h
1 #pragma once
2 #include "GDIGraphicsPath.h"
3 #include "GDIMisc.h"
4 
5 namespace ParaEngine
6 {
7  struct TextureEntity;
8  class CGDIPen;
9  class CGDIDC;
10  struct GUITextureElement;
11  struct TextureEntity;
13  {
14  public:
15  CGDIGraphics();
16  ~CGDIGraphics();
17 
19  void SetRenderTarget(TextureEntity * pEntity);
20  TextureEntity* GetRenderTarget();
21 
23  HRESULT Render();
25  void Invalidate(bool bInvalidate = true);
27  bool IsInvalidated();
28 
38  void SetCurrentPen(const CGDIPen& pen){ m_currentPen = pen;}
39 
45  CGDIPen* CreatePen(string name);
47  CGDIPen* GetPen(string name);
48 
51  bool SaveAs(const char* filename);
53  bool LoadFromTexture(TextureEntity* pTexture);
56 
57 
59  //
60  // graphic manipulating functions
61  //
63 
65  void Reset();
66 
70  HRESULT Clear(const Color &color);
75  HRESULT DrawLine(const CGDIPen *pen,const Vector3 &point1,const Vector3 &point2);
76  HRESULT DrawLines(const CGDIPen *pen, const Vector3 *points,int nNumPoints);
77  HRESULT DrawImage(GUITextureElement *pElement,RECT *prcDest,float depth );
81  HRESULT DrawPoint(const CGDIPen *pen,const Vector3 &point);
82 
84  void Undo(int nStep=1);
86  void Redo(int nStep=1);
87 
91  void SetClip(const CGDIRegion &region);
92  const CGDIRegion* GetClip()const{return &m_region;}
93 
94  // lock the current GDC
95  CGDIDC * LockDC(){m_bLocked=true;return m_pDC;}
96  void UnlockDC(){m_bLocked=false;}
97 
105  HRESULT RestoreDeviceObjects();
113  HRESULT InvalidateDeviceObjects();
114 
115  protected:
116  HRESULT CalculatePath(CGDIGraphicsPath &pPath);
129  bool m_bLocked;
132  CGDIGraphicsPath m_path;
133  CGDIRegion m_region;
135  asset_ptr<TextureEntity> m_pDiskTexture;
136 
140  map <string, CGDIPen> m_pens;
141  private:
142  };
143 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
CGDIPen * GetPen(string name)
get a new pen object in the pen pools
Definition: GDIGraphics.cpp:80
Definition: GDIGraphics.h:12
Definition: GDIGraphicsPath.h:25
different physics engine has different winding order.
Definition: EventBinding.h:32
asset_ptr< TextureEntity > m_pDiskTexture
the texture entity that is saved and persistent to disk file.
Definition: GDIGraphics.h:135
void Reset()
reset to be reused.
Definition: GDIGraphics.cpp:45
Definition: ManagedDef.h:18
TextureEntity * GetDiskTexture()
get the current disk texture.
Definition: GDIGraphics.cpp:345
HRESULT Render()
render to the current DC
Definition: GDIGraphics.cpp:152
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
map< string, CGDIPen > m_pens
available pens
Definition: GDIGraphics.h:140
bool LoadFromTexture(TextureEntity *pTexture)
load the texture from a disk image.The current graphics will be reset.
Definition: GDIGraphics.cpp:277
CGDIPen m_currentPen
the current pen object
Definition: GDIGraphics.h:138
CGDIPen * CreatePen(string name)
create a new pen object in the pen pools
Definition: GDIGraphics.cpp:69
void Undo(int nStep=1)
undo a certain amount of steps
Definition: GDIGraphics.cpp:59
void SetClip(const CGDIRegion &region)
Set the current clipping rectangle for the path.
Definition: GDIGraphics.cpp:90
bool m_bInvalidated
if this is true, the graphics will be redrawn at the next render frame
Definition: GDIGraphics.h:131
HRESULT DrawPoint(const CGDIPen *pen, const Vector3 &point)
Draw a point with a specific pen, the operation is pending.
Definition: GDIGraphics.cpp:141
a texture from a rectangular region of bitmap, and one additional texture color
Definition: GUIResource.h:12
Definition: GDIDC.h:13
void SetCurrentPen(const CGDIPen &pen)
set the current pen object
Definition: GDIGraphics.h:38
bool SaveAs(const char *filename)
save the current texture to disk file.
Definition: GDIGraphics.cpp:293
CGDIPen * GetCurrentPen()
get the current pen object
Definition: GDIGraphics.h:33
HRESULT RestoreDeviceObjects()
This callback function will be called immediately after the Direct3D device has been reset...
Definition: GDIGraphics.cpp:253
a pen object in the GDI class
Definition: GDIPen.h:9
bool IsInvalidated()
whether it is invalidated
Definition: GDIGraphics.cpp:40
We always shape the region points and edges in clockwise.
Definition: GDIRegion.h:29
void Invalidate(bool bInvalidate=true)
Invalidate the graphics, causing the entire render target to be redrawn at the next render call...
Definition: GDIGraphics.cpp:35
CGDIDC * m_pDC
Calculate the two vertices for one end of a given line.
Definition: GDIGraphics.h:128
Definition: ParaColor.h:275
void Redo(int nStep=1)
redo a certain amount of steps
Definition: GDIGraphics.cpp:64
void SetRenderTarget(TextureEntity *pEntity)
this will internally create the CGDIDC object from the render target texture.
Definition: GDIGraphics.cpp:97
HRESULT InvalidateDeviceObjects()
This callback function will be called immediately after the Direct3D device has entered a lost state ...
Definition: GDIGraphics.cpp:258
HRESULT DrawLine(const CGDIPen *pen, const Vector3 &point1, const Vector3 &point2)
Draw a line with a specific pen, the operation is pending If point1=point2, the line will not draw...
Definition: GDIGraphics.cpp:112
HRESULT Clear(const Color &color)
Clears the current render target of the CGDIGraphics.
Definition: GDIGraphics.cpp:51