coastline 0.0.4
Loading...
Searching...
No Matches
renderer.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <cstring>
9
10#include <d3d.h>
11#include <ddraw.h>
12#include <windows.h>
13
14#include "common/textureentry.h"
15#include "common/texturetile.h"
16
18#define RENDERER_E_NOT_IN_GDI_MODE static_cast<HRESULT>(0x88762711)
19
21#define RENDERER_E_OUT_OF_MEMORY static_cast<HRESULT>(0x88762714)
22
24#define RENDERER_E_NOT_CREATED static_cast<HRESULT>(0x88762712)
25
27#define RENDERER_E_NOT_READY static_cast<HRESULT>(0x88762713)
28
30#define WM_RENDERER_CREATED 0xbd0
31
33#define WM_RENDERER_DESTROYING 0xbd1
34
36#define WM_RENDERER_IS_READY 0x7e8
37
39#define WM_RENDERER_GET 0x7e9
40
42#define WM_RENDERER_GET_BACK_BUFFER 0x7ea
43
45#define RENDERER_STATE_READY 0x1f
46
48#define DIRECTDRAW_DRIVER_USABLE 0x1
49
51#define DIRECTDRAW_DRIVER_PRIMARY 0x2
52
53class D3DDeviceNode;
54class DisplayMode;
55
58private:
59 unsigned dwFlags;
60 GUID guid;
61 char *pszName;
62 char *pszDescription;
63 DDCAPS hardwareCaps;
64 DDCAPS softwareCaps;
65 int nDisplayModeCount;
66 DisplayMode *pDisplayModesHead;
67 DisplayMode *pDisplayModesTail;
68 int nD3DDeviceCount;
69 D3DDeviceNode *pD3DDevicesHead;
70 D3DDeviceNode *pD3DDevicesTail;
71 DirectDrawDriver *pPrev;
72 DirectDrawDriver *pNext;
73
81 HRESULT EnumerateDisplayModes(IDirectDraw2 *pDirectDraw2);
82
88 void FlushDirectDrawModeEnumerationList();
89
97 HRESULT EnumerateD3DDevices(IDirect3D2 *pDirect3D2);
98
105 int FlushDirect3DDeviceList();
106
107public:
109 unsigned GetFlags() const {
110 return dwFlags;
111 }
112
113 const GUID *GetGuid() const {
114 return &guid;
115 }
116
117 const char *GetName() const {
118 return pszName;
119 }
120
121 unsigned GetDisplayModeCount() const {
122 return static_cast<unsigned>(nDisplayModeCount);
123 }
124
126 return pDisplayModesHead;
127 }
128
130 return pPrev;
131 }
132
134 return pNext;
135 }
136
138 pPrev = driver;
139 }
140
141 void SetNext(DirectDrawDriver *driver) {
142 pNext = driver;
143 }
144
146 DirectDrawDriver() : pPrev(nullptr), pNext(nullptr) {
147#ifdef ENABLE_PATCHES
148 dwFlags = 0;
149#else
150 // The constructor clears a bit of flags it never set, as the original does.
151 dwFlags &= ~DIRECTDRAW_DRIVER_USABLE;
152#endif /* ENABLE_PATCHES */
153 memset(&hardwareCaps, 0, sizeof(hardwareCaps));
154 hardwareCaps.dwSize = sizeof(hardwareCaps);
155 memset(&softwareCaps, 0, sizeof(softwareCaps));
156 softwareCaps.dwSize = sizeof(softwareCaps);
157 nDisplayModeCount = 0;
158 pDisplayModesHead = nullptr;
159 pDisplayModesTail = nullptr;
160 nD3DDeviceCount = 0;
161 pD3DDevicesHead = nullptr;
162 pD3DDevicesTail = nullptr;
163 }
164
173
182
197 int nHeight,
198 int nBitDepth,
199 void *pUnused,
200 DisplayMode **ppFallback,
201 DisplayMode *pFirst);
202
215
228 DisplayMode *pMode,
229 D3DDeviceNode **ppFallback,
230 D3DDeviceNode *pFirst);
231
247 int nHeight,
248 int nBitDepth,
249 void *pUnused,
250 D3DDeviceNode *pDevice,
251 DisplayMode **ppFallback,
252 DisplayMode *pFirst);
253
263 HRESULT InitializeDirectDrawDriver(GUID *pGuid, LPSTR pszName, LPSTR pszDescription);
264
271
280
288};
289
290class RenderHost;
291
294private:
295 unsigned dwFlags;
296 GUID guid;
297 char *pszDescription;
298 char *pszName;
299 D3DDEVICEDESC hardwareDesc;
300 D3DDEVICEDESC softwareDesc;
301 int nTextureFormatCount;
302 DisplayMode *pTextureFormatsHead;
303 DisplayMode *pTextureFormatsTail;
304 D3DDeviceNode *pPrev;
305 D3DDeviceNode *pNext;
306
312 void FlushTextureFormatList();
313
314public:
317 return &guid;
318 }
319
321 return &hardwareDesc;
322 }
323
325 return &softwareDesc;
326 }
327
329 return pPrev;
330 }
331
333 return pNext;
334 }
335
337 pPrev = device;
338 }
339
340 void SetNext(D3DDeviceNode *device) {
341 pNext = device;
342 }
343
351
359 bool CompareD3DDeviceGuid(const GUID *pGuid);
360
363 : pszDescription(nullptr), pszName(nullptr), nTextureFormatCount(0),
364 pTextureFormatsHead(nullptr), pTextureFormatsTail(nullptr), pPrev(nullptr),
365 pNext(nullptr) {
366#ifdef ENABLE_PATCHES
367 dwFlags = 0;
368#else
369 // The constructor clears bits of flags it never set, as the original does.
370 dwFlags &= ~3u;
371#endif /* ENABLE_PATCHES */
372 memset(&hardwareDesc, 0, sizeof(hardwareDesc));
373 hardwareDesc.dwSize = sizeof(hardwareDesc);
374 memset(&softwareDesc, 0, sizeof(softwareDesc));
375 softwareDesc.dwSize = sizeof(softwareDesc);
376 }
377
390 LPSTR pszNewDescription,
391 LPSTR pszNewName,
392 D3DDEVICEDESC *pHardwareDesc,
393 D3DDEVICEDESC *pSoftwareDesc);
394
403
411
420};
421
424private:
425 DDSURFACEDESC desc;
426 DisplayMode *pPrev;
427 DisplayMode *pNext;
428
435 int GetSurfaceDescBitDepth();
436
437public:
439 void SetDescription(const DDSURFACEDESC &description) {
440 desc = description;
441 }
442
444 return pPrev;
445 }
446
448 return pNext;
449 }
450
452 pPrev = mode;
453 }
454
455 void SetNext(DisplayMode *mode) {
456 pNext = mode;
457 }
458
460 DisplayMode() : pPrev(nullptr), pNext(nullptr) {
461 memset(&desc, 0, sizeof(desc));
462 desc.dwSize = sizeof(desc);
463 }
464
475 HRESULT
476 GetSurfaceDescDimensions(int *pnWidth, int *pnHeight, int *pnBitDepth, int *pnRefreshRate);
477
486
496 bool IsDisplayModeMatch(int nWidth, int nHeight, int nBitDepth);
497};
498
501private:
502 D3DMATERIAL desc;
503 D3DMATERIALHANDLE hMaterial;
504 IDirect3DMaterial2 *pMaterial;
505 int bDirty;
506
507public:
510 return hMaterial;
511 }
512
514 void SetDiffuseColor(float red, float green, float blue) {
515 desc.dcvDiffuse.r = red;
516 desc.dcvDiffuse.g = green;
517 desc.dcvDiffuse.b = blue;
518 bDirty = 1;
519 }
520
522 void SetRampSize(DWORD size) {
523 desc.dwRampSize = size;
524 }
525
528 bDirty = 0;
529 return pMaterial->SetMaterial(&desc);
530 }
531
539 D3DMaterial(IDirect3D2 *pDirect3D2, IDirect3DDevice2 *pD3DDevice);
540
546 void Release();
547
555};
556
559private:
560 IDirectDrawSurface *pSysMemSurface;
561 IDirectDrawSurface *pDeviceSurface;
562 IUnknown *pUnknown8;
563 D3DTEXTUREHANDLE hTexture;
564 [[maybe_unused]] unsigned char abUnknown10[0x10];
565
566public:
569 return hTexture;
570 }
571
587 void *pImage,
588 int nWidth,
589 int nHeight,
590 int nPixelFormatId,
591 DWORD dwColorKey);
592
605 IDirect3DDevice2 *pDevice, void *pImage, int nWidth, int nHeight, int nPixelFormatId);
606
616 bool UploadSurfaceToTexture(const void *pImage, int nWidth, int nHeight);
617
625
632};
633
634#ifdef __cplusplus
635extern "C" {
636#endif
637
647#ifdef __cplusplus
648}
649#endif
650
653private:
654 [[maybe_unused]] int anUnknown0[2]; /* +0x00 */
655 D3DMaterial *pMaterial;
656 int dwDeviceInit;
657 int dwSize;
658 int dwFlags;
659 [[maybe_unused]] int nUnknown18; /* +0x18 */
660 int dwRenderStateFlags;
661 HWND hWnd;
662 int nGdiModeRefCount;
663 [[maybe_unused]] int nUnknown28; /* +0x28 */
664 DirectDrawDriver *pDriver;
665 DisplayMode *pMode;
666 D3DDeviceNode *pDevice;
667 IDirectDraw *pDirectDraw;
668 IDirectDraw2 *pDirectDraw2;
669 IDirect3D2 *pDirect3D2;
670 IDirectDrawSurface *pPrimarySurface;
671 IDirectDrawPalette *pPrimaryPalette;
672 unsigned nPaletteEntryCount;
673 PALETTEENTRY *pGdiPaletteEntries;
674 PALETTEENTRY *pGamePaletteEntries;
675 IDirectDrawSurface *pBackBuffer;
676 IDirectDrawSurface *pZBuffer;
677 IDirect3DDevice2 *pD3DDevice;
678 IDirect3DViewport2 *pViewport;
679 [[maybe_unused]] int anUnknown68[4]; /* +0x68 */
680 RECT rcViewport;
681 RenderHost *pHost;
682
683 inline void RecordDisplayMode(int nWidth, int nHeight, int nBitDepth);
684 inline HRESULT
685 CreateDepthBuffer(const D3DDEVICEDESC *pDesc, DWORD dwMemoryCaps, bool *pbAttached);
686
693 int DestroyDirectDrawRendererObjects();
694
705 HRESULT InitializeDirectDraw();
706
715 HRESULT SelectDriverDeviceAndMode();
716
723 HRESULT CreateDirectDrawObjects();
724
731 int ReleaseDirectDrawObjects();
732
739 HRESULT SetCooperativeLevel();
740
747 HRESULT SetDisplayMode();
748
755 int RestoreDisplayMode();
756
763 HRESULT CreatePrimaryFlipChain();
764
771 HRESULT InitializePrimaryPalette();
772
779 int ReleasePrimarySurface();
780
787 int ReleasePrimaryPalette();
788
795 HRESULT InitializeRenderDevice();
796
803 HRESULT CreateAndAttachViewport();
804
811 HRESULT InitializeViewportAndRenderContext();
812
820 int DestroyD3DDevice();
821
828 int ReleaseViewportAndMaterial();
829
836 HRESULT RestoreGdiPaletteAndFlipToGdi();
837
844 HRESULT RestoreGamePaletteEntries();
845
846public:
849 return pMaterial;
850 }
851
852 int GetDeviceInit() const {
853 return dwDeviceInit;
854 }
855
856 int GetFlags() const {
857 return dwFlags;
858 }
859
860 void AddFlags(int flags) {
861 dwFlags |= flags;
862 }
863
864 void RemoveFlags(int flags) {
865 dwFlags &= ~flags;
866 }
867
869 return dwRenderStateFlags;
870 }
871
872 int GetGdiModeRefCount() const {
873 return nGdiModeRefCount;
874 }
875
877 return pDriver;
878 }
879
881 return pMode;
882 }
883
885 return pDevice;
886 }
887
889 return pDirectDraw2;
890 }
891
893 return pDirect3D2;
894 }
895
897 return pPrimarySurface;
898 }
899
901 return pBackBuffer;
902 }
903
905 return pD3DDevice;
906 }
907
909 return pViewport;
910 }
911
918
924 void Cleanup();
925
942 GUID *pDriverGuid,
943 int nWidth,
944 int nHeight,
945 int nBitDepth,
946 void *pSurfaceFormat,
947 GUID *pDeviceGuid,
948 bool bOption);
949
957
966
977 int SwitchDisplayModeAndRebuildDevice(int nWidth, int nHeight, int nBitDepth, int nExtra);
978
989 HRESULT
991
1000
1008
1019
1027
1036};
1037
1040private:
1041 DirectDrawRenderer *pRenderer;
1042
1049 HRESULT ValidateObjectRenderResources();
1050
1051public:
1054 return pRenderer;
1055 }
1056
1063
1071
1079
1088
1101 const char *pszImage,
1102 unsigned nImageKey);
1103
1111};
1112
1119
1125extern IDirect3D2 *g_pDirect3D2;
1126
1127#ifdef __cplusplus
1128extern "C" {
1129#endif
1130
1139
1146
1155
1162
1174
1181
1188
1208 int nWidth,
1209 int nHeight,
1210 int nBitDepth,
1211 void *pSurfaceFormat,
1212 GUID *pDeviceGuid,
1213 bool bMatchMode,
1214 DirectDrawDriver **ppDriver,
1215 DisplayMode **ppMode,
1216 D3DDeviceNode **ppDevice);
1217
1223extern unsigned char g_bDirectDrawDriversEnumerated;
1224
1232
1248 GUID *pDeviceGuid,
1249 int nWidth,
1250 int nHeight,
1251 int nBitDepth,
1252 void *pSurfaceFormat,
1253 DisplayMode **ppMode,
1254 D3DDeviceNode **ppDevice);
1255
1267 GUID *pDeviceGuid,
1268 DisplayMode **ppMode,
1269 D3DDeviceNode **ppDevice);
1270
1276extern "C" D3DDeviceNode *
1278
1287
1295DWORD BitDepthToDDBD(int nBitDepth);
1296
1303
1310
1318
1328
1338
1352 LPSTR pszDescription,
1353 LPSTR pszName,
1354 D3DDEVICEDESC *pHardwareDesc,
1355 D3DDEVICEDESC *pSoftwareDesc,
1356 LPVOID pContext);
1357
1369 LPSTR pszDescription,
1370 LPSTR pszName,
1371 LPVOID pContext);
1372
1381
1389
1398
1407
1422 int nWidth,
1423 int nHeight,
1424 int nBitDepth,
1425 int nUnknown,
1426 D3DDeviceNode *pDevice);
1427
1433extern int g_dwScreenBitDepth;
1434
1441
1449 return reinterpret_cast<DirectDrawRenderer *>(GetWindowLongA(hWnd, GWL_USERDATA));
1450}
1451
1458
1465
1474
1486bool ApplySelectedDisplayMode(int nWidth, int nHeight, int nBitDepth, int nExtra);
1487#ifdef __cplusplus
1488}
1489#endif
1490
A Direct3D device of a driver.
Definition renderer.h:293
HRESULT InitD3DDeviceNode(GUID *pGuid, LPSTR pszNewDescription, LPSTR pszNewName, D3DDEVICEDESC *pHardwareDesc, D3DDEVICEDESC *pSoftwareDesc)
Read a device Direct3D reports.
bool IsHardwareDevice()
Whether the device is a device of the hardware, one with a colour model of its own.
D3DDeviceNode * GetNext() const
Definition renderer.h:332
HRESULT EnumerateDeviceTextureFormats(IDirect3DDevice2 *pD3DDevice)
Find the texture formats a device created from the node supports.
const D3DDEVICEDESC * GetHardwareDescription() const
Definition renderer.h:320
HRESULT EnqueueTextureFormatNode(DisplayMode *pFormat)
Add a texture format to the end of the formats of the device.
const D3DDEVICEDESC * GetSoftwareDescription() const
Definition renderer.h:324
void ReleaseD3DDeviceNode()
Free the texture formats, the description, and the name of the device, and unlink it,...
void SetNext(D3DDeviceNode *device)
Link the following device.
Definition renderer.h:340
bool CompareD3DDeviceGuid(const GUID *pGuid)
Whether a GUID names the device, a device that was read alone.
GUID * GetGuid()
Definition renderer.h:316
void SetPrevious(D3DDeviceNode *device)
Link the preceding device.
Definition renderer.h:336
D3DDeviceNode * GetPrevious() const
Definition renderer.h:328
D3DDeviceNode()
Start a device without texts, with empty descriptions.
Definition renderer.h:362
A Direct3D material and the description it was set from.
Definition renderer.h:500
void SetDiffuseColor(float red, float green, float blue)
Set the diffuse red, green, and blue components and mark the material dirty.
Definition renderer.h:514
HRESULT CommitMaterialIfDirty()
Give desc to the material of Direct3D when it changed.
void SetRampSize(DWORD size)
Set the material's colour-ramp size.
Definition renderer.h:522
void Release()
Release the material of Direct3D.
D3DMaterial(IDirect3D2 *pDirect3D2, IDirect3DDevice2 *pD3DDevice)
Create an opaque material of Direct3D and its handle on a device.
D3DMATERIALHANDLE GetMaterialHandle() const
Definition renderer.h:509
HRESULT ApplyDescription()
Apply the material description to the Direct3D material.
Definition renderer.h:527
A texture of Direct3D created from an image in memory.
Definition renderer.h:558
bool LoadSysMemTextureToDevice()
Restore the texture surface and load it from the surface in system memory.
bool CreateD3DTexture(IDirect3DDevice2 *pDevice, void *pImage, int nWidth, int nHeight, int nPixelFormatId, DWORD dwColorKey)
Create the texture from an image.
D3DTEXTUREHANDLE GetTextureHandle() const
Definition renderer.h:568
void ReleaseD3DTextureInterfaces()
Release the interfaces of the texture and clear its handle.
bool UploadSurfaceToTexture(const void *pImage, int nWidth, int nHeight)
Copy an image into the surface in system memory and load the texture surface from it.
bool CreateD3DTextureDefault(IDirect3DDevice2 *pDevice, void *pImage, int nWidth, int nHeight, int nPixelFormatId)
Create the texture from an image with no transparent colour.
A DirectDraw driver the game found.
Definition renderer.h:57
bool CompareDirectDrawDriverGuid(const GUID *pGuid)
Whether a GUID selects the driver, a usable driver alone.
HRESULT AppendDirect3DDeviceNode(D3DDeviceNode *pDevice)
Add a Direct3D device to the end of the devices of the driver.
DirectDrawDriver * GetPrevious() const
Definition renderer.h:129
void SetPrevious(DirectDrawDriver *driver)
Link the preceding driver.
Definition renderer.h:137
DirectDrawDriver()
Start a driver that is not usable, with empty abilities.
Definition renderer.h:146
GUID * GetDirectDrawDriverGuid()
The GUID that selects the driver.
DisplayMode * GetDisplayModesHead() const
Definition renderer.h:125
void ShutdownDirectDrawDriver()
Free the devices and the modes of the driver.
unsigned GetDisplayModeCount() const
Definition renderer.h:121
const GUID * GetGuid() const
Definition renderer.h:113
const char * GetName() const
Definition renderer.h:117
HRESULT EnqueueDirectDrawModeNode(DisplayMode *pMode)
Add a display mode to the end of the modes of the driver.
void SetNext(DirectDrawDriver *driver)
Link the following driver.
Definition renderer.h:141
DirectDrawDriver * GetNext() const
Definition renderer.h:133
D3DDeviceNode * SelectPreferredD3DDevice(GUID *pGuid, D3DDeviceNode **ppPreferred, D3DDeviceNode *pFirst)
Select the device a GUID names, or report the device the game prefers: a device of the hardware,...
unsigned GetFlags() const
Definition renderer.h:109
D3DDeviceNode * FindRenderDevice(GUID *pGuid, DisplayMode *pMode, D3DDeviceNode **ppFallback, D3DDeviceNode *pFirst)
Find the device a GUID names that supports a display mode.
HRESULT InitializeDirectDrawDriver(GUID *pGuid, LPSTR pszName, LPSTR pszDescription)
Read a driver DirectDraw reports, with its devices and its modes.
DisplayMode * FindDisplayModeForDevice(int nWidth, int nHeight, int nBitDepth, void *pUnused, D3DDeviceNode *pDevice, DisplayMode **ppFallback, DisplayMode *pFirst)
Find a display mode of a size and a depth that a device supports.
DisplayMode * FindDisplayMode(int nWidth, int nHeight, int nBitDepth, void *pUnused, DisplayMode **ppFallback, DisplayMode *pFirst)
Find a display mode of a size and a depth.
The DirectDraw and Direct3D objects of a window.
Definition renderer.h:652
DirectDrawRenderer()
Clear the renderer.
void Cleanup()
Release every object of the renderer and forget its window.
HRESULT ChangeDisplayModeAndReinitDirectDraw(GUID *pGuid, D3DDeviceNode *pDevice, DisplayMode *pMode)
Move the renderer to another DirectDraw driver, a device, and a display mode, and create its DirectDr...
D3DDeviceNode * GetDevice() const
Definition renderer.h:884
HRESULT SetDeviceNotificationCallback(RenderHost *pRenderHost)
Give the renderer the host that draws through it, and give the host the renderer.
HRESULT GetDeviceViewportRect(RECT *pRect)
The rectangle of the viewport.
HRESULT BeginRenderScene()
Create the material of the background of the viewport.
HRESULT RestoreLostSurfaces()
Restore the front, back, and depth buffers that were lost, and the textures of the host.
IDirect3DViewport2 * GetViewport() const
Definition renderer.h:908
void FlipPrimarySurfaceAndWait()
Flip the back buffer to the front, waiting first until the front buffer can flip when g_bD3DWaitCanFl...
void AddFlags(int flags)
Add flags to the renderer flags.
Definition renderer.h:860
DirectDrawDriver * GetDriver() const
Definition renderer.h:876
D3DMaterial * GetMaterial() const
Definition renderer.h:848
IDirectDrawSurface * GetPrimarySurface() const
Definition renderer.h:896
void RemoveFlags(int flags)
Remove flags from the renderer flags.
Definition renderer.h:864
int GetDeviceInit() const
Definition renderer.h:852
int GetFlags() const
Definition renderer.h:856
IDirect3DDevice2 * GetD3DDevice() const
Definition renderer.h:904
DisplayMode * GetMode() const
Definition renderer.h:880
HRESULT AdjustGdiModeRefCount(bool bEnter)
Give the screen to GDI or take it back.
IDirectDrawSurface * GetBackBuffer() const
Definition renderer.h:900
HRESULT InitializeWindow(HWND hWnd, GUID *pDriverGuid, int nWidth, int nHeight, int nBitDepth, void *pSurfaceFormat, GUID *pDeviceGuid, bool bOption)
Select a driver, a device, and a mode, and create the objects that draw into a window.
IDirect3D2 * GetDirect3D2() const
Definition renderer.h:892
int SwitchDisplayModeAndRebuildDevice(int nWidth, int nHeight, int nBitDepth, int nExtra)
Switch the display mode of the window and create the device again.
IDirectDraw2 * GetDirectDraw2() const
Definition renderer.h:888
int GetRenderStateFlags() const
Definition renderer.h:868
int GetGdiModeRefCount() const
Definition renderer.h:872
HRESULT SetPrimarySurfacePalette()
Give the palette to the front buffer.
A display mode of a driver.
Definition renderer.h:423
void SetNext(DisplayMode *mode)
Link the following mode.
Definition renderer.h:455
DisplayMode()
Start an empty mode.
Definition renderer.h:460
void SetPrevious(DisplayMode *mode)
Link the preceding mode.
Definition renderer.h:451
DisplayMode * GetNext() const
Definition renderer.h:447
DisplayMode * GetPrevious() const
Definition renderer.h:443
bool IsDisplayModeMatch(int nWidth, int nHeight, int nBitDepth)
Whether the mode has a size and a depth.
bool IsDisplayModeSupportedByDevice(D3DDeviceNode *pDevice)
Whether a device can draw in the depth of the mode.
HRESULT GetSurfaceDescDimensions(int *pnWidth, int *pnHeight, int *pnBitDepth, int *pnRefreshRate)
The size and the bits of a pixel of the mode.
void SetDescription(const DDSURFACEDESC &description)
Replace the mode's DirectDraw surface description.
Definition renderer.h:439
What the game draws through: the renderer of the main window.
Definition renderer.h:1039
DirectDrawRenderer * GetRenderer() const
Definition renderer.h:1053
RenderHost()
Start without a renderer.
int OnDestroyDevice()
Prepare for the device of the renderer to go.
HRESULT ValidateRenderDeviceState()
Whether the renderer is ready and has its Direct3D objects.
HRESULT SetRenderer(DirectDrawRenderer *pNewRenderer)
Draw through a renderer.
int ReloadTextureSurfacesAfterRestore()
Load the textures again after the surfaces of the renderer were restored.
HRESULT RenderLoadingScreen(DirectDrawRenderer *pWindowRenderer, const char *pszImage, unsigned nImageKey)
Show an image of the game while the game loads.
IDirectDraw * GetDirectDrawFromD3DDevice(IDirect3DDevice2 *pDevice)
Find the DirectDraw object of a device through its render target.
void PresentFrameCallback_FlipSurfaces(void)
Flip the frame of the main window.
DirectDrawDriver * FindDirectDrawDriverByGuid(GUID *pGuid, DirectDrawDriver **ppPrimary, DirectDrawDriver *pFirst)
Find the driver a GUID selects, and the primary driver on the way.
int g_dwScreenBitDepth
The bits of a pixel of the display mode set.
int g_dwActiveDisplayDeviceIndex
The index in the list of DirectDraw drivers of the driver in use.
#define DIRECTDRAW_DRIVER_USABLE
A DirectDraw driver usable by the game.
Definition renderer.h:48
IDirect3D2 * g_pDirect3D2
The Direct3D interface of the renderer that created it last.
DWORD BitDepthToDDBD(int nBitDepth)
The DDBD_ flag of a depth.
HRESULT WINAPI EnumDeviceTextureFormatsCallback_AddFormat(DDSURFACEDESC *pDesc, LPVOID pContext)
Record a texture format of a device that Direct3D reports.
IDirect3DDevice2 * g_pD3DDevice2
The Direct3D device of the renderer that created it last.
HRESULT WINAPI EnumDisplayModesCallback_AddMode(DDSURFACEDESC *pDesc, LPVOID pContext)
Record a display mode of a driver that DirectDraw reports.
bool FindDesktopDisplayModeAndDevice(DirectDrawDriver *pDriver, GUID *pDeviceGuid, DisplayMode **ppMode, D3DDeviceNode **ppDevice)
Select a device of a driver and the mode of the desktop.
HRESULT WINAPI EnumD3DDevicesCallback(GUID *pGuid, LPSTR pszDescription, LPSTR pszName, D3DDEVICEDESC *pHardwareDesc, D3DDEVICEDESC *pSoftwareDesc, LPVOID pContext)
Record a Direct3D device of a driver that Direct3D reports.
void EnumerateTextureFormats(IDirect3DDevice2 *pD3DDevice)
Find the texture formats of a Direct3D device for each entry of g_aTexturePixelFormats,...
static DirectDrawRenderer * GetWindowRenderer(HWND hWnd)
The renderer a window stores, set by AttachRenderDeviceToWindow().
Definition renderer.h:1448
D3DTexture ** g_ppTextureIdTable
The textures of Direct3D by identifier.
HRESULT EnsureDirectDrawDriversEnumerated(void)
Find the DirectDraw drivers and their devices and modes, once.
D3DDEVICEDESC g_D3DHelDeviceDesc
What the emulation of the device created last does.
D3DDEVICEDESC g_D3DHalDeviceDesc
What the hardware of the device created last does.
DisplayMode * FindDisplayModeWithFallback(DirectDrawDriver *pDriver, int nWidth, int nHeight, int nBitDepth, int nUnknown, D3DDeviceNode *pDevice)
Find a mode of a driver for a size and a depth, for a device.
D3DDeviceNode * ResolveRenderDeviceOrFind(DirectDrawDriver *pDriver, GUID *pDeviceGuid, DisplayMode *pMode)
Resolve a device by GUID and optional display mode, using the reported fallback on failure.
int g_dwSelectedDisplayDeviceIndex
The index in the list of DirectDraw drivers of the driver the menu of devices selects.
RenderHost * g_pRenderHost
The host the game draws through.
int DDBDToBitDepth(DWORD dwMask)
The bits of a depth from the DDBD_ flags of the depths.
DirectDrawDriver * g_pDirectDrawDriverListHead
The DirectDraw drivers the game found, linked by DirectDrawDriver::pNext.
bool IsPixelFormatPalettized(const DDPIXELFORMAT *pFormat)
Whether a pixel format indexes a palette of 1, 2, 4, or 8 bits.
HRESULT AppendDirectDrawDriverNode(DirectDrawDriver *pDriver)
Add a driver to the end of the list of drivers.
BOOL WINAPI EnumDirectDrawDriversCallback(GUID *pGuid, LPSTR pszDescription, LPSTR pszName, LPVOID pContext)
Record a DirectDraw driver that DirectDraw reports.
bool SelectDeviceAndDisplayMode(DirectDrawDriver *pDriver, GUID *pDeviceGuid, int nWidth, int nHeight, int nBitDepth, void *pSurfaceFormat, DisplayMode **ppMode, D3DDeviceNode **ppDevice)
Select a device of a driver and a mode that matches a size.
void InitializeAllTextureSurfaces(void)
Load every texture the game loaded into its texture surface again, after the surfaces were lost.
bool ApplySelectedDisplayMode(int nWidth, int nHeight, int nBitDepth, int nExtra)
Move the main window to the DirectDraw driver of g_GlobalRallyConfig when it differs from the driver ...
DirectDrawDriver * FindDirectDrawDriverOrDefault(GUID *pGuid)
The first DirectDraw driver the game found with a GUID, or the default.
HRESULT SelectDriverDeviceAndModeFromConfig(GUID *pDriverGuid, int nWidth, int nHeight, int nBitDepth, void *pSurfaceFormat, GUID *pDeviceGuid, bool bMatchMode, DirectDrawDriver **ppDriver, DisplayMode **ppMode, D3DDeviceNode **ppDevice)
Select the driver, device, and mode of a renderer, finding the drivers first if the game has not.
unsigned char g_bDirectDrawDriversEnumerated
Whether the DirectDraw drivers were found, in bit 0.
HRESULT EnumerateDirectDrawDrivers(void)
Find the DirectDraw drivers and their devices and modes.
void QueryD3DDeviceCaps(IDirect3DDevice2 *pD3DDevice)
Read what a Direct3D device can do.
DirectDrawDriver * g_pSelectedDisplayDriver
The DirectDraw driver chosen in the configuration.
DirectDrawDriver * FindDisplayDeviceByGuid(GUID *pGuid)
Find the DirectDraw driver of a GUID and make it the selected one.
typedef D3DMATERIALHANDLE
typedef D3DTEXTUREHANDLE
typedef DDCAPS
GetWindowLongA()
What the search of the DirectDraw drivers found.
Definition renderer.h:1312
int bSucceeded
Definition renderer.h:1313
void * pOwner
The driver whose modes or devices, or the device whose formats, are found, if any.
Definition renderer.h:1316
int nFound
Definition renderer.h:1314
typedef BOOL
typedef DWORD
typedef HRESULT
typedef HWND
typedef LPSTR
typedef LPVOID
typedef WINAPI
#define GWL_USERDATA