World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл RenderD3D.cpp

См. исходные тексты.

Функции

HRESULT __stdcall DDrawDisplayModesEnumerator (DDSURFACEDESC2 *pSurfaceDesc, __int16 *found_compatible_mode)
 
HRESULT __stdcall D3DDeviceEnumerator (const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6)
 
int __stdcall RenderD3D__DeviceEnumerator (GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut)
 
HRESULT __stdcall D3DZBufferFormatEnumerator (DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst)
 
unsigned int GetMaxMipLevels (unsigned int uDim)
 

Функции

◆ DDrawDisplayModesEnumerator()

HRESULT __stdcall DDrawDisplayModesEnumerator ( DDSURFACEDESC2 *  pSurfaceDesc,
__int16 *  found_compatible_mode 
)

См. определение в файле RenderD3D.cpp строка 9

10  {
11  if (pSurfaceDesc->ddsCaps.dwCaps | DDSCAPS_3DDEVICE) {
12  *found_compatible_mode = 1;
13  return S_OK;
14  }
15  return 1;
16 }

Используется в RenderD3D__DeviceEnumerator().

+ Граф вызова функции:

◆ D3DDeviceEnumerator()

HRESULT __stdcall D3DDeviceEnumerator ( const GUID *  lpGUID,
const char *  lpDeviceDesc,
const char *  lpDeviceName,
D3DDEVICEDESC *  pHWDesc,
D3DDEVICEDESC *  pSWDesc,
RenderD3D_aux a6 
)

См. определение в файле RenderD3D.cpp строка 18

20  {
21  int v7 = -1;
22  if (pHWDesc->dwFlags) {
23  if (!a6->ptr_4->pGUID) v7 = 0;
24  if (pHWDesc->dwFlags && a6->ptr_4->pGUID) v7 = 1;
25  }
26  if (!strcmp(lpDeviceName, "RGB Emulation") && !a6->ptr_4->pGUID) v7 = 2;
27  if (!strcmp(lpDeviceName, "Reference Rasterizer") && !a6->ptr_4->pGUID)
28  v7 = 3;
29  if (v7 != -1) {
30  a6->pInfo[v7].bIsDeviceCompatible = 1;
31  a6->pInfo[v7].uCaps = 0;
32  if (!(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 0x10))
33  a6->pInfo[v7].uCaps |= 2;
34  if (!(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 2)) a6->pInfo[v7].uCaps |= 4;
35  if (!(pHWDesc->dpcTriCaps.dwSrcBlendCaps & 1)) a6->pInfo[v7].uCaps |= 8;
36  if (!(pHWDesc->dpcTriCaps.dwDestBlendCaps & 0x20))
37  a6->pInfo[v7].uCaps |= 16;
38  if (!(pHWDesc->dpcTriCaps.dwDestBlendCaps & 2))
39  a6->pInfo[v7].uCaps |= 32;
40  if (!(pHWDesc->dpcTriCaps.dwDestBlendCaps & 4))
41  a6->pInfo[v7].uCaps |= 64;
42  if (!(pHWDesc->dwDevCaps & 0x1000)) a6->pInfo[v7].uCaps |= 0x100;
43  if (pHWDesc->dpcTriCaps.dwTextureCaps & 0x20)
44  a6->pInfo[v7].uCaps |= 0x80;
45 
46  a6->pInfo[v7].pName = new char[strlen(lpDeviceName) + 1];
47  strcpy(a6->pInfo[v7].pName, lpDeviceName);
48 
49  a6->pInfo[v7].pDescription = new char[strlen(lpDeviceDesc) + 1];
50  strcpy(a6->pInfo[v7].pDescription, lpDeviceDesc);
51 
52  a6->pInfo[v7].pGUID = new GUID;
53  memcpy(a6->pInfo[v7].pGUID, lpGUID, 0x10);
54 
55  a6->pInfo[v7].pDriverName = strdup(a6->ptr_4->pDriverName);
56  a6->pInfo[v7].pDeviceDesc = strdup(a6->ptr_4->pDeviceDesc);
57  a6->pInfo[v7].pDDraw4DevDesc = strdup(a6->ptr_4->pDDraw4DevDesc);
58 
59  if (a6->ptr_4->pGUID) {
60  a6->pInfo[v7].pDirectDrawGUID = new GUID;
61  memcpy(a6->pInfo[v7].pDirectDrawGUID, a6->ptr_4->pGUID, 0x10);
62  } else {
63  a6->pInfo[v7].pDirectDrawGUID = 0;
64  }
65  a6->pInfo[v7].uVideoMem = a6->ptr_4->uVideoMem;
66  }
67  return 1;
68 }

Перекрестные ссылки RenderD3D__DevInfo::bIsDeviceCompatible, RenderD3D__DevInfo::pDDraw4DevDesc, RenderD3D_D3DDevDesc::pDDraw4DevDesc, RenderD3D__DevInfo::pDescription, RenderD3D__DevInfo::pDeviceDesc, RenderD3D_D3DDevDesc::pDeviceDesc, RenderD3D__DevInfo::pDirectDrawGUID, RenderD3D__DevInfo::pDriverName, RenderD3D_D3DDevDesc::pDriverName, RenderD3D__DevInfo::pGUID, RenderD3D_D3DDevDesc::pGUID, RenderD3D_aux::pInfo, RenderD3D__DevInfo::pName, RenderD3D_aux::ptr_4, RenderD3D__DevInfo::uCaps, RenderD3D__DevInfo::uVideoMem и RenderD3D_D3DDevDesc::uVideoMem.

Используется в RenderD3D__DeviceEnumerator().

+ Граф вызова функции:

◆ RenderD3D__DeviceEnumerator()

int __stdcall RenderD3D__DeviceEnumerator ( GUID *  lpGUID,
const char *  lpDevDesc,
const char *  lpDriverName,
RenderD3D__DevInfo pOut 
)

См. определение в файле RenderD3D.cpp строка 70

72  {
73  size_t v5; // eax@1
74  size_t v7; // eax@13
75  DDDEVICEIDENTIFIER ddDevId; // [sp+4h] [bp-4F8h]@11
76  DDSURFACEDESC2 v10; // [sp+42Ch] [bp-D0h]@16
77  DDSCAPS2 ddsCaps; // [sp+4A8h] [bp-54h]@14
78  unsigned int uFreeVideoMem; // [sp+4B8h] [bp-44h]@14
79  RenderD3D_aux aux; // [sp+4BCh] [bp-40h]@19
80  IDirect3D3 *pDirect3D3; // [sp+4C4h] [bp-38h]@18
81  int is_there_a_compatible_screen_mode; // [sp+4C8h] [bp-34h]@16
82  IDirectDraw4 *pDirectDraw4; // [sp+4F8h] [bp-4h]@7
83 
84  RenderD3D_D3DDevDesc v20 = {0};
85  size_t v4 = strlen(lpDriverName);
86  v20.pDriverName = new char[v4 + 1];
87  v5 = strlen(lpDevDesc);
88  v20.pDeviceDesc = new char[v5 + 1];
89  strcpy(v20.pDriverName, lpDriverName);
90  strcpy(v20.pDeviceDesc, lpDevDesc);
91  if (lpGUID) {
92  v20.pGUID = new GUID;
93  memcpy(v20.pGUID, lpGUID, 0x10);
94  } else {
95  v20.pGUID = 0;
96  }
97 
98  LPDIRECTDRAW pDirectDraw = nullptr;
99  if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0))) {
100  delete[] v20.pDriverName;
101  delete[] v20.pDeviceDesc;
102  delete v20.pGUID;
103  } else {
104  if (FAILED(pDirectDraw->QueryInterface(IID_IDirectDraw4,
105  (LPVOID *)&pDirectDraw4))) {
106  delete[] v20.pDriverName;
107  delete[] v20.pDeviceDesc;
108  delete v20.pGUID;
109  pDirectDraw->Release();
110  } else {
111  pDirectDraw->Release();
112  if (FAILED(pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1))) {
113  v20.pDDraw4DevDesc = 0;
114  } else {
115  v7 = strlen(ddDevId.szDescription);
116  v20.pDDraw4DevDesc = new char[v7 + 1];
117  strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription);
118  }
119  memset(&ddsCaps, 0, sizeof(ddsCaps));
120  if (FAILED(pDirectDraw4->GetAvailableVidMem(
121  &ddsCaps, (LPDWORD)&v20.uVideoMem,
122  (LPDWORD)&uFreeVideoMem)))
123  v20.uVideoMem = 0;
124  memset(&v10, 0, sizeof(v10));
125  v10.dwSize = 124;
126  v10.dwFlags = 6;
127  v10.dwHeight = window->GetWidth();
128  v10.dwWidth = window->GetHeight();
129  v10.ddpfPixelFormat.dwSize = 32;
130 
131  is_there_a_compatible_screen_mode = false;
132  if (FAILED(pDirectDraw4->EnumDisplayModes(
133  0, 0, &is_there_a_compatible_screen_mode,
134  (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator)) ||
135  !is_there_a_compatible_screen_mode ||
136  FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3,
137  (LPVOID *)&pDirect3D3))) {
138  delete[] v20.pDriverName;
139  delete[] v20.pDeviceDesc;
140  // free(v20.pDDraw4DevDesc);
141  delete[] v20.pDDraw4DevDesc;
142  delete v20.pGUID;
143  pDirectDraw4->Release();
144  } else {
145  aux.pInfo = pOut;
146  aux.ptr_4 = &v20;
147  pDirect3D3->EnumDevices(
148  (LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux);
149  delete[] v20.pDriverName;
150  delete[] v20.pDeviceDesc;
151  delete[] v20.pDDraw4DevDesc;
152  delete v20.pGUID;
153  pDirectDraw4->Release();
154  pDirectDraw4 = 0;
155  pDirect3D3->Release();
156  }
157  }
158  }
159  return 1;
160 }

Перекрестные ссылки D3DDeviceEnumerator(), DDrawDisplayModesEnumerator(), RenderD3D_D3DDevDesc::pDDraw4DevDesc, RenderD3D_D3DDevDesc::pDeviceDesc, RenderD3D_D3DDevDesc::pDriverName, RenderD3D_D3DDevDesc::pGUID, RenderD3D_aux::pInfo, RenderD3D_aux::ptr_4 и RenderD3D_D3DDevDesc::uVideoMem.

Используется в RenderD3D::GetAvailableDevices().

+ Граф вызовов:
+ Граф вызова функции:

◆ D3DZBufferFormatEnumerator()

HRESULT __stdcall D3DZBufferFormatEnumerator ( DDPIXELFORMAT *  Src,
DDPIXELFORMAT *  Dst 
)

См. определение в файле RenderD3D.cpp строка 162

163  {
164  if (Src->dwFlags & (0x400 | 0x2000)) {
165  if (Src->dwRGBBitCount == 16 && !Src->dwRBitMask) {
166  memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
167  return 0;
168  }
169  if (!Dst->dwSize) {
170  memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
171  return 1;
172  }
173  }
174  return 1;
175 }

Используется в RenderD3D::CreateDevice().

+ Граф вызова функции:

◆ GetMaxMipLevels()

unsigned int GetMaxMipLevels ( unsigned int  uDim)

См. определение в файле RenderD3D.cpp строка 771

771  {
772  int v2 = 0;
773  unsigned int v3 = uDim - 1;
774  while (v3 & 1) {
775  v3 >>= 1;
776  ++v2;
777  }
778  return v3 == 0 ? v2 : 0;
779 }

Используется в RenderD3D::CreateTexture().

+ Граф вызова функции:
RenderD3D__DevInfo::pGUID
GUID * pGUID
Definition: RenderD3D.h:35
RenderD3D_D3DDevDesc::pDeviceDesc
char * pDeviceDesc
Definition: RenderD3D.h:54
RenderD3D__DevInfo::pName
char * pName
Definition: RenderD3D.h:33
RenderD3D__DevInfo::pDirectDrawGUID
GUID * pDirectDrawGUID
Definition: RenderD3D.h:40
RenderD3D__DevInfo::pDDraw4DevDesc
char * pDDraw4DevDesc
Definition: RenderD3D.h:39
RenderD3D__DevInfo::pDescription
char * pDescription
Definition: RenderD3D.h:34
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
RenderD3D_aux::ptr_4
RenderD3D_D3DDevDesc * ptr_4
Definition: RenderD3D.h:62
RenderD3D_D3DDevDesc::pDriverName
char * pDriverName
Definition: RenderD3D.h:53
RenderD3D_D3DDevDesc
Definition: RenderD3D.h:47
RenderD3D__DevInfo::uVideoMem
int uVideoMem
Definition: RenderD3D.h:41
RenderD3D_D3DDevDesc::pDDraw4DevDesc
char * pDDraw4DevDesc
Definition: RenderD3D.h:55
v2
GLfloat GLfloat GLfloat v2
Definition: SDL_opengl_glext.h:695
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: SDL_opengl_glext.h:696
D3DDeviceEnumerator
HRESULT __stdcall D3DDeviceEnumerator(const GUID *lpGUID, const char *lpDeviceDesc, const char *lpDeviceName, D3DDEVICEDESC *pHWDesc, D3DDEVICEDESC *pSWDesc, RenderD3D_aux *a6)
Definition: RenderD3D.cpp:18
RenderD3D_aux
Definition: RenderD3D.h:60
RenderD3D__DevInfo::bIsDeviceCompatible
unsigned int bIsDeviceCompatible
Definition: RenderD3D.h:32
RenderD3D__DevInfo::pDeviceDesc
char * pDeviceDesc
Definition: RenderD3D.h:38
DDrawDisplayModesEnumerator
HRESULT __stdcall DDrawDisplayModesEnumerator(DDSURFACEDESC2 *pSurfaceDesc, __int16 *found_compatible_mode)
Definition: RenderD3D.cpp:9
RenderD3D_aux::pInfo
RenderD3D__DevInfo * pInfo
Definition: RenderD3D.h:61
RenderD3D_D3DDevDesc::uVideoMem
unsigned int uVideoMem
Definition: RenderD3D.h:57
RenderD3D__DevInfo::uCaps
unsigned int uCaps
Definition: RenderD3D.h:36
RenderD3D_D3DDevDesc::pGUID
GUID * pGUID
Definition: RenderD3D.h:56
RenderD3D__DevInfo::pDriverName
char * pDriverName
Definition: RenderD3D.h:37