Direct2Dのサンプルソースを改造しながら書いたためこんな設計になってます。
もともとこのソースが文字と画像を表示するだけのもので、それを改造していったのですが
初期からDemoApp内に画像を読み込む関数や実質のメインループやプロシージャが入っています。
やはりそれらは別のクラスに分けるべきですかね?
コード:
class DemoApp
{
public:
HRESULT hr;
DemoApp();
~DemoApp();
HRESULT Initialize();
int wait();//自分で追加
int GetKey();//追加
int GameMain();//追加
void RunMessageLoop();
ID2D1Bitmap* LoadGr(TCHAR *text);//パッケージ関数
private:
/**********************************/
void paint(ID2D1Bitmap *Gr , float x , float y);//パッケージ関数
void ClearScreen();//パッケージ関数
/**********************************/
HRESULT CreateDeviceIndependentResources();
HRESULT CreateDeviceResources();
HRESULT CreateGridPatternBrush(
ID2D1RenderTarget *pRenderTarget,
ID2D1BitmapBrush **ppBitmapBrush
);
void DiscardDeviceResources();
HRESULT OnRender(ID2D1Bitmap *Gr,float x,float y);//もとのコードでは引数無し
void OnResize(
UINT width,
UINT height
);
static LRESULT CALLBACK WndProc(
HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam
);
HRESULT LoadResourceBitmap(
ID2D1RenderTarget *pRenderTarget,
IWICImagingFactory *pIWICFactory,
PCWSTR resourceName,
PCWSTR resourceType,
UINT destinationWidth,
UINT destinationHeight,
ID2D1Bitmap **ppBitmap
);
HRESULT LoadBitmapFromFile(
ID2D1RenderTarget *pRenderTarget,
IWICImagingFactory *pIWICFactory,
PCWSTR uri,
UINT destinationWidth,
UINT destinationHeight,
ID2D1Bitmap **ppBitmap
);
private:
HWND m_hwnd;
ID2D1Factory *m_pD2DFactory;
IWICImagingFactory *m_pWICFactory;
IDWriteFactory *m_pDWriteFactory;
ID2D1HwndRenderTarget *m_pRenderTarget;
IDWriteTextFormat *m_pTextFormat;
ID2D1PathGeometry *m_pPathGeometry;
ID2D1LinearGradientBrush *m_pLinearGradientBrush;
ID2D1SolidColorBrush *m_pBlackBrush;
ID2D1BitmapBrush *m_pGridPatternBitmapBrush;
// ID2D1Bitmap *m_pBitmap;
ID2D1Bitmap *m_pAnotherBitmap;
};