1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
5 #include "DirectXGlobals.h"
7 static char *VB_Name = "DirectXGlobals";
15 // Public DInput As DirectInput
16 // Public DKeyboard As DirectInputDevice
17 DirectDrawSurface7 PrimarySurface;
19 void InitDirectX(long hWndForm, long hWndClip)
21 // DirectX = New DirectX7; // (handle this later, if needed)
22 // DirectXS = New DirectX7; // (handle this later, if needed)
26 // --- On Error Resume Next
27 DSound = DirectXS.DirectSoundCreate("");
30 ReportError("InitDirectX()", "Unable to start DirectSound.");
34 DSound.SetCooperativeLevel(hWndForm, DSSCL_PRIORITY);
39 DDraw = DirectX.DirectDrawCreate("");
40 DDraw.SetCooperativeLevel(0, DDSCL_NORMAL);
41 RestorePrimarySurface();
43 ClipToWindow(hWndClip);
46 // Set DInput = DirectX.DirectInputCreate()
47 // Set DKeyboard = DInput.CreateDevice("GUID_SysKeyboard")
48 // Call DKeyboard.SetCommonDataFormat(DIFORMAT_KEYBOARD)
49 // Call DKeyboard.SetCooperativeLevel(hWndForm, DISCL_NONEXCLUSIVE Or DISCL_BACKGROUND)
50 // Call DKeyboard.Acquire
53 void RestorePrimarySurface()
57 // Create PrimarySurface:
59 SD.lFlags = DDSD_CAPS;
60 SD.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE;
63 // --- On Error Resume Next
64 SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
65 PrimarySurface = DDraw.CreateSurface(SD);
68 void ReleaseDirectDraw()
70 SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
71 SET_TO_NOTHING(&DDraw, sizeof(DDraw));
72 SET_TO_NOTHING(&DirectX, sizeof(DirectX));
75 void ClipToWindow(long hWnd)
77 DirectDrawClipper Clipper;
84 Clipper = DDraw.CreateClipper(0);
85 Clipper.SetHWnd(shWnd);
86 PrimarySurface.SetClipper(Clipper);
87 SET_TO_NOTHING(&Clipper, sizeof(Clipper));
90 // Public Sub DimPrimary(Brightness&)
91 // Dim Pal As DirectDrawPalette
92 // Set Pal = PrimarySurface.GetPalette()