7#if !defined(MXDIRECTX_FOR_CONFIG)
19 m_pDirect3dDevice =
NULL;
20 m_bTexturesDisabled =
FALSE;
21 m_currentDeviceInfo =
NULL;
36 BOOL surface_fullscreen,
37 BOOL onlySystemMemory,
41 const PALETTEENTRY* pPaletteEntries,
46 assert(m_currentDeviceInfo);
87 if (m_currentDeviceInfo) {
88 delete m_currentDeviceInfo;
89 m_currentDeviceInfo =
NULL;
114 result =
DirectDraw()->QueryInterface(IID_IDirect3D2, (
LPVOID*) &m_pDirect3d);
115 if (result !=
DD_OK) {
116 Error(
"Creation of IDirect3D failed", result);
126 assert(m_currentDeviceInfo);
130 Error(
"Failed to place vital surfaces in video memory for hardware driver",
DDERR_GENERIC);
135 m_bTexturesDisabled =
FALSE;
138 m_bTexturesDisabled =
TRUE;
147 m_bTexturesDisabled =
FALSE;
150 m_bTexturesDisabled =
TRUE;
159 HRESULT result = m_pDirect3d->CreateDevice(m_currentDeviceInfo->m_guid, backBuf, &m_pDirect3dDevice);
161 if (result !=
DD_OK) {
162 Error(
"Create D3D device failed", result);
179 memset(&desc, 0,
sizeof(desc));
180 desc.
dwSize =
sizeof(desc);
183 unsigned char* surface = (
unsigned char*) desc.
lpSurface;
185 for (
int i = 0; i < mode.
height; i++) {
193 OutputDebugString(
"MxDirect3D::D3DSetMode() back lock failed\n");
197 memset(&desc, 0,
sizeof(desc));
198 desc.
dwSize =
sizeof(desc);
201 unsigned char* surface = (
unsigned char*) desc.
lpSurface;
203 for (
int i = 0; i < mode.
height; i++) {
211 OutputDebugString(
"MxDirect3D::D3DSetMode() front lock failed\n");
235 else if (deviceDepth &
DDBD_24) {
238 else if (deviceDepth &
DDBD_16) {
241 else if (deviceDepth &
DDBD_8) {
255 if (m_currentDeviceInfo) {
256 delete m_currentDeviceInfo;
257 m_currentDeviceInfo =
NULL;
265 for (list<MxDriver>::iterator it = p_deviceEnumerate.
m_list.begin(); it != p_deviceEnumerate.
m_list.end();
269 if (&driver == p_driver) {
273 d->m_deviceInfo->
m_guid =
new GUID;
279 if (d->m_deviceInfo->
m_count > 0) {
283 for (list<MxDisplayMode>::iterator it2 = driver.
m_displayModes.begin();
298 for (list<Direct3DDeviceInfo>::iterator it2 = driver.
m_devices.begin(); it2 != driver.
m_devices.end();
301 if (&device == p_device) {
302 memcpy(&d->m_guid, device.
m_guid,
sizeof(d->m_guid));
312 m_currentDeviceInfo = d;
320 if (!m_currentDeviceInfo) {
[AI] Holds assignment and description details for a Direct3D rendering device in use.
@ c_primaryDevice
[AI] Flags the device as the system's primary device.
@ c_hardwareMode
[AI] Indicates that the device is a hardware rendering device.
[AI] Enumerates DirectDraw/Direct3D drivers, devices, and display modes on the system.
list< MxDriver > m_list
[AI] List of all discovered DirectDraw drivers and their device/mode info.
[AI] MxDirect3D provides Direct3D (D3D) rendering capabilities layered on top of MxDirectDraw,...
~MxDirect3D() override
[AI] Destroys the MxDirect3D object, releasing associated Direct3D interfaces and memory for assigned...
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...
BOOL D3DCreate()
[AI] Internal D3D initialization helper: acquires the IDirect3D2 interface from DirectDraw.
void DestroyButNotDirectDraw() override
[AI] Like Destroy(), but preserves the DirectDraw context; only Direct3D/3DDevice and D3D-specific ob...
int ZBufferDepth(MxAssignedDevice *p_assignedDevice)
[AI] Determines the suitable ZBuffer depth for a selected rendering device, according to its capabili...
BOOL D3DSetMode()
[AI] Internal method to initialize D3D video mode, create devices, ZBuffer, and clear surfaces as nee...
MxDirect3D()
[AI] Constructs a new MxDirect3D object.
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,...
void Destroy() override
[AI] Tears down the Direct3D environment, including releasing D3D and D3DDevice objects,...
void FUN_1009d920()
Internal: Restores original palette and resets display mode and cooperative level.
BOOL IsSupportedMode(int width, int height, int bpp)
Checks if the given mode (resolution, bpp) is supported by the current device.
BOOL m_bOnlySoftRender
If TRUE, restricts rendering to software only; disables hardware acceleration. [AI].
IDirectDrawSurface * BackBuffer()
Returns the back buffer surface.
IDirectDraw * DirectDraw()
Returns the DirectDraw device interface pointer.
DeviceModesInfo * m_currentDevInfo
Device info array for storing supported display modes. [AI].
virtual void Destroy()
Shuts down DirectDraw and releases all resources, including device and surfaces.
BOOL CreateZBuffer(DWORD memorytype, DWORD depth)
Creates a z-buffer with the given memory type/capabilities and attaches it to the back buffer.
virtual void DestroyButNotDirectDraw()
Releases all DirectDraw-related resources except the DirectDraw device itself.
void Error(const char *p_message, int p_error)
Invokes the error handler, optionally destroying the device, and outputs the given error message/code...
BOOL IsFullScreen()
Returns TRUE if DirectDraw is currently set in exclusive fullscreen mode.
DeviceModesInfo::Mode * CurrentMode()
Provides access to the current selected display mode (width, height, bpp).
IDirectDrawSurface * FrontBuffer()
Returns the surface used as the primary/front buffer.
virtual BOOL Create(HWND hWnd, BOOL fullscreen_1, BOOL surface_fullscreen, BOOL onlySystemMemory, int width, int height, int bpp, const PALETTEENTRY *pPaletteEntries, int paletteEntryCount)
Creates and initializes the DirectDraw device and associated surfaces/windows/state.
#define D3DDD_DEVICEZBUFFERBITDEPTH
#define D3DPTEXTURECAPS_PERSPECTIVE
struct IDirectDrawSurface FAR * LPDIRECTDRAWSURFACE
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
#define DDSCAPS_VIDEOMEMORY
#define DDSCAPS_SYSTEMMEMORY
#define DECOMP_SIZE_ASSERT(T, S)
#define NULL
[AI] Null pointer value (C/C++ semantics).
[AI] Represents a specific display mode supported by the device (width, height, bits per pixel).
int bitsPerPixel
[AI] Color depth (bits per pixel)
int width
[AI] Horizontal resolution in pixels
int height
[AI] Vertical resolution in pixels
[AI] Contains detailed information about a Direct3D device's supported display modes and capabilities...
DDCAPS m_ddcaps
[AI] Capabilities of the DirectDraw device as filled by GetCaps.
Mode * m_modeArray
[AI] Array of supported display modes; dynamically allocated and owned.
int m_count
[AI] Number of display modes in m_modeArray.
GUID * m_guid
[AI] GUID of the video device (heap-allocated and owned by this struct).
[AI] Encapsulates Direct3D device enumeration information and capability structures.
D3DDEVICEDESC m_HWDesc
[AI] Hardware Direct3D device capability description.
D3DDEVICEDESC m_HELDesc
[AI] Software (HEL) emulation device capability description.
LPGUID m_guid
[AI] GUID uniquely identifying this 3D device. [AI]
[AI] Holds data about a DirectDraw driver including devices and supported display modes.
LPGUID m_guid
[AI] GUID for this DirectDraw driver (heap-allocated and owned).
list< MxDisplayMode > m_displayModes
[AI] List of all display modes reported by the driver.
DDCAPS m_ddCaps
[AI] Capabilities structure as reported by the driver.
list< Direct3DDeviceInfo > m_devices
[AI] List of all Direct3D devices provided by this driver.
DWORD dwDeviceZBufferBitDepth
D3DCOLORMODEL dcmColorModel
DDPIXELFORMAT ddpfPixelFormat