1 /* -*- c++ -*-
2 FILE: WrapD3D.h
3 RCS REVISION: $Revision: 1.8 $
4 
5 COPYRIGHT: (c) 1999 -- 2003 Melinda Green, Don Hatch, and Jay Berkenbilt - Superliminal Software
6 
7 LICENSE: Free to use and modify for non-commercial purposes as long as the
8     following conditions are adhered to:
9     1) Obvious credit for the source of this code and the designs it embodies
10        are clearly made, and
11     2) Ports and derived versions of 4D Magic Cube programs are not distributed
12        without the express written permission of the authors.
13 
14 DESCRIPTION:
15     Abstraction on top of DirectX
16 */
17 
18 #ifndef WrapD3D_h
19 #define WrapD3D_h
20 
21 #include "WrapDD.h"
22 #include <d3d.h>
23 
24 
25 class       WrapD3D:public WrapDD
26 {
27 
28     struct Direct3DDeviceInfo
29     {
30         char        Desc[50];
31         char        Name[30];
32         D3DDEVICEDESC HWDesc;
33         D3DDEVICEDESC HELDesc;
34         GUID        Guid;
35 
InitializeDirect3DDeviceInfo36         void        Initialize(const GUID * pGuid,
37                                const char *pDeviceDescription,
38                                const char *pDeviceName,
39                                const LPD3DDEVICEDESC pHWDesc,
40                                const LPD3DDEVICEDESC pHELDesc)
41             {
42                 memcpy(&Guid, pGuid, sizeof(GUID));
43                 strcpy(Desc, pDeviceDescription);
44                 strcpy(Name, pDeviceName);
45                 memcpy(&HWDesc, pHWDesc, sizeof(HWDesc));
46                 memcpy(&HELDesc, pHELDesc, sizeof(HELDesc));
47             }
48     };
49 
50     enum
51     { maxDeviceInfoCount = 5 };
52 
53   public:
54     WrapD3D();
55     ~WrapD3D();
56 
57     BOOL        Create(HWND,
58                        BOOL fullScreen,
59                        int width, int height, int bpp,
60                        const PALETTEENTRY * pPaletteEntries,
61                        int pPaletteEntryCount,
62                        bool software_render_only = false);
63     void        Destroy();
64     void        DestroyButNotDirectDraw();
65 
66     const char *ErrorToString(HRESULT);
67 
Direct3D()68     IDirect3D  *Direct3D()
69         {
70             return m_pDirect3D;
71         }
Direct3DDevice()72     IDirect3DDevice *Direct3DDevice()
73         {
74             return m_pDirect3DDevice;
75         }
76 
77   protected:
78     BOOL D3DCreate();
79     BOOL        D3DInit();
80     BOOL        D3DSetMode();
81 
82     int         ZBufferDepth(Direct3DDeviceInfo *);
83 
84     BOOL        FilterDisplayModes(LPDDSURFACEDESC);
85 
86     HRESULT     EnumDevicesCallback(GUID *, char *, char *,
87                                     LPD3DDEVICEDESC, LPD3DDEVICEDESC);
88 
89     static HRESULT CALLBACK EnumDevicesCallback(GUID *, char *, char *,
90                                                 LPD3DDEVICEDESC,
91                                                 LPD3DDEVICEDESC, void *);
92 
93   private:
94     Direct3DDeviceInfo m_deviceInfo[maxDeviceInfoCount];
95     Direct3DDeviceInfo *m_pCurrentDeviceInfo;
96     int         m_deviceInfoCount;
97 
98     IDirect3D  *m_pDirect3D;
99     IDirect3DDevice *m_pDirect3DDevice;
100 
101     BOOL        m_bTexturesDisabled;
102 };
103 
104 #endif /* WrapD3D_h */
105 
106 // Local Variables:
107 // c-basic-offset: 4
108 // c-comment-only-line-offset: 0
109 // c-file-offsets: ((defun-block-intro . +) (block-open . 0) (substatement-open . 0) (statement-cont . +) (statement-case-open . +4) (arglist-intro . +) (arglist-close . +) (inline-open . 0))
110 // indent-tabs-mode: nil
111 // End:
112