A Fast Bresenham Type Algorithm For Drawing Ellipses by John Kennedy
[xy_vsfilter.git] / src / filters / BaseClasses / ddmm.cpp
blob77a6a41161dde36ab90ab9777056c11caf47e21c
1 //------------------------------------------------------------------------------
2 // File: DDMM.cpp
3 //
4 // Desc: DirectShow base classes - implements routines for using DirectDraw
5 // on a multimonitor system.
6 //
7 // Copyright (c) 1995-2002 Microsoft Corporation. All rights reserved.
8 //------------------------------------------------------------------------------
11 #include <streams.h>
12 #include <ddraw.h>
13 #include "ddmm.h"
16 * FindDeviceCallback
18 typedef struct {
19 LPSTR szDevice;
20 GUID* lpGUID;
21 GUID GUID;
22 BOOL fFound;
23 } FindDeviceData;
25 BOOL CALLBACK FindDeviceCallback(GUID* lpGUID, LPSTR szName, LPSTR szDevice, LPVOID lParam)
27 FindDeviceData *p = (FindDeviceData*)lParam;
29 if (lstrcmpiA(p->szDevice, szDevice) == 0) {
30 if (lpGUID) {
31 p->GUID = *lpGUID;
32 p->lpGUID = &p->GUID;
33 } else {
34 p->lpGUID = NULL;
36 p->fFound = TRUE;
37 return FALSE;
39 return TRUE;
43 BOOL CALLBACK FindDeviceCallbackEx(GUID* lpGUID, LPSTR szName, LPSTR szDevice, LPVOID lParam, HMONITOR hMonitor)
45 FindDeviceData *p = (FindDeviceData*)lParam;
47 if (lstrcmpiA(p->szDevice, szDevice) == 0) {
48 if (lpGUID) {
49 p->GUID = *lpGUID;
50 p->lpGUID = &p->GUID;
51 } else {
52 p->lpGUID = NULL;
54 p->fFound = TRUE;
55 return FALSE;
57 return TRUE;
62 * DirectDrawCreateFromDevice
64 * create a DirectDraw object for a particular device
66 IDirectDraw * DirectDrawCreateFromDevice(LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP)
68 IDirectDraw* pdd = NULL;
69 FindDeviceData find;
71 if (szDevice == NULL) {
72 DirectDrawCreateP(NULL, &pdd, NULL);
73 return pdd;
76 find.szDevice = szDevice;
77 find.fFound = FALSE;
78 DirectDrawEnumerateP(FindDeviceCallback, (LPVOID)&find);
80 if (find.fFound)
83 // In 4bpp mode the following DDraw call causes a message box to be popped
84 // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
85 // make sure it doesn't happen.
87 UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
88 DirectDrawCreateP(find.lpGUID, &pdd, NULL);
89 SetErrorMode(ErrorMode);
92 return pdd;
97 * DirectDrawCreateFromDeviceEx
99 * create a DirectDraw object for a particular device
101 IDirectDraw * DirectDrawCreateFromDeviceEx(LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)
103 IDirectDraw* pdd = NULL;
104 FindDeviceData find;
106 if (szDevice == NULL) {
107 DirectDrawCreateP(NULL, &pdd, NULL);
108 return pdd;
111 find.szDevice = szDevice;
112 find.fFound = FALSE;
113 DirectDrawEnumerateExP(FindDeviceCallbackEx, (LPVOID)&find,
114 DDENUM_ATTACHEDSECONDARYDEVICES);
116 if (find.fFound)
119 // In 4bpp mode the following DDraw call causes a message box to be popped
120 // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
121 // make sure it doesn't happen.
123 UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
124 DirectDrawCreateP(find.lpGUID, &pdd, NULL);
125 SetErrorMode(ErrorMode);
128 return pdd;