1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
5 #include "DirectXGlobals.h"
7 // static char *VB_Name = "DirectXGlobals";
16 // Public DInput As DirectInput
17 // Public DKeyboard As DirectInputDevice
18 DirectDrawSurface7 PrimarySurface;
20 void InitDirectX(long hWndForm, long hWndClip)
22 // DirectX = New DirectX7; // (handle this later, if needed)
23 // DirectXS = New DirectX7; // (handle this later, if needed)
27 // --- On Error Resume Next
28 DSound = DirectXS.DirectSoundCreate("");
31 ReportError("InitDirectX()", "Unable to start DirectSound.");
35 DSound.SetCooperativeLevel(hWndForm, DSSCL_PRIORITY);
40 DDraw = DirectX.DirectDrawCreate("");
41 DDraw.SetCooperativeLevel(0, DDSCL_NORMAL);
42 RestorePrimarySurface();
44 ClipToWindow(hWndClip);
47 // Set DInput = DirectX.DirectInputCreate()
48 // Set DKeyboard = DInput.CreateDevice("GUID_SysKeyboard")
49 // Call DKeyboard.SetCommonDataFormat(DIFORMAT_KEYBOARD)
50 // Call DKeyboard.SetCooperativeLevel(hWndForm, DISCL_NONEXCLUSIVE Or DISCL_BACKGROUND)
51 // Call DKeyboard.Acquire
54 void RestorePrimarySurface()
58 // Create PrimarySurface:
60 SD.lFlags = DDSD_CAPS;
61 SD.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE;
64 // --- On Error Resume Next
65 SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
66 PrimarySurface = DDraw.CreateSurface(SD);
69 void ReleaseDirectDraw()
71 SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
72 SET_TO_NOTHING(&DDraw, sizeof(DDraw));
73 SET_TO_NOTHING(&DirectX, sizeof(DirectX));
76 void ClipToWindow(long hWnd)
78 DirectDrawClipper Clipper;
85 Clipper = DDraw.CreateClipper(0);
86 Clipper.SetHWnd(shWnd);
87 PrimarySurface.SetClipper(Clipper);
88 SET_TO_NOTHING(&Clipper, sizeof(Clipper));
91 // Public Sub DimPrimary(Brightness&)
92 // Dim Pal As DirectDrawPalette
93 // Set Pal = PrimarySurface.GetPalette()