1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/compapis/RCS/gshelapi.h $
4 // $Date: 1997/09/10 13:57:12 $
7 // Interfaces for use with the Looking Glass Generic Game Shell. Game shell
8 // is responsible for platform dependent synchronization.
14 #if defined(__SC__) || defined(__RCC__)
18 ///////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////////////
29 // Forward Declarations
31 typedef struct grs_bitmap grs_bitmap
;
32 typedef grs_bitmap sGrBitmap
;
33 typedef struct Point Point
;
35 F_DECLARE_INTERFACE(IGameShell
);
36 F_DECLARE_INTERFACE(IGameShellAdviseSink
);
38 ///////////////////////////////////////////////////////////////////////////////
44 // Create a game shell and add it to the global app-object
46 #define GameShellCreate(flags) \
48 IUnknown * pAppUnknown = AppGetObj(IUnknown); \
49 _GameShellCreate(IID_TO_REFIID(IID_IGameShell), NULL, pAppUnknown, flags, 0); \
50 COMRelease(pAppUnknown); \
53 #define GameShellCreate2(flags, msecBlockSignal) \
55 IUnknown * pAppUnknown = AppGetObj(IUnknown); \
56 _GameShellCreate(IID_TO_REFIID(IID_IGameShell), NULL, pAppUnknown, flags, msecBlockSignal); \
57 COMRelease(pAppUnknown); \
60 // Creates a game shell, aggregating it with specfied pOuter,
61 // use IAggregate protocol if ppGameShell is NULL
63 EXTERN tResult LGAPI
_GameShellCreate(REFIID
, IGameShell
** ppGameShell
, IUnknown
* pOuter
, int fFlags
, int msecBlockSignal
);
65 ///////////////////////////////////////
67 enum eGameShellCreateFlags
70 // Automatically lock display device within Begin/EndFrame() pair
75 // Automatically flip display device on EndFrame(), if flippable
77 kFlipOnEndFrame
= 0x02,
80 // Call exit() if OS-specific quit event is detected
82 kExitOnQuitEvent
= 0x04,
85 // Automatically capture mouse while button is down
87 kCaptureMouseWhileDown
= 0x08,
92 kShowNativeCursor
= 0x10,
95 // Attempt to run the game shell in multi-threaded mode
97 kMultithreadedShell
= 0x20,
100 // Automatically flush display device on EndFrame()
102 kFlushOnEndFrame
= 0x40,
107 kGameShellDefault
= (kLockFrame
+ kFlipOnEndFrame
+ kExitOnQuitEvent
+ kCaptureMouseWhileDown
+ kFlushOnEndFrame
)
110 ///////////////////////////////////////////////////////////////////////////////
112 typedef enum eGSCursorEvent
118 typedef void (LGAPI
* tGSCursorCallbackFunc
)(eGSCursorEvent
);
120 ///////////////////////////////////////////////////////////////////////////////
122 // INTERFACE: IGameShell
127 #define INTERFACE IGameShell
129 DECLARE_INTERFACE_(IGameShell
, IUnknown
)
134 DECLARE_UNKNOWN_PURE();
137 // Pump-input and lock display surfaces (if specified when created)
139 STDMETHOD_(void, BeginFrame
)(THIS
) PURE
;
142 // Release locks, ensure screen is up-to-date
144 STDMETHOD_(void, EndFrame
)(THIS
) PURE
;
147 // Make sure the game is the user focus
149 STDMETHOD (BringToFront
)(THIS
) PURE
;
153 // @TBD (toml 08-03-97): next time a non-backtouch game shell change goes in, remove this
155 STDMETHOD (Obsolete1
)(THIS
) PURE
;
158 // Process pending events (on event-driven OSs)
160 // This is done automatically in BeginFrame()
162 // This will break all locks, if there are any, then re-lock. Messages
163 // will be passed into the event aggregation event handler, if any.
165 // Sprinkle this around if things seem choppy, but not too many places,
166 // as it can be relatively expensive
168 STDMETHOD_(void, PumpEvents
)(THIS_
int fPumpFlags
/* = kPumpAll */) PURE
;
170 ///////////////////////////////////
172 // Convenience functions that provide a facade for common operations on
173 // other components without forcing game shell clients to include headers
174 // with a lot of irrelevant dependencies
178 // Try to lock video memory. Locked pointers will be placed in
179 // structure provided in SetMode(). Returns lock count.
181 STDMETHOD_(int, DisplayLock
)(THIS
) PURE
;
184 // Release a lock on memory
186 STDMETHOD_(int, DisplayUnlock
)(THIS
) PURE
;
189 // Verify display reflects what is expected. Useful if not particularly
190 // frame based & want to ensure screen is up-to-date within/without a
191 // BeginFrame()/EndFrame() pair. Meaningful in "artificial" modes, no-op
194 STDMETHOD_(void, DisplayFlush
)(THIS
) PURE
;
197 // Get the present tick count, in msec since initialization or timer restart
199 STDMETHOD_(unsigned long, GetTimerTick
)(THIS
) PURE
;
202 // Reset the timer (by default, starts at zero from initialization)
204 STDMETHOD_(void , SetTimer
)(THIS_
unsigned long) PURE
;
209 STDMETHOD_(BOOL
, ShowHelp
)(THIS_
const char * pszHelpFile
, uint command
, ulong dwData
) PURE
;
212 // Show/Hide the OS cursor.
214 STDMETHOD_(BOOL
, SetOSCursor
)(THIS_ sGrBitmap
* pCursorBitmap
, const Point
* pHotSpot
) PURE
;
215 STDMETHOD_(BOOL
, ShowOSCursor
)(THIS_ BOOL
) PURE
;
216 STDMETHOD_(void, SetCursorCallback
)(THIS_ tGSCursorCallbackFunc
) PURE
;
219 // Execute a command line
221 STDMETHOD_(BOOL
, Exec
)(THIS_
const char * pszCommandLine
) PURE
;
224 // Set flags. Some flags may be unaffected (e.g., multithreaded)
226 STDMETHOD_(BOOL
, SetFlags
)(THIS_
int fFlags
) PURE
;
231 STDMETHOD_(BOOL
, GetFlags
)(THIS_
int * pfFlags
) PURE
;
234 #define IGameShell_QueryInterface(p, a, b) COMQueryInterface(p, a, b)
235 #define IGameShell_AddRef(p) COMAddRef(p)
236 #define IGameShell_Release(p) COMRelease(p)
237 #define IGameShell_BeginFrame(p) COMCall0(p, BeginFrame)
238 #define IGameShell_EndFrame(p) COMCall0(p, EndFrame)
239 #define IGameShell_PumpEvents(p, a) COMCall1(p, PumpEvents, a)
240 #define IGameShell_DisplayLock(p) COMCall0(p, DisplayLock)
241 #define IGameShell_DisplayUnlock(p) COMCall0(p, DisplayUnlock)
242 #define IGameShell_DisplayFlush(p) COMCall0(p, DisplayFlush)
243 #define IGameShell_SetTimer(p, a) COMCall1(p, SetTimer, a)
244 #define IGameShell_GetTimerTick(p) COMCall0(p, GetTimerTick)
245 #define IGameShell_ShowHelp(p, a, b, c) COMCall3(p, ShowHelp, a, b, c)
246 #define IGameShell_SetOSCursor(p, a, b) COMCall2(p, SetOSCursor, a, b)
247 #define IGameShell_ShowOSCursor(p, a) COMCall1(p, ShowOSCursor, a)
248 #define IGameShell_SetCursorCallback(p, a) COMCall1(p, SetCursorCallback, a)
249 #define IGameShell_Exec(p, a) COMCall1(p, Exec, a)
250 #define IGameShell_SetFlags(p, a) COMCall1(p, SetFlags, a)
251 #define IGameShell_GetFlags(p, a) COMCall1(p, GetFlags, a)
253 ///////////////////////////////////////////////////////////////////////////////
255 #endif /* !__GSHELAPI_H */