00001
00002
00003
00004
00005 #include "MFCBase.h"
00006 #include "DxMGRView.h"
00007 #include "RwGRDoc.h"
00008
00009
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015
00016
00017 using namespace jbxl;
00018 using namespace jbxwl;
00019
00020
00021
00023
00024
00025 IMPLEMENT_DYNCREATE(CDxMGRView, CExView)
00026
00027
00028 CDxMGRView::CDxMGRView()
00029 {
00030 cnstXYRate = true;
00031
00032 renderRect.left = 0;
00033 renderRect.top = 0;
00034 renderRect.right = 0;
00035 renderRect.bottom = 0;
00036
00037 cMax = VIEW_8_MAX;
00038 cMin = 0;
00039
00040 vSBntch = 1;
00041 }
00042
00043
00044
00045 CDxMGRView::~CDxMGRView()
00046 {
00047
00048 }
00049
00050
00051
00052 BEGIN_MESSAGE_MAP(CDxMGRView, CDxBaseView)
00053
00054
00055 END_MESSAGE_MAP()
00056
00057
00058
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00072
00073
00074 #ifdef _DEBUG
00075 void CDxMGRView::AssertValid() const
00076 {
00077 CDxBaseView::AssertValid();
00078 }
00079
00080
00081 void CDxMGRView::Dump(CDumpContext& dc) const
00082 {
00083 CDxBaseView::Dump(dc);
00084 }
00085 #endif //_DEBUG
00086
00087
00088
00090
00091
00092
00093
00094
00095
00096
00097
00098 void CDxMGRView::OnInitialUpdate()
00099 {
00100 cmnHead = pDoc->cmnHead;
00101 if (isNull(cmnHead.grptr)) return;
00102
00103 colorMode = pDoc->colorMode & GRAPH_COLOR_MASK;
00104 if (pDoc->colorMode & GRAPH_COLOR_USE_PLANE) usePlane = true;
00105
00106 if (usePlane) {
00107 if (colorMode==GRAPH_COLOR_RGB && cmnHead.zsize!=3) colorMode = GRAPH_COLOR_MONO;
00108 else if (colorMode==GRAPH_COLOR_BGR && cmnHead.zsize!=3) colorMode = GRAPH_COLOR_MONO;
00109 else if (colorMode==GRAPH_COLOR_ARGB && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO;
00110 else if (colorMode==GRAPH_COLOR_ABGR && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO;
00111 else if (colorMode==GRAPH_COLOR_RGBA && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO;
00112 else if (colorMode==GRAPH_COLOR_BGRA && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO;
00113 else if (colorMode==GRAPH_COLOR_XRGB && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO;
00114 else if (colorMode==GRAPH_COLOR_XBGR && cmnHead.zsize!=4) colorMode = GRAPH_COLOR_MONO;
00115 }
00116 if (colorMode==GRAPH_COLOR_MONO) usePlane = false;
00117
00118
00119 xsize = cmnHead.xsize;
00120 ysize = cmnHead.ysize;
00121
00122
00123 if (colorMode==GRAPH_COLOR_RGB || colorMode==GRAPH_COLOR_BGR ||
00124 colorMode==GRAPH_COLOR_XRGB || colorMode==GRAPH_COLOR_ARGB || colorMode==GRAPH_COLOR_RGBA ||
00125 colorMode==GRAPH_COLOR_XBGR || colorMode==GRAPH_COLOR_ABGR || colorMode==GRAPH_COLOR_BGRA) {
00126 if (viewMode==VIEW_ZDIR) {
00127 xsize = cmnHead.xsize;
00128 ysize = cmnHead.ysize;
00129 zsize = 1;
00130 }
00131 else {
00132 CString mesg;
00133 mesg.LoadString(IDS_STR_UNSPT_VWMODE);
00134 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00135 pFrame->doneErrorMessage = TRUE;
00136 return;
00137 }
00138 }
00139
00140 else {
00141 if (viewMode==VIEW_ZDIR) {
00142 xsize = cmnHead.xsize;
00143 ysize = cmnHead.ysize;
00144 zsize = cmnHead.zsize;
00145 }
00146 else if (viewMode==VIEW_XDIR) {
00147 xsize = cmnHead.ysize;
00148 ysize = cmnHead.zsize;
00149 zsize = cmnHead.xsize;
00150 if (ysize<=1) {
00151 CString mesg;
00152 mesg.LoadString(IDS_STR_INVLD_VWMODE);
00153 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00154 pFrame->doneErrorMessage = TRUE;
00155 return;
00156 }
00157 }
00158 else if (viewMode==VIEW_YDIR) {
00159 xsize = cmnHead.xsize;
00160 ysize = cmnHead.zsize;
00161 zsize = cmnHead.ysize;
00162 if (ysize<=1) {
00163 CString mesg;
00164 mesg.LoadString(IDS_STR_INVLD_VWMODE);
00165 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00166 pFrame->doneErrorMessage = TRUE;
00167 return;
00168 }
00169
00170 }
00171 else {
00172 CString mesg;
00173 mesg.LoadString(IDS_STR_UNKWN_VWMODE);
00174 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00175 pFrame->doneErrorMessage = TRUE;
00176 return;
00177 }
00178 }
00179
00180
00181 cMax = pDoc->cMax;
00182 cMin = pDoc->cMin;
00183 vMax = pDoc->vMax;
00184 vMin = pDoc->vMin;
00185
00186
00187 D3DFORMAT format;
00188
00189
00190
00191 if (colorMode==GRAPH_COLOR_RGB || colorMode==GRAPH_COLOR_BGR) {
00192
00193
00194 viewData.set(xsize, ysize, 1, 24);
00195 format = D3DFMT_X8R8G8B8;
00196 vMax = cMax = VIEW_8_MAX;
00197 vMin = cMin = VIEW_8_MIN;
00198 }
00199
00200 else if (colorMode==GRAPH_COLOR_ARGB || colorMode==GRAPH_COLOR_RGBA) {
00201 viewData.set(xsize, ysize, 1, 32);
00202 format = D3DFMT_A8R8G8B8;
00203 vMax = cMax = VIEW_8_MAX;
00204 vMin = cMin = VIEW_8_MIN;
00205 }
00206
00207 else if (colorMode==GRAPH_COLOR_XRGB) {
00208 viewData.set(xsize, ysize, 1, 32);
00209 format = D3DFMT_X8R8G8B8;
00210 vMax = cMax = VIEW_8_MAX;
00211 vMin = cMin = VIEW_8_MIN;
00212 }
00213
00214 else if (colorMode==GRAPH_COLOR_ABGR || colorMode==GRAPH_COLOR_BGRA) {
00215 viewData.set(xsize, ysize, 1, 32);
00216 format = D3DFMT_A8R8G8B8;
00217 vMax = cMax = VIEW_8_MAX;
00218 vMin = cMin = VIEW_8_MIN;
00219 }
00220
00221 else if (colorMode==GRAPH_COLOR_XBGR) {
00222 viewData.set(xsize, ysize, 1, 32);
00223 format = D3DFMT_X8R8G8B8;
00224 vMax = cMax = VIEW_8_MAX;
00225 vMin = cMin = VIEW_8_MIN;
00226 }
00227
00228 else if (colorMode==GRAPH_COLOR_ARGB16 || colorMode==GRAPH_COLOR_RGBA16) {
00229
00230
00231 viewData.set(xsize, ysize, 1, 16);
00232 format = D3DFMT_A4R4G4B4;
00233 vMax = cMax = SWORDMAX;
00234 vMin = cMin = SWORDMIN;
00235 }
00236
00237 else if (colorMode==GRAPH_COLOR_RGB16) {
00238
00239
00240 viewData.set(xsize, ysize, 1, 16);
00241 format = D3DFMT_R5G6B5;
00242 vMax = cMax = SWORDMAX;
00243 vMin = cMin = SWORDMIN;
00244 }
00245
00246 else {
00247
00248
00249 viewData.set(xsize, ysize);
00250 format = D3DFMT_R5G6B5;
00251 }
00252
00253
00254 origXSize = xsize;
00255 origYSize = ysize;
00256 sizeXYRate = (double)ysize/(double)xsize;
00257
00258 renderRect.top = 0;
00259 renderRect.left = 0;
00260 renderRect.right = xsize;
00261 renderRect.bottom = ysize;
00262 vSBmax = zsize - 1;
00263
00264 SetScrollRange(SB_VERT, 0, vSBmax);
00265 SetScrollPos(SB_VERT, vSBpos);
00266
00267
00268
00269
00270 BOOL rslt = InitDevice(xsize, ysize);
00271 if (!rslt) {
00272 CString mesg;
00273 mesg.LoadString(IDS_STR_FAIL_GET_DX9DEV);
00274 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00275 pFrame->doneErrorMessage = TRUE;
00276 return;
00277 }
00278
00279 bufferSize = Dx9GetBackBuffer(lpD3DDevice, &lpBackBuffer);
00280 if (bufferSize.x<0) {
00281 CString mesg;
00282 mesg.LoadString(IDS_STR_FAIL_CRT_BAKBUF);
00283 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00284 return;
00285 }
00286
00287 HRESULT hr = lpD3DDevice->CreateOffscreenPlainSurface(xsize, ysize, format, D3DPOOL_DEFAULT, &lpSurface, NULL);
00288 if (FAILED(hr)) {
00289 CString mesg;
00290 mesg.LoadString(IDS_STR_FAIL_CRT_SURFACE);
00291 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00292 pFrame->doneErrorMessage = TRUE;
00293 return;
00294 }
00295
00296 hasViewData = SetNewSurface(vSBpos);
00297 if (!hasViewData) {
00298 CString mesg;
00299 mesg.LoadString(IDS_STR_FAIL_TRNS_SURFACE);
00300 MessageBox(_T("CDxMGRView::OnInitialUpdate():\n\n") + mesg);
00301 pFrame->doneErrorMessage = TRUE;
00302 return;
00303 }
00304
00305
00306
00307 SetWindowSize(viewData.xsize, viewData.ysize);
00308 return;
00309 }
00310
00311
00312
00313 BOOL CDxMGRView::SetNewSurface(int dummy)
00314 {
00315 int point, n;
00316 double ca, cb;
00317 HRESULT hr;
00318
00319 if (isNull(viewData.grptr)) {
00320 CString mesg, noti;
00321 mesg.LoadString(IDS_STR_DLTD_DATA);
00322 noti.LoadString(IDS_STR_ERROR);
00323 MessageBox(_T("CDxMGRView::SetNewSurface():\n\n") + mesg, noti, MB_OK);
00324 return FALSE;
00325 }
00326
00327
00328 check_endian();
00329 MakeSetTitle();
00330
00331
00332
00333 if (cMax==cMin) cMax = cMin + 1;
00334 ca = ((double)(vMax-vMin))/((double)(cMax-cMin));
00335 cb = ((double)(vMin-cMin))/((double)(cMax-cMin));
00336
00337
00338 if (colorMode==GRAPH_COLOR_RGB) {
00339 for (int k=0; k<3; k++) {
00340 if (HostEndian==BIG_ENDIAN) n = k;
00341 else n = 2 - k;
00342 for (int j=0; j<cmnHead.ysize; j++) {
00343 for (int i=0; i<cmnHead.xsize; i++) {
00344 uByte* ptr = &viewData.point(i, j);
00345 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5);
00346 point = Min(point, VIEW_8_MAX);
00347 point = Max(point, VIEW_8_MIN);
00348 ptr[n] = point;
00349 }
00350 }
00351 }
00352
00353 int srcpitch = viewData.xsize*3;
00354 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00355 }
00356
00357
00358 else if (colorMode==GRAPH_COLOR_BGR) {
00359 for (int k=0; k<3; k++) {
00360 if (HostEndian==BIG_ENDIAN) n = 2 - k;
00361 else n = k;
00362 for (int j=0; j<cmnHead.ysize; j++) {
00363 for (int i=0; i<cmnHead.xsize; i++) {
00364 uByte* ptr = &viewData.point(i, j);
00365 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5);
00366 point = Min(point, VIEW_8_MAX);
00367 point = Max(point, VIEW_8_MIN);
00368 ptr[n] = point;
00369 }
00370 }
00371 }
00372
00373 int srcpitch = viewData.xsize*3;
00374 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00375 }
00376
00377
00378 else if (colorMode==GRAPH_COLOR_XRGB || colorMode==GRAPH_COLOR_ARGB) {
00379 for (int k=0; k<4; k++) {
00380 if (HostEndian==BIG_ENDIAN) n = k;
00381 else n = 3 - k;
00382 for (int j=0; j<cmnHead.ysize; j++) {
00383 for (int i=0; i<cmnHead.xsize; i++) {
00384 uByte* ptr = &viewData.point(i, j);
00385 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5);
00386 point = Min(point, VIEW_8_MAX);
00387 point = Max(point, VIEW_8_MIN);
00388 ptr[n] = point;
00389 }
00390 }
00391 }
00392
00393 int srcpitch = viewData.xsize*4;
00394 if (colorMode==GRAPH_COLOR_XRGB) {
00395 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_X8R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00396 }
00397 else {
00398 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00399 }
00400 }
00401
00402
00403 else if (colorMode==GRAPH_COLOR_RGBA) {
00404 for (int k=0; k<4; k++) {
00405 if (HostEndian==BIG_ENDIAN) n = 3 - k;
00406 else n = k;
00407 for (int j=0; j<cmnHead.ysize; j++) {
00408 for (int i=0; i<cmnHead.xsize; i++) {
00409 uByte* ptr = &viewData.point(i, j);
00410 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5);
00411 point = Min(point, VIEW_8_MAX);
00412 point = Max(point, VIEW_8_MIN);
00413 ptr[n] = point;
00414 }
00415 }
00416 }
00417
00418 int srcpitch = viewData.xsize*4;
00419 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8B8G8R8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00420 }
00421
00422
00423 else if (colorMode==GRAPH_COLOR_XBGR || colorMode==GRAPH_COLOR_ABGR) {
00424 for (int k=0; k<4; k++) {
00425 if (HostEndian==BIG_ENDIAN) n = k;
00426 else n = 3 - k;
00427 for (int j=0; j<cmnHead.ysize; j++) {
00428 for (int i=0; i<cmnHead.xsize; i++) {
00429 uByte* ptr = &viewData.point(i, j);
00430 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5);
00431 point = Min(point, VIEW_8_MAX);
00432 point = Max(point, VIEW_8_MIN);
00433 ptr[n] = point;
00434 }
00435 }
00436 }
00437
00438 int srcpitch = viewData.xsize*4;
00439 if (colorMode==GRAPH_COLOR_XBGR) {
00440 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_X8B8G8R8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00441 }
00442 else {
00443 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8B8G8R8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00444 }
00445 }
00446
00447
00448 else if (colorMode==GRAPH_COLOR_BGRA) {
00449 for (int k=0; k<4; k++) {
00450 if (HostEndian==BIG_ENDIAN) n = 3 - k;
00451 else n = k;
00452 for (int j=0; j<cmnHead.ysize; j++) {
00453 for (int i=0; i<cmnHead.xsize; i++) {
00454 uByte* ptr = &viewData.point(i, j);
00455 point = (int)(cmnHead.point(i, j, k)*ca + VIEW_8_MAX*cb + 0.5);
00456 point = Min(point, VIEW_8_MAX);
00457 point = Max(point, VIEW_8_MIN);
00458 ptr[n] = point;
00459 }
00460 }
00461 }
00462
00463 int srcpitch = viewData.xsize*4;
00464 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A8R8G8B8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00465 }
00466
00467
00468 else if (colorMode==GRAPH_COLOR_RGB16 || colorMode==GRAPH_COLOR_ARGB16 || colorMode==GRAPH_COLOR_RGBA16) {
00469 uWord* src = NULL;
00470 uWord* dst = NULL;
00471
00472 if (prevSBpos!=vSBpos) {
00473 if (viewMode==VIEW_ZDIR) {
00474 for (int j=0; j<cmnHead.ysize; j++) {
00475 for (int i=0; i<cmnHead.xsize; i++) {
00476 src = (uWord*)&cmnHead.point(i, j, vSBpos);
00477 dst = (uWord*)&viewData.point(i, j);
00478 point = (int)(*src*ca + vMax*cb + 0.5);
00479
00480
00481 *dst = point;
00482 }
00483 }
00484 }
00485 else if (viewMode==VIEW_XDIR) {
00486 for (int j=0; j<cmnHead.zsize; j++) {
00487 for (int i=0; i<cmnHead.ysize; i++) {
00488 src = (uWord*)&cmnHead.point(vSBpos, i, j);
00489 dst = (uWord*)&viewData.point(i, j);
00490 point = (int)(*src*ca + vMax*cb + 0.5);
00491
00492
00493 *dst = point;
00494 }
00495 }
00496 }
00497 else if (viewMode==VIEW_YDIR) {
00498 for (int j=0; j<cmnHead.zsize; j++) {
00499 for (int i=0; i<cmnHead.xsize; i++) {
00500 src = (uWord*)&cmnHead.point(i, cmnHead.ysize-1-vSBpos, j);
00501 dst = (uWord*)&viewData.point(i, j);
00502 point = (int)(*src*ca + vMax*cb + 0.5);
00503
00504
00505 *dst = point;
00506 }
00507 }
00508 }
00509 else return FALSE;
00510 }
00511
00512 ntoh_data(viewData.grptr, viewData.lsize, 2);
00513 int srcpitch = viewData.xsize*2;
00514 if (colorMode==GRAPH_COLOR_RGB16) {
00515 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_R5G6B5, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00516 }
00517 else if (colorMode==GRAPH_COLOR_ARGB16) {
00518 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A4R4G4B4, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00519 }
00520 else {
00521
00522 for (int i=0; i<viewData.xsize*viewData.ysize*2; i+=2) {
00523 int r = (viewData.grptr[i] &0xf0)>>4;
00524 int g = (viewData.grptr[i] &0x0f)<<4;
00525 int b = (viewData.grptr[i+1]&0xf0)>>4;
00526 int a = (viewData.grptr[i+1]&0x0f)<<4;
00527 viewData.grptr[i] = (uByte)(a + r);
00528 viewData.grptr[i+1] = (uByte)(g + b);
00529 }
00530 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_A4R4G4B4, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00531 }
00532 }
00533
00534
00535 else if (colorMode==GRAPH_COLOR_MONO || colorMode==GRAPH_COLOR_MONO16) {
00536 if (prevSBpos!=vSBpos) {
00537 if (viewMode==VIEW_ZDIR) {
00538 for (int j=0; j<cmnHead.ysize; j++) {
00539 for (int i=0; i<cmnHead.xsize; i++) {
00540 point = (int)(cmnHead.point(i, j, vSBpos)*ca + VIEW_8_MAX*cb + 0.5);
00541 point = Min(point, VIEW_8_MAX);
00542 point = Max(point, 0);
00543 viewData.point(i, j) = point;
00544 }
00545 }
00546 }
00547 else if (viewMode==VIEW_XDIR) {
00548 for (int j=0; j<cmnHead.zsize; j++) {
00549 for (int i=0; i<cmnHead.ysize; i++) {
00550 point = (int)(cmnHead.point(vSBpos, i, j)*ca + VIEW_8_MAX*cb + 0.5);
00551 point = Min(point, VIEW_8_MAX);
00552 point = Max(point, 0);
00553 viewData.point(i, j) = point;
00554 }
00555 }
00556 }
00557 else if (viewMode==VIEW_YDIR) {
00558 for (int j=0; j<cmnHead.zsize; j++) {
00559 for (int i=0; i<cmnHead.xsize; i++) {
00560 point = (int)(cmnHead.point(i, cmnHead.ysize-1-vSBpos, j)*ca + VIEW_8_MAX*cb + 0.5);
00561 point = Min(point, VIEW_8_MAX);
00562 point = Max(point, 0);
00563 viewData.point(i, j) = point;
00564 }
00565 }
00566 }
00567 else return FALSE;
00568 }
00569
00570
00571 int srcpitch = viewData.xsize;
00572 hr = D3DXLoadSurfaceFromMemory(lpSurface, NULL, NULL, viewData.grptr, D3DFMT_L8, srcpitch, NULL, &renderRect, D3DX_FILTER_NONE, 0);
00573 }
00574
00575 if (FAILED(hr)) return FALSE;
00576
00577 return TRUE;
00578 }
00579
00580
00581
00582 void CDxMGRView::ExecRender()
00583 {
00584 HRESULT hr;
00585
00586 MakeSetTitle();
00587
00588 hr = lpD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0);
00589 if (FAILED(hr)) {
00590 CString mesg;
00591 mesg.LoadString(IDS_STR_FAIL_CLR_WND);
00592 MessageBox(_T("CDxMGRView::ExecRender():\n\n") + mesg);
00593 return;
00594 }
00595
00596 hr = lpD3DDevice->StretchRect(lpSurface, NULL, lpBackBuffer, NULL, D3DTEXF_NONE);
00597 if (FAILED(hr)) {
00598 CString mesg;
00599 mesg.LoadString(IDS_STR_FAIL_TRNS_BAKBUF);
00600 MessageBox(_T("CDxMGRView::ExecRender():\n\n") + mesg);
00601 return;
00602 }
00603
00604 hr = lpD3DDevice->Present(NULL, NULL, NULL, NULL);
00605 if (FAILED(hr)) {
00606 hr = ResetDx9Device(lpD3DDevice, &d3dParam, this);
00607 if (FAILED(hr)) {
00608 CString mesg;
00609 mesg.LoadString(IDS_STR_FAIL_RESTR_DX9DEV);
00610 MessageBox(_T("CDxMGRView::ExecRender():\n\n") + mesg);
00611 pFrame->SendMessage(WM_CLOSE);
00612
00613 }
00614 else ExecRender();
00615 }
00616 }
00617
00618
00619
00620 void CDxMGRView::InitObject()
00621 {
00622 bufferSize = Dx9GetBackBuffer(lpD3DDevice, &lpBackBuffer);
00623 if (bufferSize.x<0) {
00624 CString mesg;
00625 mesg.LoadString(IDS_STR_FAIL_REGET_BAKBUF);
00626 MessageBox(_T("CDxMGRView::InitObject():\n\n") + mesg);
00627 return;
00628 }
00629
00630 HRESULT hr;
00631 if (colorMode==GRAPH_COLOR_RGB || colorMode==GRAPH_COLOR_BGR) {
00632 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL);
00633 }
00634 else if (colorMode==GRAPH_COLOR_ARGB || colorMode==GRAPH_COLOR_RGBA) {
00635 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL);
00636 }
00637 else if (colorMode==GRAPH_COLOR_XRGB) {
00638 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL);
00639 }
00640 else if (colorMode==GRAPH_COLOR_ABGR || colorMode==GRAPH_COLOR_BGRA) {
00641 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL);
00642 }
00643 else if (colorMode==GRAPH_COLOR_XBGR) {
00644 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &lpSurface, NULL);
00645 }
00646 else if (colorMode==GRAPH_COLOR_ARGB16 || colorMode==GRAPH_COLOR_RGBA16) {
00647 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &lpSurface, NULL);
00648 }
00649 else {
00650 hr = lpD3DDevice->CreateOffscreenPlainSurface(viewData.xsize, viewData.ysize, D3DFMT_R5G6B5, D3DPOOL_DEFAULT, &lpSurface, NULL);
00651 }
00652
00653 if (FAILED(hr)) {
00654 CString mesg;
00655 mesg.LoadString(IDS_STR_FAIL_REGET_SURFACE);
00656 MessageBox(_T("CDxMGRView::InitObject():\n\n") + mesg);
00657 return;
00658 }
00659
00660 hasViewData = SetNewSurface(vSBpos);
00661 if (!hasViewData) {
00662 CString mesg;
00663 mesg.LoadString(IDS_STR_FAIL_RETRNS_SURFACE);
00664 MessageBox(_T("CDxMGRView::InitObject():\n\n") + mesg);
00665 return;
00666 }
00667 return;
00668 }
00669
00670
00671
00672 void CDxMGRView::MakeSetTitle()
00673 {
00674 Title = pDoc->preTitle + pDoc->Title + pDoc->pstTitle;
00675 if (vSBmax>=1) {
00676 CString mesg;
00677 mesg.LoadString(IDS_STR_IMG_NUM);
00678 mesg = _T(" ") + mesg + _T(" %d");
00679 int no = pDoc->startNo + vSBpos*Sign(pDoc->endNo - pDoc->startNo);
00680
00681 Title += numbering_name_t((LPCTSTR)mesg, no);
00682 }
00683
00684 if (clientRate!=1.0) {
00685 CString szprcnt;
00686 szprcnt.Format(_T(" (%d%%)"), (int)(clientRate*100+0.5));
00687 Title = Title + szprcnt;
00688 }
00689 this->SetTitle(Title);
00690 }
00691