Isle
Loading...
Searching...
No Matches
mxdirectdraw.h
Go to the documentation of this file.
1#ifndef MXDIRECTDRAW_H
2#define MXDIRECTDRAW_H
3
4#include "mxdirectxinfo.h"
5
6#include <ddraw.h>
7#include <windows.h>
8
9// VTABLE: LEGO1 0x100db818
10// VTABLE: BETA10 0x101c1b10
11// SIZE 0x880
12
18public:
25 typedef void (*ErrorHandler)(const char*, HRESULT, void*);
26
31 static int GetPrimaryBitDepth();
32
37
41 virtual ~MxDirectDraw();
42
56 virtual BOOL Create(
57 HWND hWnd,
58 BOOL fullscreen_1,
59 BOOL surface_fullscreen,
60 BOOL onlySystemMemory,
61 int width,
62 int height,
63 int bpp,
64 const PALETTEENTRY* pPaletteEntries,
65 int paletteEntryCount
66 ); // vtable+0x04
67
71 virtual void Destroy(); // vtable+0x08
72
76 virtual void DestroyButNotDirectDraw(); // vtable+0x0c
77
82 IDirectDraw* DirectDraw() { return m_pDirectDraw; }
83
88 IDirectDrawSurface* FrontBuffer() { return m_pFrontBuffer; }
89
94 IDirectDrawSurface* BackBuffer() { return m_pBackBuffer; }
95
100 IDirectDrawClipper* Clipper() { return m_pClipper; }
101
107
112
120 BOOL IsSupportedMode(int width, int height, int bpp);
121
127 int Pause(BOOL);
128
135
141 BOOL TextToTextSurface1(const char* text);
142
148 BOOL TextToTextSurface2(const char* lpString);
149
155 virtual const char* ErrorToString(HRESULT p_error); // vtable+0x10
156
161 int FlipToGDISurface();
162
163protected:
171 BOOL SetPaletteEntries(const PALETTEENTRY* pPaletteEntries, int paletteEntryCount, BOOL fullscreen);
172
178
184
190
196 BOOL DDInit(BOOL fullscreen);
197
206 BOOL DDSetMode(int width, int height, int bpp);
207
213
222
230
237 BOOL CreateZBuffer(DWORD memorytype, DWORD depth);
238
244
252 BOOL TextToTextSurface(const char* text, IDirectDrawSurface* pSurface, SIZE& textSizeOnSurface);
253
259 void Error(const char* p_message, int p_error);
260
267 BOOL RecreateDirectDraw(GUID** a2);
268
273 void FUN_1009e020();
274
279 void FUN_1009d920();
280
281 // SYNTHETIC: LEGO1 0x1009d510
282 // SYNTHETIC: BETA10 0x10122f80
283 // MxDirectDraw::`scalar deleting destructor'
284
285protected:
288 IDirectDraw* m_pDirectDraw;
289 IDirectDrawSurface* m_pFrontBuffer;
290 IDirectDrawSurface* m_pBackBuffer;
291 IDirectDrawSurface* m_pZBuffer;
292 IDirectDrawSurface* m_pText1Surface;
293 IDirectDrawSurface* m_pText2Surface;
294 IDirectDrawClipper* m_pClipper;
295 IDirectDrawPalette* m_pPalette;
296 PALETTEENTRY m_paletteEntries[256];
297 PALETTEENTRY m_originalPaletteEntries[256];
301 HFONT m_hFont;
315};
316
317#endif // MXDIRECTDRAW_H
Class responsible for interfacing with DirectDraw to manage rendering surfaces, palettes,...
Definition: mxdirectdraw.h:17
void FUN_1009d920()
Internal: Restores original palette and resets display mode and cooperative level.
IDirectDrawSurface * m_pBackBuffer
Backbuffer for offscreen rendering/flipping. [AI].
Definition: mxdirectdraw.h:290
BOOL IsSupportedMode(int width, int height, int bpp)
Checks if the given mode (resolution, bpp) is supported by the current device.
PALETTEENTRY m_originalPaletteEntries[256]
Backup of system/Windows palette for restoration. [AI].
Definition: mxdirectdraw.h:297
BOOL m_bIgnoreWMSIZE
Internal flag to suppress window resize messages during device switching. [AI].
Definition: mxdirectdraw.h:302
BOOL DDInit(BOOL fullscreen)
Initializes DirectDraw cooperative level for fullscreen or windowed mode.
PALETTEENTRY m_paletteEntries[256]
Active 8-bit palette entries for palettized modes. [AI].
Definition: mxdirectdraw.h:296
BOOL SetPaletteEntries(const PALETTEENTRY *pPaletteEntries, int paletteEntryCount, BOOL fullscreen)
Sets the DirectDraw palette using the provided palette entries.
BOOL m_bOnlySoftRender
If TRUE, restricts rendering to software only; disables hardware acceleration. [AI].
Definition: mxdirectdraw.h:286
IDirectDrawSurface * BackBuffer()
Returns the back buffer surface.
Definition: mxdirectdraw.h:94
HRESULT CreateDDSurface(LPDDSURFACEDESC a2, LPDIRECTDRAWSURFACE *a3, IUnknown *a4)
Creates a DirectDraw surface with the given surface description.
IDirectDrawClipper * m_pClipper
Clipper for managing windowed surface boundaries. [AI].
Definition: mxdirectdraw.h:294
BOOL CacheOriginalPaletteEntries()
Caches the original Windows/system palette for restoration.
IDirectDrawSurface * m_pText2Surface
Debug overlay surface for "text2". [AI].
Definition: mxdirectdraw.h:293
static int GetPrimaryBitDepth()
Returns the bit depth (color depth) of the primary display device.
BOOL m_bPrimaryPalettized
TRUE if primary/backbuffer is using 8-bit palettized mode. [AI].
Definition: mxdirectdraw.h:303
virtual const char * ErrorToString(HRESULT p_error)
Converts DirectDraw error code to a human-readable string.
ErrorHandler m_pErrorHandler
Callback for non-fatal DirectDraw errors. [AI].
Definition: mxdirectdraw.h:308
IDirectDrawSurface * m_pZBuffer
Attached Z-buffer for 3D rendering. [AI].
Definition: mxdirectdraw.h:291
SIZE m_text2SizeOnSurface
Pixel size of rendered text2 overlay surface. [AI].
Definition: mxdirectdraw.h:299
DeviceModesInfo::Mode m_currentMode
Struct with current width, height, and bits per pixel. [AI].
Definition: mxdirectdraw.h:314
HFONT m_hFont
Font handle for debug text overlays. [AI].
Definition: mxdirectdraw.h:301
BOOL TextToTextSurface(const char *text, IDirectDrawSurface *pSurface, SIZE &textSizeOnSurface)
Renders a string to the given surface and fills in its onscreen size.
IDirectDraw * DirectDraw()
Returns the DirectDraw device interface pointer.
Definition: mxdirectdraw.h:82
BOOL TextToTextSurface1(const char *text)
Draws the specified text string to the debug "text1" surface.
DeviceModesInfo * m_currentDevInfo
Device info array for storing supported display modes. [AI].
Definition: mxdirectdraw.h:313
int FlipToGDISurface()
Flips to the Windows GDI surface, restoring the desktop when leaving exclusive fullscreen.
BOOL DDCreateSurfaces()
Internal: Creates all necessary front/back/offscreen surfaces for rendering.
BOOL m_bOnlySystemMemory
TRUE for system RAM-only surfaces; disables video memory allocation. [AI].
Definition: mxdirectdraw.h:306
ErrorHandler m_pFatalErrorHandler
Callback invoked for fatal device errors. [AI].
Definition: mxdirectdraw.h:309
IDirectDrawSurface * m_pText1Surface
Debug overlay surface for "text1". [AI].
Definition: mxdirectdraw.h:292
virtual void Destroy()
Shuts down DirectDraw and releases all resources, including device and surfaces.
IDirectDrawSurface * m_pFrontBuffer
Primary or front display surface. [AI].
Definition: mxdirectdraw.h:289
SIZE m_text1SizeOnSurface
Pixel size of rendered text1 overlay surface. [AI].
Definition: mxdirectdraw.h:298
void * m_pErrorHandlerArg
Custom argument pointer for error handler. [AI].
Definition: mxdirectdraw.h:310
void * m_pFatalErrorHandlerArg
Custom argument pointer for fatal error handler. [AI].
Definition: mxdirectdraw.h:311
void * m_unk0x850
[AI] Purpose unknown; possibly driver-specific data or reserved.
Definition: mxdirectdraw.h:305
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.
BOOL TextToTextSurface2(const char *lpString)
Draws the specified string to the debug "text2" surface.
IDirectDraw * m_pDirectDraw
Pointer to the DirectDraw COM device. [AI].
Definition: mxdirectdraw.h:288
MxDirectDraw()
Constructs a MxDirectDraw instance and initializes its members.
void(* ErrorHandler)(const char *, HRESULT, void *)
Function pointer type for error handling callbacks.
Definition: mxdirectdraw.h:25
HWND m_hWndMain
Main window handle on which DirectDraw is initialized. [AI].
Definition: mxdirectdraw.h:300
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 RestorePaletteEntries()
Restores the active DirectDraw palette entries from the internal palette array.
IDirectDrawPalette * m_pPalette
DirectDraw palette assigned to the primary/back surfaces. [AI].
Definition: mxdirectdraw.h:295
BOOL DDSetMode(int width, int height, int bpp)
Changes DirectDraw to the specified display mode and creates relevant surfaces.
int Pause(BOOL)
Pauses or resumes DirectDraw rendering.
BOOL GetDDSurfaceDesc(LPDDSURFACEDESC lpDDSurfDesc, LPDIRECTDRAWSURFACE lpDDSurf)
Retrieves the surface description for the given DirectDraw surface.
int m_pauseCount
Count of nested pauses; ensures multiple Pause(TRUE)/Pause(FALSE) work correctly. [AI].
Definition: mxdirectdraw.h:312
BOOL m_bFlipSurfaces
TRUE if using DirectDraw flipping (fullscreen buffer swap); windowed disables this....
Definition: mxdirectdraw.h:287
BOOL IsFullScreen()
Returns TRUE if DirectDraw is currently set in exclusive fullscreen mode.
Definition: mxdirectdraw.h:111
BOOL m_bFullScreen
TRUE if device is in exclusive fullscreen mode. [AI].
Definition: mxdirectdraw.h:304
DeviceModesInfo::Mode * CurrentMode()
Provides access to the current selected display mode (width, height, bpp).
Definition: mxdirectdraw.h:106
virtual ~MxDirectDraw()
Virtual destructor.
IDirectDrawSurface * FrontBuffer()
Returns the surface used as the primary/front buffer.
Definition: mxdirectdraw.h:88
BOOL RestoreOriginalPaletteEntries()
Restores the original Windows palette from backup.
IDirectDrawClipper * Clipper()
Returns the current DirectDraw clipper object used for window clipping.
Definition: mxdirectdraw.h:100
void FUN_1009e020()
Internal: Clears the backbuffer(s), locking and filling with zero color, possibly flipping to front.
BOOL RecreateDirectDraw(GUID **a2)
Recreates the DirectDraw device, deleting and restoring the device object pointer.
BOOL RestoreSurfaces()
Attempts to restore all DirectDraw surfaces that may have been lost.
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.
BOOL m_bIsOnPrimaryDevice
TRUE if rendering on Windows' main display; disables windowed mode for other devices....
Definition: mxdirectdraw.h:307
BOOL CreateTextSurfaces()
Creates the two offscreen text surfaces used for debug overlay.
#define IUnknown
Definition: ddraw.h:28
struct _DDSURFACEDESC FAR * LPDDSURFACEDESC
Definition: ddraw.h:83
struct IDirectDrawSurface FAR * LPDIRECTDRAWSURFACE
Definition: ddraw.h:74
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
HWND hWnd
Definition: ddraw.h:425
long HRESULT
Definition: ddraw.h:115
typedef BOOL(FAR PASCAL *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA
[AI] Represents a specific display mode supported by the device (width, height, bits per pixel).
Definition: mxdirectxinfo.h:22
[AI] Contains detailed information about a Direct3D device's supported display modes and capabilities...
Definition: mxdirectxinfo.h:16