378903d2b7b0688f9d52f7919dca6baba7a82f26
[rocksndiamonds.git] / src / game_sp / DirectXGlobals.c
1 // ----------------------------------------------------------------------------
2 // DirectXGlobals.c
3 // ----------------------------------------------------------------------------
4
5 #include "DirectXGlobals.h"
6
7 // static char *VB_Name = "DirectXGlobals";
8
9 // --- Option Explicit
10
11 #if 0
12
13 DirectX7 DirectX;
14 DirectX7 DirectXS;
15 DirectDraw7 DDraw;
16 DirectSound DSound;
17
18 // Public DInput As DirectInput
19 // Public DKeyboard As DirectInputDevice
20 DirectDrawSurface7 PrimarySurface;
21
22 #endif
23
24 #if 0
25
26 void InitDirectX(long hWndForm, long hWndClip)
27 {
28   // DirectX = New DirectX7; // (handle this later, if needed)
29   // DirectXS = New DirectX7; // (handle this later, if needed)
30
31   // DirectSound:
32
33   // --- On Error Resume Next
34   DSound = DirectXS.DirectSoundCreate("");
35   if (Err.Number != 0)
36   {
37     ReportError("InitDirectX()", "Unable to start DirectSound.");
38   }
39   else
40   {
41     DSound.SetCooperativeLevel(hWndForm, DSSCL_PRIORITY);
42     LoadSoundFX();
43   }
44
45   // DirectDraw:
46   DDraw = DirectX.DirectDrawCreate("");
47   DDraw.SetCooperativeLevel(0, DDSCL_NORMAL);
48   RestorePrimarySurface();
49   if (hWndClip != 0)
50     ClipToWindow(hWndClip);
51
52   // 'DirectInput:
53   //  Set DInput = DirectX.DirectInputCreate()
54   //  Set DKeyboard = DInput.CreateDevice("GUID_SysKeyboard")
55   //  Call DKeyboard.SetCommonDataFormat(DIFORMAT_KEYBOARD)
56   //  Call DKeyboard.SetCooperativeLevel(hWndForm, DISCL_NONEXCLUSIVE Or DISCL_BACKGROUND)
57   //  Call DKeyboard.Acquire
58 }
59
60 void RestorePrimarySurface()
61 {
62   DDSURFACEDESC2 SD;
63
64   // Create PrimarySurface:
65   {
66     SD.lFlags = DDSD_CAPS;
67     SD.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE;
68   }
69
70   // --- On Error Resume Next
71   SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
72   PrimarySurface = DDraw.CreateSurface(SD);
73 }
74
75 void ReleaseDirectDraw()
76 {
77   SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
78   SET_TO_NOTHING(&DDraw, sizeof(DDraw));
79   SET_TO_NOTHING(&DirectX, sizeof(DirectX));
80 }
81
82 void ClipToWindow(long hWnd)
83 {
84   DirectDrawClipper Clipper;
85   long shWnd;
86
87   if (hWnd != 0)
88     shWnd = hWnd;
89
90   // create clipper
91   Clipper = DDraw.CreateClipper(0);
92   Clipper.SetHWnd(shWnd);
93   PrimarySurface.SetClipper(Clipper);
94   SET_TO_NOTHING(&Clipper, sizeof(Clipper));
95 }
96
97 // Public Sub DimPrimary(Brightness&)
98 // Dim Pal As DirectDrawPalette
99 //  Set Pal = PrimarySurface.GetPalette()
100 // End Sub
101
102 #endif