1/****************************************************************************
2*
3*						MegaGraph Graphics Library
4*
5*                   Copyright (C) 1996 SciTech Software.
6*							All rights reserved.
7*
8* Filename:		$Workfile:   mglwin.h  $
9* Version:		$Revision:   1.14  $
10*
11* Language:		ANSI C
12* Environment:	IBM PC (MS DOS)
13*
14* Description:	Header file for the MGLWIN bindings for MS Windows using
15*				WinG in a window and WinDirect for full screen. The MGLWIN
16*				binding only targets Win32 applications, so cannot be used
17*				for 16 bit Windows development.
18*
19* $Date:   14 Mar 1997 16:09:34  $ $Author:   KendallB  $
20*
21****************************************************************************/
22
23#ifndef	__MGLWIN_H
24#define	__MGLWIN_H
25
26#ifndef MGLWIN
27#define	MGLWIN
28#endif
29
30/*---------------------- Macros and type definitions ----------------------*/
31
32typedef HWND		MGL_HWND;
33typedef	HDC			MGL_HDC;
34typedef	HINSTANCE	MGL_HINSTANCE;
35
36/*------------------------- Function Prototypes ---------------------------*/
37
38#ifdef	__cplusplus
39extern "C" {			/* Use "C" linkage when in C++ mode	*/
40#endif
41
42/* Initialise the MGL for fullscreen output */
43
44bool	MGLAPI MGL_init(m_int *driver,m_int *mode,const char *mglpath);
45
46/* Initialise the MGL just for Windowed output, not full screen */
47
48bool	MGLAPI MGL_initWindowed(const char *mglpath);
49
50/* Function to register a fullscreen window with the MGL. If you wish
51 * for the MGL to use your own window for fullscreen modes, you can
52 * register it with this function. Note that when the MGL goes into
53 * fullscreen modes, the attributes, size and position of the window are
54 * modified to make it into a fullscreen Window necessary to cover the
55 * entire desktop, and the state of the window will be restore to the original
56 * format on return to normal GDI mode.
57 *
58 * Note that if you are using a common window for Windowed mode and fullscreen
59 * modes of your application, you will need to ensure that certain messages
60 * that you window normally handles in windowed modes are ignored when in
61 * fullscreen modes.
62 */
63
64void 	MGLAPI MGL_registerFullScreenWindow(HWND hwndFullScreen);
65
66/* Function to register a fullscreen event handling window procedure.
67 * If you wish to do your own event handling, you can register your window
68 * procedure with the MGL using this function and it will be called
69 * when there are messages to be handled. You can still call the MGL_event()
70 * functions even if you have registered an event handling procedure.
71 */
72
73void 	MGLAPI MGL_registerEventProc(WNDPROC userWndProc);
74
75/* Change the active display mode. You must destroy all display device
76 * contexts before calling this function, and re-create them again with
77 * the new display mode. Does not affect any event handling hooks.
78 */
79
80bool	MGLAPI MGL_changeDisplayMode(m_int mode);
81
82/* Obtain the handle to the MGL fullscreen window when in fullscreen modes */
83
84MGL_HWND MGLAPI MGL_getFullScreenWindow(void);
85
86/* Tell the MGL what your applications main window is */
87
88void	MGLAPI MGL_setMainWindow(MGL_HWND hwnd);
89
90/* Tell the MGL your applications instance handle (call before all funcs!) */
91
92void	MGLAPI MGL_setAppInstance(MGL_HINSTANCE hInstApp);
93
94/* Device context management */
95
96MGLDC	* MGLAPI MGL_createDisplayDC(m_int numBuffers);
97MGLDC	* MGLAPI MGL_createSrollingDC(m_int virtualX,m_int virtualY,m_int numBuffers);
98MGLDC	* MGLAPI MGL_createOffscreenDC(void);
99MGLDC	* MGLAPI MGL_createLinearOffscreenDC(void);
100MGLDC	* MGLAPI MGL_createWindowedDC(MGL_HWND hwnd);
101MGLDC 	* MGLAPI MGL_createMemoryDC(m_int xSize,m_int ySize,m_int bitsPerPixel,pixel_format_t *pf);
102bool	MGLAPI MGL_destroyDC(MGLDC *dc);
103
104/* Get a Windows HDC for the MGL device context. You can use this returned
105 * HDC to get GDI to draw to the device context surface, such as rendering
106 * and using TrueType fonts with the MGL. If a Windows compatible HDC is not
107 * available, this function will return NULL.
108 */
109
110HDC		MGLAPI MGL_getWinDC(MGLDC *dc);
111
112/* Associate a Window manager DC with the MGLDC for painting */
113
114bool	MGLAPI MGL_setWinDC(MGLDC *dc,MGL_HDC hdc);
115
116/* Activate the WindowDC's palette */
117
118bool	MGLAPI MGL_activatePalette(MGLDC *dc,bool unrealize);
119
120/* Let the MGL know when your application is being activated or deactivated.
121 * This function only needs to be called when running in Windowed modes and
122 * you have set the system palette to SYSPAL_NOSTATIC mode, to ensure
123 * that the MGL can properly re-map your application palette when your
124 * app is not active and allow Windows to re-map your bitmap colors on the
125 * fly. This function should be passed a pointer to the currently active
126 * MGL Windowed DC and a flag to indicate whether the app is in the background
127 * or not.
128 */
129
130void	MGLAPI MGL_appActivate(MGLDC *winDC,bool active);
131
132/* Generic helper functions */
133
134ulong	MGLAPI MGL_getTicks(void);
135ulong	MGLAPI MGL_getTickResolution(void);
136void	MGLAPI MGL_delay(m_int millseconds);
137void	MGLAPI MGL_beep(m_int freq,m_int milliseconds);
138
139/* Fullscreen specific routines */
140
141void	MGLAPI MGL_setPaletteSnowLevel(MGLDC *dc,m_int level);
142m_int	MGLAPI MGL_getPaletteSnowLevel(MGLDC *dc);
143
144/* Determine if a specific scancode'ed key is held down (PC specific) */
145
146bool	MGLAPI EVT_isKeyDown(uchar scanCode);
147
148#ifdef	__cplusplus
149}						/* End of "C" linkage for C++	*/
150#endif
151
152#endif	/* __MGLWIN_H */
153