JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
Dx2DView.cpp
Go to the documentation of this file.
1//
2// CDx2DView.cpp : インプリメンテーション ファイル
3//
4
5#include "MFCBase.h"
6#include "Dx2DView.h"
7
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15
16using namespace jbxl;
17using namespace jbxwl;
18
19
21// CDx2DView
22
23IMPLEMENT_DYNCREATE(CDx2DView, CExView)
24
25
27{
28 cnstXYRate = true;
29}
30
31
32//
36
37
38BEGIN_MESSAGE_MAP(CDx2DView, CDxBaseView)
39 //{{AFX_MSG_MAP(CDx2DView)
40 // メモ - ClassWizard はこの位置にマッピング用のマクロを追加または削除します.
41 //}}AFX_MSG_MAP
42END_MESSAGE_MAP()
43
44
45
46
47// CDx2DView 描画
48/*
49void CDx2DView::OnDraw(CDC* pDC)
50{
51 ExecWindowReSize();
52 ExecRender();
53}
54*/
55
56
57
58
59// CDx2DView 診断
60
61#ifdef _DEBUG
66
67
68//
69void CDx2DView::Dump(CDumpContext& dc) const
70{
72}
73#endif //_DEBUG
74
75
76
78// CDx2DView メッセージ ハンドラ
79
80//
81// デバイスを初期化して,サーフェイスに表示データを読み込む
82//
84{
86 if (isNull(cmnHead.grptr)) return;
87
88 origXSize = cmnHead.xsize;
89 origYSize = cmnHead.ysize;
90 sizeXYRate = (double)cmnHead.ysize/(double)cmnHead.xsize;
91
92 BOOL rslt = InitDevice(cmnHead.xsize, cmnHead.ysize);
93 if (!rslt) {
95 mesg.LoadString(IDS_STR_FAIL_GET_DX9DEV);
96 MessageBox(_T("CDx2DView::OnInitialUpdate():\n\n") + mesg);
98 return;
99 }
100
101 // グラフィックデータ
103 if (bufferSize.x<0) {
105 mesg.LoadString(IDS_STR_FAIL_CRT_BAKBUF);
106 MessageBox(_T("CDx2DView::OnInitialUpdate():\n\n") + mesg);
108 return;
109 }
110
111 // サーフェイスを作成して表示データを読み込む
113 if (!hasViewData) {
116 MessageBox(_T("CDx2DView::OnInitialUpdate():\n\n") + mesg);
118 return;
119 }
120
122 return;
123}
124
125
127{
128 //
130 if (clientRate!=1.0) {
132 szprcnt.Format(_T(" (%d%%)"), (int)(clientRate*100+0.5));
133 Title = Title + szprcnt;
134 }
136 mesg1.LoadString(IDS_STR_UNSPT_DATA);
137 mesg2.LoadString(IDS_STR_IMP_PROCESS);
138 Title = Title + _T(" ") + mesg1 + _T(" [") + mesg2 + _T("]");
139 this->SetTitle(Title);
140
141 HRESULT hr;
142
143 hr = lpD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0);
144 if (FAILED(hr)) {
146 mesg.LoadString(IDS_STR_FAIL_CLR_WND);
147 MessageBox(_T("CDx2DView::ExecRender():\n\n") + mesg);
148 return;
149 }
150
152 if (FAILED(hr)) {
154 mesg.LoadString(IDS_STR_FAIL_TRNS_BAKBUF);
155 MessageBox(_T("CDx2DView::ExecRender():\n\n") + mesg);
156 return;
157 }
158
159 hr = lpD3DDevice->Present(NULL, NULL, NULL, NULL);
160 if (FAILED(hr)) {
162 if (FAILED(hr)) {
165 MessageBox(_T("CDx2DView::ExecRender():\n\n") + mesg);
166 pFrame->SendMessage(WM_CLOSE);
167 //GetParentFrame()->DestroyWindow();
168 }
169 else ExecRender();
170 }
171}
172
173
174//
176{
179 if (!hasViewData) {
181 mesg.LoadString(IDS_STR_FAIL_REINIT_OBJ);
182 MessageBox(_T("CDx2DView::InitObject():\n\n") + mesg);
183 return;
184 }
185}
static char THIS_FILE[]
Definition Dx2DView.cpp:12
virtual void OnInitialUpdate()
Definition Dx2DView.cpp:83
virtual void ExecRender()
Definition Dx2DView.cpp:126
virtual ~CDx2DView()
Definition Dx2DView.cpp:33
virtual void AssertValid() const
Definition Dx2DView.cpp:62
virtual void Dump(CDumpContext &dc) const
Definition Dx2DView.cpp:69
virtual void InitObject(void)
Definition Dx2DView.cpp:175
LPDIRECT3DDEVICE9 lpD3DDevice
D3DPRESENT_PARAMETERS d3dParam
LPDIRECT3DSURFACE9 lpBackBuffer
BOOL InitDevice(int xsize=0, int ysize=0, CWnd *cwnd=NULL)
LPDIRECT3DSURFACE9 lpSurface
ExCmnHead cmnHead
Definition ExDocument.h:53
bool doneErrorMessage
Definition ExFrame.h:51
ExCmnHead cmnHead
Definition ExView.h:73
CString Title
Definition ExView.h:83
BOOL hasViewData
Definition ExView.h:81
int origYSize
Definition ExView.h:95
CExFrame * pFrame
Definition ExView.h:77
double sizeXYRate
Definition ExView.h:86
int origXSize
Definition ExView.h:94
void SetTitle(LPCTSTR title)
Definition ExView.cpp:348
CExDocument * pDoc
Definition ExView.h:76
virtual void AssertValid() const
Definition ExView.cpp:130
virtual void Dump(CDumpContext &dc) const
Definition ExView.cpp:136
POINT SetWindowSize(int xs, int ys, BOOL first=TRUE)
Definition ExView.cpp:156
double clientRate
Definition ExView.h:87
HRESULT ResetDx9Device(LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS *, CDxBaseView *pviw=NULL)
POINT Dx9GetBackBuffer(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9 *)
Definition Dx9.cpp:175
BOOL Dx9SurfaceFromMemory(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9 *, CmnHead)
Definition Dx9.cpp:198
#define IDS_STR_FAIL_RESTR_DX9DEV
Definition resource.h:65
#define IDS_STR_FAIL_GET_DX9DEV
Definition resource.h:59
#define IDS_STR_FAIL_REINIT_OBJ
Definition resource.h:67
#define IDS_STR_FAIL_CLR_WND
Definition resource.h:64
#define IDS_STR_FAIL_TRNS_BAKBUF
Definition resource.h:61
#define IDS_STR_UNSPT_DATA
Definition resource.h:94
#define IDS_STR_FAIL_CRT_BAKBUF
Definition resource.h:60
#define IDS_STR_IMP_PROCESS
Definition resource.h:95
#define IDS_STR_FAIL_TRNS_SURFACE
Definition resource.h:63