1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
5 #include "DirectXGlobals.h"
7 // static char *VB_Name = "DirectXGlobals";
18 // Public DInput As DirectInput
19 // Public DKeyboard As DirectInputDevice
20 DirectDrawSurface7 PrimarySurface;
26 void InitDirectX(long hWndForm, long hWndClip)
28 // DirectX = New DirectX7; // (handle this later, if needed)
29 // DirectXS = New DirectX7; // (handle this later, if needed)
33 // --- On Error Resume Next
34 DSound = DirectXS.DirectSoundCreate("");
37 ReportError("InitDirectX()", "Unable to start DirectSound.");
41 DSound.SetCooperativeLevel(hWndForm, DSSCL_PRIORITY);
46 DDraw = DirectX.DirectDrawCreate("");
47 DDraw.SetCooperativeLevel(0, DDSCL_NORMAL);
48 RestorePrimarySurface();
50 ClipToWindow(hWndClip);
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
60 void RestorePrimarySurface()
64 // Create PrimarySurface:
66 SD.lFlags = DDSD_CAPS;
67 SD.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE;
70 // --- On Error Resume Next
71 SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
72 PrimarySurface = DDraw.CreateSurface(SD);
75 void ReleaseDirectDraw()
77 SET_TO_NOTHING(&PrimarySurface, sizeof(PrimarySurface));
78 SET_TO_NOTHING(&DDraw, sizeof(DDraw));
79 SET_TO_NOTHING(&DirectX, sizeof(DirectX));
82 void ClipToWindow(long hWnd)
84 DirectDrawClipper Clipper;
91 Clipper = DDraw.CreateClipper(0);
92 Clipper.SetHWnd(shWnd);
93 PrimarySurface.SetClipper(Clipper);
94 SET_TO_NOTHING(&Clipper, sizeof(Clipper));
97 // Public Sub DimPrimary(Brightness&)
98 // Dim Pal As DirectDrawPalette
99 // Set Pal = PrimarySurface.GetPalette()