Isle
Loading...
Searching...
No Matches
legovideomanager.cpp
Go to the documentation of this file.
1#include "legovideomanager.h"
2
4#include "legoinputmanager.h"
5#include "legomain.h"
6#include "misc.h"
10#include "mxdisplaysurface.h"
11#include "mxgeometry/mxmatrix.h"
12#include "mxmisc.h"
13#include "mxpalette.h"
14#include "mxregion.h"
15#include "mxtimer.h"
16#include "mxtransitionmanager.h"
17#include "realtime/realtime.h"
18#include "roi/legoroi.h"
19#include "tgl/d3drm/impl.h"
20#include "viewmanager/viewroi.h"
21
22#include <stdio.h>
23
27
28// FUNCTION: LEGO1 0x1007aa20
30{
31 m_renderer = NULL;
32 m_3dManager = NULL;
33 m_viewROI = NULL;
34 m_direct3d = NULL;
35 m_unk0xe6 = FALSE;
36 memset(m_unk0x78, 0, sizeof(m_unk0x78));
37 m_unk0x78[0] = 0x6c;
38 m_phonemeRefList = NULL;
39 m_isFullscreenMovie = FALSE;
40 m_palette = NULL;
41 m_stopWatch = NULL;
42 m_drawCursor = FALSE;
43 m_cursorX = m_cursorY;
44 m_cursorYCopy = m_cursorY;
45 m_cursorXCopy = m_cursorY;
46 m_cursorSurface = NULL;
47 m_fullScreenMovie = FALSE;
48 m_drawFPS = FALSE;
49 m_unk0x528 = NULL;
50 m_arialFont = NULL;
51 m_unk0xe5 = FALSE;
52 m_unk0x554 = FALSE;
53 m_paused = FALSE;
54}
55
56// FUNCTION: LEGO1 0x1007ab40
58{
59 Destroy();
60 delete m_palette;
61}
62
63// FUNCTION: LEGO1 0x1007abb0
64MxResult LegoVideoManager::CreateDirect3D()
65{
66 if (!m_direct3d) {
67 m_direct3d = new MxDirect3D;
68 }
69
70 return m_direct3d ? SUCCESS : FAILURE;
71}
72
73// FUNCTION: LEGO1 0x1007ac40
74// FUNCTION: BETA10 0x100d5cf4
75MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS, MxBool p_createThread)
76{
77 MxResult result = FAILURE;
78 MxBool paletteCreated = FALSE;
79 MxS32 deviceNum = -1;
80 Direct3DDeviceInfo* device = NULL;
81 MxDriver* driver = NULL;
82 LegoDeviceEnumerate deviceEnumerate;
83 Mx3DPointFloat posVec(0.0, 1.25, -50.0);
84 Mx3DPointFloat dirVec(0.0, 0.0, 1.0);
85 Mx3DPointFloat upVec(0.0, 1.0, 0.0);
86 MxMatrix outMatrix;
87 HWND hwnd = MxOmni::GetInstance()->GetWindowHandle();
88 MxS32 bits = p_videoParam.Flags().Get16Bit() ? 16 : 8;
89
90 if (!p_videoParam.GetPalette()) {
91 MxPalette* palette = new MxPalette;
92 p_videoParam.SetPalette(palette);
93
94 if (!p_videoParam.GetPalette()) {
95 goto done;
96 }
97 paletteCreated = TRUE;
98 }
99
100 PALETTEENTRY paletteEntries[256];
101 p_videoParam.GetPalette()->GetEntries(paletteEntries);
102
103 if (CreateDirect3D() != SUCCESS) {
104 goto done;
105 }
106
107 if (deviceEnumerate.DoEnumerate() != SUCCESS) {
108 goto done;
109 }
110
111 if (p_videoParam.GetDeviceName()) {
112 deviceNum = deviceEnumerate.ParseDeviceName(p_videoParam.GetDeviceName());
113 if (deviceNum >= 0) {
114 if ((deviceNum = deviceEnumerate.GetDevice(deviceNum, driver, device)) != SUCCESS) {
115 deviceNum = -1;
116 }
117 }
118 }
119
120 if (deviceNum < 0) {
121 deviceEnumerate.FUN_1009d210();
122 deviceNum = deviceEnumerate.FUN_1009d0d0();
123 deviceNum = deviceEnumerate.GetDevice(deviceNum, driver, device);
124 }
125
126 m_direct3d->SetDevice(deviceEnumerate, driver, device);
127
128 if (!driver->m_ddCaps.dwCaps2 && driver->m_ddCaps.dwSVBRops[7] != 2) {
129 p_videoParam.Flags().SetF2bit0(TRUE);
130 }
131 else {
132 p_videoParam.Flags().SetF2bit0(FALSE);
133 }
134
135 ViewROI::SetUnk101013d8(p_videoParam.Flags().GetF2bit0() == FALSE);
136
137 if (!m_direct3d->Create(
138 hwnd,
139 p_videoParam.Flags().GetFullScreen(),
140 p_videoParam.Flags().GetFlipSurfaces(),
141 p_videoParam.Flags().GetBackBuffers() == FALSE,
142 p_videoParam.GetRect().GetWidth(),
143 p_videoParam.GetRect().GetHeight(),
144 bits,
145 paletteEntries,
146 sizeof(paletteEntries) / sizeof(paletteEntries[0])
147 )) {
148 goto done;
149 }
150
152 p_videoParam,
153 m_direct3d->DirectDraw(),
154 m_direct3d->Direct3D(),
155 m_direct3d->FrontBuffer(),
156 m_direct3d->BackBuffer(),
157 m_direct3d->Clipper(),
158 p_frequencyMS,
159 p_createThread
160 ) != SUCCESS) {
161 goto done;
162 }
163
164 m_renderer = Tgl::CreateRenderer();
165
166 if (!m_renderer) {
167 goto done;
168 }
169
170 m_3dManager = new Lego3DManager;
171
172 if (!m_3dManager) {
173 goto done;
174 }
175
176 Lego3DManager::CreateStruct createStruct;
177 memset(&createStruct, 0, sizeof(createStruct));
178 createStruct.m_hWnd = LegoOmni::GetInstance()->GetWindowHandle();
179 createStruct.m_pDirectDraw = m_pDirectDraw;
183 createStruct.m_isFullScreen = FALSE;
185 createStruct.m_direct3d = m_direct3d->Direct3D();
186 createStruct.m_d3dDevice = m_direct3d->Direct3DDevice();
187
188 if (!m_3dManager->Create(createStruct)) {
189 goto done;
190 }
191
192 ViewLODList* pLODList;
193
194 if (ConfigureD3DRM() != SUCCESS) {
195 goto done;
196 }
197
198 pLODList = m_3dManager->GetViewLODListManager()->Create("CameraROI", 1);
199 m_viewROI = new TimeROI(m_renderer, pLODList, Timer()->GetTime());
200 pLODList->Release();
201
202 CalcLocalTransform(posVec, dirVec, upVec, outMatrix);
203 m_viewROI->WrappedSetLocalTransform(outMatrix);
204
205 m_3dManager->Add(*m_viewROI);
206 m_3dManager->SetPointOfView(*m_viewROI);
207
208 m_phonemeRefList = new LegoPhonemeList;
210 m_stopWatch = new MxStopWatch;
211 m_stopWatch->Start();
212
213 result = SUCCESS;
214
215done:
216 if (paletteCreated) {
217 delete p_videoParam.GetPalette();
218 p_videoParam.SetPalette(NULL);
219 }
220
221 return result;
222}
223
224// FUNCTION: LEGO1 0x1007b5e0
225// FUNCTION: BETA10 0x100d6816
227{
228 if (m_cursorSurface != NULL) {
229 m_cursorSurface->Release();
230 m_cursorSurface = NULL;
231 }
232
233 if (m_unk0x528 != NULL) {
234 m_unk0x528->Release();
235 m_unk0x528 = NULL;
236 }
237
238 if (m_arialFont != NULL) {
239 DeleteObject(m_arialFont);
240 m_arialFont = NULL;
241 }
242
243 delete m_renderer;
244
245 if (m_viewROI != NULL) {
246 if (m_3dManager != NULL) {
247 m_3dManager->Remove(*m_viewROI);
248 }
249
250 delete m_viewROI;
251 }
252
253 delete m_3dManager;
255 delete m_phonemeRefList;
256 delete m_stopWatch;
257}
258
259// FUNCTION: LEGO1 0x1007b6a0
260void LegoVideoManager::MoveCursor(MxS32 p_cursorX, MxS32 p_cursorY)
261{
262 m_cursorX = p_cursorX;
263 m_cursorY = p_cursorY;
264 m_drawCursor = TRUE;
265
266 if (623 < p_cursorX) {
267 m_cursorX = 623;
268 }
269
270 if (463 < p_cursorY) {
271 m_cursorY = 463;
272 }
273}
274
275// FUNCTION: LEGO1 0x1007b6f0
277{
278 if (p_visible && !m_drawFPS) {
279 m_drawFPS = TRUE;
280 m_unk0x550 = 1.0;
281 m_unk0x54c = Timer()->GetTime();
282 }
283 else {
284 m_drawFPS = p_visible;
285 }
286}
287
288// FUNCTION: LEGO1 0x1007b770
290{
291 if (m_unk0x554 && !m_videoParam.Flags().GetFlipSurfaces() &&
292 TransitionManager()->GetTransitionType() == MxTransitionManager::e_idle) {
293 Sleep(30);
294 }
295
296 m_stopWatch->Stop();
297 m_elapsedSeconds = m_stopWatch->ElapsedSeconds();
298 m_stopWatch->Reset();
299 m_stopWatch->Start();
300
301 m_direct3d->RestoreSurfaces();
302
304
305 MxPresenter* presenter;
307
308 while (cursor.Next(presenter)) {
309 presenter->Tickle();
310 }
311
312 if (m_render3d && !m_paused) {
313 m_3dManager->GetLego3DView()->GetView()->Clear();
314 }
315
317 InvalidateRect(rect);
318
319 if (!m_paused && (m_render3d || m_unk0xe5)) {
320 cursor.Reset();
321
322 while (cursor.Next(presenter) && presenter->GetDisplayZ() >= 0) {
323 presenter->PutData();
324 }
325
326 if (!m_unk0xe5) {
327 m_3dManager->Render(0.0);
328 m_3dManager->GetLego3DView()->GetDevice()->Update();
329 }
330
331 cursor.Prev();
332
333 while (cursor.Next(presenter)) {
334 presenter->PutData();
335 }
336
337 if (m_drawCursor) {
338 DrawCursor();
339 }
340
341 if (m_drawFPS) {
342 DrawFPS();
343 }
344 }
345 else if (m_fullScreenMovie) {
346 MxPresenter* presenter;
348
349 if (cursor.Last(presenter)) {
350 presenter->PutData();
351 }
352 }
353
354 if (!m_paused) {
355 if (m_render3d && m_videoParam.Flags().GetFlipSurfaces()) {
356 m_3dManager->GetLego3DView()
357 ->GetView()
359 }
360
361 UpdateRegion();
362 }
363
364 m_region->Reset();
365 return SUCCESS;
366}
367
368inline void LegoVideoManager::DrawCursor()
369{
370 if (m_cursorX != m_cursorXCopy || m_cursorY != m_cursorYCopy) {
371 if (m_cursorX >= 0 && m_cursorY >= 0) {
372 m_cursorXCopy = m_cursorX;
373 m_cursorYCopy = m_cursorY;
374 }
375 }
376
378
379 if (!m_cursorSurface) {
380 m_cursorRect.top = 0;
381 m_cursorRect.left = 0;
382 m_cursorRect.bottom = 16;
383 m_cursorRect.right = 16;
384 m_cursorSurface = MxDisplaySurface::CreateCursorSurface();
385
386 if (!m_cursorSurface) {
387 m_drawCursor = FALSE;
388 }
389 }
390
391 ddSurface2
392 ->BltFast(m_cursorXCopy, m_cursorYCopy, m_cursorSurface, &m_cursorRect, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
393}
394
395// FUNCTION: LEGO1 0x1007bbc0
396void LegoVideoManager::DrawFPS()
397{
398 char zeros[8] = "0000.00";
399
400 if (m_unk0x528 == NULL) {
401 m_arialFont = CreateFontA(
402 12,
403 0,
404 0,
405 0,
406 FW_NORMAL,
407 FALSE,
408 FALSE,
409 FALSE,
410 ANSI_CHARSET,
411 OUT_DEFAULT_PRECIS,
412 CLIP_DEFAULT_PRECIS,
413 DEFAULT_QUALITY,
414 FF_DONTCARE | VARIABLE_PITCH,
415 "Arial"
416 );
417
418 HDC dc = GetDC(NULL);
419 SelectObject(dc, m_arialFont);
420 GetTextExtentPointA(dc, zeros, strlen(zeros), &m_fpsSize);
421 ReleaseDC(NULL, dc);
422
423 m_unk0x528 = m_displaySurface->FUN_100bc8b0(m_fpsSize.cx, m_fpsSize.cy);
424 SetRect(&m_fpsRect, 0, 0, m_fpsSize.cx, m_fpsSize.cy);
425
426 if (m_unk0x528 == NULL) {
427 DeleteObject(m_arialFont);
428 m_arialFont = NULL;
429 return;
430 }
431
432 DDCOLORKEY colorKey;
433 memset(&colorKey, 0, sizeof(colorKey));
434 m_unk0x528->SetColorKey(DDCKEY_SRCBLT, &colorKey);
435
436 DDSURFACEDESC surfaceDesc;
437 memset(&surfaceDesc, 0, sizeof(surfaceDesc));
438 surfaceDesc.dwSize = sizeof(surfaceDesc);
439
440 if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) != DD_OK) {
441 m_unk0x528->Release();
442 DeleteObject(m_arialFont);
443 m_unk0x528 = NULL;
444 m_arialFont = NULL;
445 }
446 else {
447 DWORD i;
448 char* ptr = (char*) surfaceDesc.lpSurface;
449
450 for (i = 0; i < surfaceDesc.dwHeight; i++) {
451 memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8);
452 ptr += surfaceDesc.lPitch;
453 }
454
455 m_unk0x528->Unlock(surfaceDesc.lpSurface);
456 m_unk0x54c = Timer()->GetTime();
457 m_unk0x550 = 1.f;
458 }
459 }
460 else {
461 if (Timer()->GetTime() > m_unk0x54c + 5000.f) {
462 char buffer[32];
463 MxFloat time = (Timer()->GetTime() - m_unk0x54c) / 1000.0f;
464 MxS32 nb = sprintf(buffer, "%.02f", m_unk0x550 / time);
465 m_unk0x54c = Timer()->GetTime();
466
467 DDSURFACEDESC surfaceDesc;
468 memset(&surfaceDesc, 0, sizeof(surfaceDesc));
469 surfaceDesc.dwSize = sizeof(surfaceDesc);
470
471 if (m_unk0x528->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) == DD_OK) {
472 DWORD i;
473 char* ptr = (char*) surfaceDesc.lpSurface;
474
475 for (i = 0; i < surfaceDesc.dwHeight; i++) {
476 memset(ptr, 0, surfaceDesc.dwWidth * surfaceDesc.ddpfPixelFormat.dwRGBBitCount / 8);
477 ptr += surfaceDesc.lPitch;
478 }
479
480 m_unk0x528->Unlock(surfaceDesc.lpSurface);
481 }
482
483 HDC dc;
484 if (m_unk0x528->GetDC(&dc) != DD_OK) {
485 m_unk0x528->Release();
486 m_unk0x528 = NULL;
487 DeleteObject(m_arialFont);
488 m_arialFont = NULL;
489 return;
490 }
491
492 SelectObject(dc, m_arialFont);
493 SetTextColor(dc, RGB(255, 255, 0));
494 SetBkColor(dc, RGB(0, 0, 0));
495 SetBkMode(dc, OPAQUE);
496 GetTextExtentPoint32A(dc, buffer, nb, &m_fpsSize);
497
498 RECT rect;
499 SetRect(&rect, 0, 0, m_fpsSize.cx, m_fpsSize.cy);
500 ExtTextOutA(dc, 0, 0, ETO_OPAQUE, &rect, buffer, nb, NULL);
501 m_unk0x528->ReleaseDC(dc);
502 m_unk0x550 = 1.f;
503 }
504 else {
505 m_unk0x550 += 1.f;
506 }
507
508 if (m_unk0x528 != NULL) {
510 ->BltFast(20, 20, m_unk0x528, &m_fpsRect, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY);
511 m_3dManager->GetLego3DView()->GetView()->ForceUpdate(20, 20, m_fpsRect.right, m_fpsRect.bottom);
512 }
513 }
514}
515
516// FUNCTION: LEGO1 0x1007c080
518{
520 MxPresenter* presenter;
521
522 while (cursor.Prev(presenter)) {
523 if (presenter->IsHit(p_x, p_y)) {
524 return presenter;
525 }
526 }
527
528 return NULL;
529}
530
531// FUNCTION: LEGO1 0x1007c180
532// FUNCTION: BETA10 0x100d6df4
534{
536 MxPresenter* presenter;
537
538 while (TRUE) {
539 if (!cursor.Prev(presenter)) {
540 return NULL;
541 }
542
543 if (!presenter->GetAction()) {
544 continue;
545 }
546
547 if (strcmpi(presenter->GetAction()->GetObjectName(), p_actionObjectName) == 0) {
548 return presenter;
549 }
550 }
551}
552
553// FUNCTION: LEGO1 0x1007c290
555{
556 if (p_pallete && m_videoParam.GetPalette()) {
557 p_pallete->GetEntries(m_paletteEntries);
558 m_videoParam.GetPalette()->SetEntries(m_paletteEntries);
560 }
561
562 return SUCCESS;
563}
564
565// FUNCTION: LEGO1 0x1007c2d0
567{
568 MxResult result = FAILURE;
569
570 if (m_videoParam.GetPalette() != NULL) {
571 m_videoParam.GetPalette()->Reset(p_ignoreSkyColor);
573 result = SUCCESS;
574 }
575
576 return result;
577}
578
579// FUNCTION: LEGO1 0x1007c300
581{
582 EnableFullScreenMovie(p_enable, TRUE);
583}
584
585// FUNCTION: LEGO1 0x1007c310
587{
588 if (m_isFullscreenMovie != p_enable) {
589 m_isFullscreenMovie = p_enable;
590
591 if (p_enable) {
592 m_palette = m_videoParam.GetPalette()->Clone();
594
596
597 m_render3d = FALSE;
598 m_fullScreenMovie = TRUE;
599 }
600 else {
603
604 // restore previous pallete
605 RealizePalette(m_palette);
606 delete m_palette;
607 m_palette = NULL;
608
609 // update region where video used to be
610 MxRect32 rect(
611 0,
612 0,
615 );
616
617 InvalidateRect(rect);
618 UpdateRegion();
620
621 m_render3d = TRUE;
622 m_fullScreenMovie = FALSE;
623 }
624 }
625
626 if (p_enable) {
628 }
629 else {
631 }
632}
633
634// FUNCTION: LEGO1 0x1007c440
635void LegoVideoManager::SetSkyColor(float p_red, float p_green, float p_blue)
636{
637 PALETTEENTRY colorStrucure;
638
639 colorStrucure.peRed = (p_red * 255.0f);
640 colorStrucure.peGreen = (p_green * 255.0f);
641 colorStrucure.peBlue = (p_blue * 255.0f);
642 colorStrucure.peFlags = -124;
643 m_videoParam.GetPalette()->SetSkyColor(&colorStrucure);
645 m_3dManager->GetLego3DView()->GetView()->SetBackgroundColor(p_red, p_green, p_blue);
646}
647
648// FUNCTION: LEGO1 0x1007c4c0
650{
651 m_videoParam.GetPalette()->SetOverrideSkyColor(p_shouldOverride);
652}
653
654// FUNCTION: LEGO1 0x1007c4d0
655void LegoVideoManager::UpdateView(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height)
656{
657 if (p_width == 0) {
658 p_width = m_videoParam.GetRect().GetWidth();
659 }
660 if (p_height == 0) {
661 p_height = m_videoParam.GetRect().GetHeight();
662 }
663
664 if (!m_paused) {
665 m_3dManager->GetLego3DView()->GetView()->ForceUpdate(p_x, p_y, p_width, p_height);
666 }
667}
668
669// FUNCTION: LEGO1 0x1007c520
671{
672 m_unk0xe5 = TRUE;
673 m_render3d = FALSE;
675
679}
680
681extern void ViewportDestroyCallback(IDirect3DRMObject*, void*);
682
683// FUNCTION: LEGO1 0x1007c560
685{
686 IDirect3DRMViewport* viewport;
687
688 if (!m_paused) {
689 return -1;
690 }
691
692 TglImpl::DeviceImpl* deviceImpl = (TglImpl::DeviceImpl*) m_3dManager->GetLego3DView()->GetDevice();
693 IDirect3DRMDevice2* d3drmDev2 = NULL;
694 IDirect3D2* d3d2 = m_direct3d->Direct3D();
695 IDirect3DDevice2* d3dDev2 = m_direct3d->Direct3DDevice();
696
697 int result = -1;
698 IDirect3DRM2* d3drm2 = ((TglImpl::RendererImpl*) m_renderer)->ImplementationData();
699
700 m_direct3d->RestoreSurfaces();
701
702 if (d3drm2->CreateDeviceFromD3D(d3d2, d3dDev2, &d3drmDev2) == D3DRM_OK) {
703 viewport = NULL;
704 deviceImpl->SetImplementationData(d3drmDev2);
705
706 if (d3drm2->CreateViewport(d3drmDev2, m_camera, 0, 0, m_cameraWidth, m_cameraHeight, &viewport) == D3DRM_OK) {
707 viewport->SetBack(m_back);
708 viewport->SetFront(m_front);
709 viewport->SetField(m_fov);
710 viewport->SetCamera(m_camera);
711 viewport->SetProjection(m_projection);
712 viewport->SetAppData((DWORD) m_appdata);
713 d3drmDev2->SetQuality(m_quality);
714 d3drmDev2->SetShades(m_shades);
715 d3drmDev2->SetTextureQuality(m_textureQuality);
716 d3drmDev2->SetRenderMode(m_rendermode);
717 d3drmDev2->SetDither(m_dither);
718 d3drmDev2->SetBufferCount(m_bufferCount);
719 m_camera->Release();
720
721 if (viewport->AddDestroyCallback(ViewportDestroyCallback, m_appdata) == D3DRM_OK) {
722 ((TglImpl::ViewImpl*) m_3dManager->GetLego3DView()->GetView())->SetImplementationData(viewport);
723 m_paused = 0;
724 result = 0;
725 }
726 }
727 }
728
729 return result;
730}
731
732// FUNCTION: LEGO1 0x1007c740
734{
735 if (m_paused) {
736 return -1;
737 }
738
739 IDirect3DRMDevice2* d3drmDev2 =
740 ((TglImpl::DeviceImpl*) m_3dManager->GetLego3DView()->GetDevice())->ImplementationData();
741
742 if (d3drmDev2 != NULL) {
743 IDirect3DRMViewportArray* viewportArray = NULL;
744
745 if (d3drmDev2->GetViewports(&viewportArray) == D3DRM_OK && viewportArray != NULL) {
746 if (viewportArray->GetSize() == 1) {
747 IDirect3DRMViewport* viewport = NULL;
748
749 if (viewportArray->GetElement(0, &viewport) == D3DRM_OK) {
750 m_back = viewport->GetBack();
751 m_front = viewport->GetFront();
752 m_cameraWidth = viewport->GetWidth();
753 m_cameraHeight = viewport->GetHeight();
754 m_fov = viewport->GetField();
755 viewport->GetCamera(&m_camera);
756 m_projection = viewport->GetProjection();
757 m_appdata = (ViewportAppData*) viewport->GetAppData();
758 viewportArray->Release();
759 viewport->Release();
760 viewport->DeleteDestroyCallback(ViewportDestroyCallback, this->m_appdata);
761 viewport->Release();
762 m_paused = 1;
763 m_direct3d->Direct3D()->AddRef();
764 m_direct3d->Direct3DDevice()->AddRef();
765 }
766 else {
767 viewportArray->Release();
768 }
769 }
770 }
771
772 m_quality = d3drmDev2->GetQuality();
773 m_shades = d3drmDev2->GetShades();
774 m_textureQuality = d3drmDev2->GetTextureQuality();
775 m_rendermode = d3drmDev2->GetRenderMode();
776 m_dither = d3drmDev2->GetDither();
777 m_bufferCount = d3drmDev2->GetBufferCount();
778 d3drmDev2->Release();
779 }
780
781 if (m_paused) {
782 return 0;
783 }
784 else {
785 return -1;
786 }
787}
788
789// FUNCTION: LEGO1 0x1007c930
790MxResult LegoVideoManager::ConfigureD3DRM()
791{
792 IDirect3DRMDevice2* d3drm =
793 ((TglImpl::DeviceImpl*) m_3dManager->GetLego3DView()->GetDevice())->ImplementationData();
794
795 if (!d3drm) {
796 return FAILURE;
797 }
798
799 MxAssignedDevice* assignedDevice = m_direct3d->AssignedDevice();
800
801 if (assignedDevice && assignedDevice->GetFlags() & MxAssignedDevice::c_hardwareMode) {
803 d3drm->SetTextureQuality(D3DRMTEXTURE_LINEAR);
804 }
805
806 d3drm->SetDither(TRUE);
807
809 d3drm->SetRenderMode(D3DRMRENDERMODE_BLENDEDTRANSPARENCY);
810 }
811 }
812
813 return SUCCESS;
814}
[AI] Central class managing the LEGO Island 3D rendering subsystem.
Definition: lego3dmanager.h:39
BOOL Create(CreateStruct &rCreateStruct)
[AI] Initializes the LEGO 3D system using the specified creation parameters.
BOOL Add(ViewROI &rROI)
[AI] Adds a ViewROI (rendered object) to the scene.
ViewLODListManager * GetViewLODListManager()
[AI] Returns the internal ViewLODListManager instance.
double Render(double p_und)
[AI] Renders the current frame.
Lego3DView * GetLego3DView()
[AI] Returns the encapsulated Lego3DView instance.
BOOL Remove(ViewROI &rROI)
[AI] Removes a ViewROI from the scene.
BOOL SetPointOfView(ViewROI &rROI)
[AI] Sets the camera's point of view to match the given ROI.
[AI] Enumerates and manages Direct3D devices and drivers for the LEGO Island engine.
Definition: legodxinfo.h:24
int GetDevice(int p_deviceNum, MxDriver *&p_driver, Direct3DDeviceInfo *&p_device)
[AI] Outputs pointers to the MxDriver and Direct3DDeviceInfo for the given device index.
Definition: legodxinfo.cpp:85
int FUN_1009d0d0()
[AI] Finds and returns the preferred device index that supports required features.
Definition: legodxinfo.cpp:161
int ParseDeviceName(const char *p_deviceId)
[AI] Parses a device string identifier and locates the matching device entry.
Definition: legodxinfo.cpp:11
int FUN_1009d210()
[AI] Prunes the enumeration to only include devices/drivers that support the required display mode an...
Definition: legodxinfo.cpp:294
void SetUnknown335(MxBool p_unk0x335)
[AI] Typically used to allow button-down event processing during partial-blocked states.
void EnableInputProcessing()
[AI] Enable event queue and input event processing. Resets relevant state. [AI]
static LegoOmni * GetInstance()
[AI] Returns the current LegoOmni singleton pointer, cast from MxOmni.
Definition: legomain.cpp:305
Specialized list class for managing LegoPhoneme objects.
[AI] Extends the functionality of MxVideoManager to provide LEGO Island–specific video and 3D graphic...
MxResult ResetPalette(MxBool p_ignoreSkyColor)
[AI] Resets palette entries and re-installs base palette, restoring sky color if requested.
virtual MxPresenter * GetPresenterAt(MxS32 p_x, MxS32 p_y)
[AI] Finds a presenter at the specific screen coordinates (for hit testing).
int EnableRMDevice()
[AI] Enables the Direct3D Retained Mode (RM) rendering device, and re-creates the device/viewport if ...
void UpdateView(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height) override
[AI] Notifies the manager of changes in view rectangle, updating the 3D device's viewport as needed.
void EnableFullScreenMovie(MxBool p_enable)
[AI] Convenience method to enable or disable fullscreen movie playback with default scaling.
MxResult Tickle() override
[AI] Performs per-frame update for all video, 3D, and interface layers.
~LegoVideoManager() override
[AI] Releases all allocated resources and restores graphics state.
void FUN_1007c520()
[AI] Sets rendering state to allow PutData for all overlay presenters, disables 3D main rendering.
int DisableRMDevice()
[AI] Disables the Direct3D Retained Mode (RM) rendering device and saves/restores 3D state as needed.
void OverrideSkyColor(MxBool p_shouldOverride)
[AI] Requests that the palette override the sky color entry, for movie transitions or when re-enablin...
void Destroy() override
[AI] Cleans up graphics resources, disables overlays, removes from 3D scene and releases presenters/l...
MxResult RealizePalette(MxPalette *) override
[AI] Sets the realized palette to use for rendering and updates the display surface.
void ToggleFPS(MxBool p_visible)
[AI] Toggles display of the on-screen frames-per-second (FPS) overlay.
MxPresenter * GetPresenterByActionObjectName(const char *p_char)
[AI] Searches all active presenters for one associated with the given action object name.
void SetRender3D(MxBool p_render3d)
[AI] Enables or disables main 3D rendering (e.g., used internally on video transitions).
void MoveCursor(MxS32 p_cursorX, MxS32 p_cursorY)
[AI] Updates the position of the custom software cursor overlay, and ensures it renders on the next f...
void SetSkyColor(float p_red, float p_green, float p_blue)
[AI] Sets the RGB color for the sky/background in the 3D view and updates the palette accordingly.
[AI] Represents a 3D point with floating-point precision, inheriting from Vector3.
Definition: mxgeometry3d.h:14
[AI] Holds assignment and description details for a Direct3D rendering device in use.
Definition: mxdirectxinfo.h:65
@ c_hardwareMode
[AI] Indicates that the device is a hardware rendering device.
Definition: mxdirectxinfo.h:68
D3DDEVICEDESC & GetDesc()
[AI] Accessor for device's current description.
Definition: mxdirectxinfo.h:92
unsigned int GetFlags()
[AI] Returns all flags describing hardware mode/primary device status.
Definition: mxdirectxinfo.h:84
const char * GetObjectName() const
[AI] Returns the object name string.
Definition: mxdsobject.h:127
virtual int DoEnumerate()
[AI] Begins enumeration of DirectDraw drivers, their devices, and available display modes.
[AI] MxDirect3D provides Direct3D (D3D) rendering capabilities layered on top of MxDirectDraw,...
Definition: mxdirect3d.h:24
BOOL SetDevice(MxDeviceEnumerate &p_deviceEnumerate, MxDriver *p_driver, Direct3DDeviceInfo *p_device)
[AI] Selects which Direct3D device to be used for rendering, given an enumeration of available device...
Definition: mxdirect3d.cpp:253
IDirect3DDevice2 * Direct3DDevice()
[AI] Provides access to the currently selected Direct3D device interface.
Definition: mxdirect3d.h:87
MxAssignedDevice * AssignedDevice()
[AI] Returns the currently selected/active rendering device information for 3D output.
Definition: mxdirect3d.h:75
IDirect3D2 * Direct3D()
[AI] Provides access to the underlying IDirect3D2 interface for advanced 3D rendering operations.
Definition: mxdirect3d.h:81
BOOL Create(HWND hWnd, BOOL fullscreen_1, BOOL surface_fullscreen, BOOL onlySystemMemory, int width, int height, int bpp, const PALETTEENTRY *pPaletteEntries, int paletteEntryCount) override
[AI] Initializes DirectDraw and Direct3D, prepares primary surfaces and selects the video mode,...
Definition: mxdirect3d.cpp:33
IDirectDrawSurface * BackBuffer()
Returns the back buffer surface.
Definition: mxdirectdraw.h:94
IDirectDraw * DirectDraw()
Returns the DirectDraw device interface pointer.
Definition: mxdirectdraw.h:82
IDirectDrawSurface * FrontBuffer()
Returns the surface used as the primary/front buffer.
Definition: mxdirectdraw.h:88
IDirectDrawClipper * Clipper()
Returns the current DirectDraw clipper object used for window clipping.
Definition: mxdirectdraw.h:100
BOOL RestoreSurfaces()
Attempts to restore all DirectDraw surfaces that may have been lost.
LPDIRECTDRAWSURFACE FUN_100bc8b0(MxS32 width, MxS32 height)
[AI] Creates a 16-bit DirectDraw surface of specified size, either in video or system memory.
LPDIRECTDRAWSURFACE GetDirectDrawSurface1()
[AI] Returns the primary DirectDraw surface (front buffer).
virtual void SetPalette(MxPalette *p_palette)
[AI] Sets the palette used for the primary and secondary DirectDraw surfaces.
void ClearScreen()
[AI] Fills the current back buffer with black (clears the display area). [AI]
LPDIRECTDRAWSURFACE GetDirectDrawSurface2()
[AI] Returns the secondary DirectDraw surface (back buffer).
static LPDIRECTDRAWSURFACE CreateCursorSurface()
[AI] Creates and draws a 16x16 cursor DirectDraw surface.
MxVideoParam & GetVideoParam()
[AI] Gets the video parameter configuration (mode/resolution/etc) in use by this surface.
Utility for measuring the frequency (operations per second) of a repeated operation.
Definition: mxstopwatch.h:91
MxBool Next()
[AI]
MxBool Prev()
[AI]
MxBool Last(T &p_obj)
[AI]
void Reset()
[AI]
Definition: mxlist.h:269
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
MxPresenterList * m_presenters
[AI] Pointer to list of currently registered (active) presenters.
virtual MxResult Create()
[AI] Allocates and initializes the internal presenter list for this manager, ensuring thread safety.
static MxOmni * GetInstance()
[AI] Returns the singleton instance of the MxOmni subsystem coordinator.
Definition: mxomni.cpp:289
HWND GetWindowHandle() const
[AI] Gets the window handle (HWND) associated with the engine (ownership not transferred).
Definition: mxomni.h:192
[AI] Encapsulates a DirectDraw 8-bit (256 color) palette for use with DirectX rendering.
Definition: mxpalette.h:17
LPDIRECTDRAWPALETTE CreateNativePalette()
[AI] Creates the internal DirectDraw palette object and populates it with the current palette entries...
Definition: mxpalette.cpp:114
MxResult SetEntries(LPPALETTEENTRY p_palette)
[AI] Sets the palette's RGB entries from an external array and updates the DirectDraw palette if atta...
Definition: mxpalette.cpp:178
void SetOverrideSkyColor(MxBool p_value)
[AI] Sets whether the sky color is overridden, preventing calls to SetSkyColor from effecting palette...
Definition: mxpalette.h:112
MxPalette * Clone()
[AI] Creates a duplicate of this palette object with the same palette data and override flag.
Definition: mxpalette.cpp:160
MxResult GetEntries(LPPALETTEENTRY p_entries)
[AI] Copies all palette entries to external buffer.
Definition: mxpalette.cpp:170
MxResult SetSkyColor(LPPALETTEENTRY p_skyColor)
[AI] Sets the "sky color" palette entry (typically index 141, reserved for sky background),...
Definition: mxpalette.cpp:239
void Reset(MxBool p_ignoreSkyColor)
[AI] Resets palette entries to default system values, optionally preserving the current sky color,...
Definition: mxpalette.cpp:329
[AI] Cursor/iterator for traversing an MxPresenterList.
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
Definition: mxpresenter.h:20
virtual MxResult PutData()
[AI] Allows the presenter to submit pending results or output to the engine.
Definition: mxpresenter.h:112
MxResult Tickle() override
[AI] Main tickle handler, called periodically to progress presenter's internal state.
MxS32 GetDisplayZ() const
[AI] Returns the display Z (depth) order.
Definition: mxpresenter.h:172
MxDSAction * GetAction() const
[AI] Returns the current action being presented.
Definition: mxpresenter.h:175
virtual MxBool IsHit(MxS32 p_x, MxS32 p_y)
[AI] Returns TRUE if the given (x, y) falls within hit-test bounds for the presenter (e....
Definition: mxpresenter.h:118
[AI] Rectangle using 32-bit signed integer coordinates.
Definition: mxgeometry.h:706
T GetTop() const
[AI] Get the top edge.
Definition: mxgeometry.h:231
T GetWidth() const
[AI] Get the rectangle's width.
Definition: mxgeometry.h:262
T GetRight() const
[AI] Get the right edge.
Definition: mxgeometry.h:241
T GetHeight() const
[AI] Get the rectangle's height.
Definition: mxgeometry.h:268
T GetLeft() const
[AI] Get the left edge.
Definition: mxgeometry.h:221
T GetBottom() const
[AI] Get the bottom edge.
Definition: mxgeometry.h:251
virtual void Reset()
[AI] Removes all spans and resets the bounding rectangle to an empty state.
Definition: mxregion.cpp:27
Measures elapsed wall clock time using high resolution performance counters.
Definition: mxstopwatch.h:25
void Stop()
Stops timing and accumulates the elapsed interval to m_elapsedSeconds.
void Reset()
Resets the stopwatch to zero.
double ElapsedSeconds() const
Returns the total accumulated elapsed time in seconds.
void Start()
Starts (or resumes) timing from the current moment.
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
@ e_idle
[AI] No transition is active.
virtual MxResult VTable0x28(MxVideoParam &p_videoParam, LPDIRECTDRAW p_pDirectDraw, LPDIRECT3D2 p_pDirect3D, LPDIRECTDRAWSURFACE p_ddSurface1, LPDIRECTDRAWSURFACE p_ddSurface2, LPDIRECTDRAWCLIPPER p_ddClipper, MxU32 p_frequencyMS, MxBool p_createThread)
[AI] Main DirectDraw/Direct3D allocator and presenter chain creation.
void UpdateRegion()
[AI] Updates the portion of the display surface that is marked dirty based on m_region,...
void InvalidateRect(MxRect32 &p_rect)
[AI] Invalidates a rectangular region in the display; marks it for redraw on next tick.
void Destroy() override
[AI] Releases all display/video resources, any DirectDraw/Direct3D handles, and associated objects.
MxVideoParam m_videoParam
[AI] Video configuration, containing palette, source/dest rectangles, and other state....
MxRegion * m_region
[AI] Tracks regions that have been invalidated and need to be updated/redrawn. [0x5c]
MxDisplaySurface * m_displaySurface
[AI] Concrete blitting/output surface where final image is copied each frame. [0x58]
LPDIRECTDRAW m_pDirectDraw
[AI] DirectDraw interface pointer. May be allocated here, or passed in/injected. [0x50]
void SortPresenterList()
[AI] Sorts presenters in descending Z order for proper overdraw order during tickle (bubble-sort).
MxBool GetWideViewAngle()
[AI] Get whether a wide view angle is enabled.
MxBool GetFullScreen()
[AI] Get whether fullscreen mode is enabled.
MxBool Get16Bit()
[AI] Get whether 16-bit rendering mode is selected.
void SetF2bit0(MxBool p_e)
[AI] Set secondary flag 0 (often used for internal video logic).
void SetF1bit3(MxBool p_e)
[AI] Set an additional primary flag; exact usage is unknown but may control a video mode detail.
MxBool GetF2bit0()
[AI] Get the value of secondary flag 0.
MxBool GetFlipSurfaces()
[AI] Get whether page flipping of surfaces is enabled.
MxBool GetBackBuffers()
[AI] Get whether back buffering (double buffering) is enabled.
[AI] Video parameter configuration for display and rendering, encapsulates resolution,...
Definition: mxvideoparam.h:14
void SetPalette(MxPalette *p_palette)
[AI] Assign the palette pointer (color indexing) for the video mode.
Definition: mxvideoparam.h:57
MxPalette * GetPalette()
[AI] Get the palette used for rendering (may be NULL if not set).
Definition: mxvideoparam.h:53
MxVideoParamFlags & Flags()
[AI] Access the video parameter flags (windowed/fullscreen, rendering mode, etc).
Definition: mxvideoparam.h:45
MxRect32 & GetRect()
[AI] Get the rectangle specifying the display dimensions and screen area.
Definition: mxvideoparam.h:49
char * GetDeviceName()
[AI] Get a pointer to the internal device name string (may be NULL).
Definition: mxvideoparam.h:61
void WrappedSetLocalTransform(const Matrix4 &p_transform)
Wraps SetLocalTransform, for possible override or interface uniformity.
[AI] Implements the Tgl::Device interface, encapsulates Direct3DRMDevice2 and provides rendering devi...
Definition: impl.h:322
void SetImplementationData(IDirect3DRMDevice2 *device)
Replaces the implementation pointer [AI].
Definition: impl.h:410
[AI] Implements Tgl::MeshBuilder; facilitates mesh construction [AI]
Definition: impl.h:55
[AI] Implementation of Tgl::View backed by Direct3DRMViewport, handles scene rendering,...
Definition: impl.h:449
Tgl::View * GetView() const
[AI] Gets the current view/camera for this surface.
Definition: tglsurface.h:108
Tgl::Device * GetDevice() const
[AI] Returns the graphics device used by this surface, e.g.
Definition: tglsurface.h:102
virtual Result Update()=0
[AI] Performs a device update/synchronization.
virtual Result SetBackgroundColor(float r, float g, float b)=0
[AI] Sets the background color for the view.
virtual Result Clear()=0
[AI] Clears the current contents of the view.
virtual Result ForceUpdate(unsigned long x, unsigned long y, unsigned long width, unsigned long height)=0
[AI] Forces update/redraw of a region in the view.
[AI] An extension of LegoROI that adds support for keeping and applying a base time reference (used f...
Definition: legoroi.h:342
ViewLODList * Create(const ROIName &rROIName, int lodCount)
[AI] Creates and registers a new ViewLODList for a named ROI, with space for the specified number of ...
Definition: viewlodlist.cpp:67
[AI] Reference-counted list of Level-of-Detail (LOD) objects associated with a single ROI (Realtime O...
Definition: viewlodlist.h:30
int Release()
[AI] Decrements the reference count.
static undefined SetUnk101013d8(undefined p_flag)
[AI] Sets the global flag g_unk101013d8 and returns its previous value.
Definition: viewroi.cpp:81
#define D3DPTFILTERCAPS_LINEAR
Definition: d3dcaps.h:162
#define D3DPSHADECAPS_ALPHAFLATBLEND
Definition: d3dcaps.h:139
#define D3DRM_OK
Definition: d3drm.h:197
#define D3DRMRENDERMODE_BLENDEDTRANSPARENCY
Definition: d3drmdef.h:96
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
@ D3DRMTEXTURE_LINEAR
Definition: d3drmdef.h:101
struct IDirectDrawSurface FAR * LPDIRECTDRAWSURFACE
Definition: ddraw.h:74
#define DDBLTFAST_WAIT
Definition: ddraw.h:2737
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
#define DDBLTFAST_SRCCOLORKEY
Definition: ddraw.h:2735
#define DD_OK
Definition: ddraw.h:3166
#define DDCKEY_SRCBLT
Definition: ddraw.h:2237
#define DDLOCK_WAIT
Definition: ddraw.h:2916
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
void ViewportDestroyCallback(IDirect3DRMObject *, void *)
Definition: view.cpp:125
MxTransitionManager * TransitionManager()
[AI] Accessor for the MxTransitionManager, handling level transitions, fades, and world changes....
Definition: misc.cpp:208
LegoInputManager * InputManager()
[AI] Accessor for the input manager, which handles keyboard, mouse, and controller input....
Definition: misc.cpp:45
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
void DeleteObject(MxDSAction &p_dsAction)
[AI] Deletes the specified action object, removing it from the global action list.
Definition: mxmisc.cpp:105
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
float MxFloat
[AI]
Definition: mxtypes.h:68
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
Renderer * CreateRenderer()
[AI] Instantiates and returns a new Tgl::Renderer implementation.
Definition: renderer.cpp:8
@ RGB
[AI] Uses direct RGB color values. [AI]
Definition: tgl.h:21
void CalcLocalTransform(const Vector3 &p_posVec, const Vector3 &p_dirVec, const Vector3 &p_upVec, Matrix4 &p_outMatrix)
[AI] Computes a transformation matrix based on a position, direction, and up vector.
Definition: realtime.cpp:7
[AI] Encapsulates Direct3D device enumeration information and capability structures.
[AI] Construction parameters for initializing the 3D system.
Definition: lego3dmanager.h:45
IDirectDrawSurface * m_pFrontBuffer
[AI] DirectDraw front buffer surface
Definition: lego3dmanager.h:49
IDirect3D2 * m_direct3d
[AI] Direct3D interface
Definition: lego3dmanager.h:54
IDirectDrawPalette * m_pPalette
[AI] Color palette for indexed display modes
Definition: lego3dmanager.h:51
IDirect3DDevice2 * m_d3dDevice
[AI] Direct3D device to use for rendering
Definition: lego3dmanager.h:55
HWND m_hWnd
[AI] Window handle to associate DirectDraw surfaces with
Definition: lego3dmanager.h:47
IDirectDrawSurface * m_pBackBuffer
[AI] DirectDraw back buffer surface
Definition: lego3dmanager.h:50
IDirectDraw * m_pDirectDraw
[AI] Pointer to active DirectDraw interface
Definition: lego3dmanager.h:48
BOOL m_isFullScreen
[AI] TRUE if 3D system should run in full-screen mode
Definition: lego3dmanager.h:52
BOOL m_isWideViewAngle
[AI] TRUE for wide-angle (FOV) projection
Definition: lego3dmanager.h:53
[AI] Holds data about a DirectDraw driver including devices and supported display modes.
DDCAPS m_ddCaps
[AI] Capabilities structure as reported by the driver.
D3DPRIMCAPS dpcTriCaps
Definition: d3dcaps.h:200
DWORD dwShadeCaps
Definition: d3dcaps.h:56
DWORD dwTextureFilterCaps
Definition: d3dcaps.h:58
DWORD dwCaps2
Definition: ddraw.h:272
DWORD dwSVBRops[DD_ROP_SPACE]
Definition: ddraw.h:309
DWORD dwRGBBitCount
Definition: ddraw.h:348
LPVOID lpSurface
Definition: ddraw.h:1152
DDPIXELFORMAT ddpfPixelFormat
Definition: ddraw.h:1157
LONG lPitch
Definition: ddraw.h:1140
DWORD dwSize
Definition: ddraw.h:1134
DWORD dwWidth
Definition: ddraw.h:1137
DWORD dwHeight
Definition: ddraw.h:1136