vid: remove mgl and make import mh's GDI code

Re-write vid_win based on mh's version with all the mgl dependencies
removed and purely using GDI. Seems to work really well - hopefully I
didn't miss anything too glaring...

  http://forums.inside3d.com/viewtopic.php?f=3&t=2182&sid=fa84752fa03ad142663a8223dd825be2#p23868

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-01-17 15:41:16 +10:30
parent f94f9cbc78
commit 440b9a360c
8 changed files with 313 additions and 3974 deletions

View File

@ -207,8 +207,6 @@ I386_GUESS := $(call cc-i386)
# Special include/lib dirs
# -------------------------
DX_INC = $(TOPDIR)/wine-dx
ST_INC = $(TOPDIR)/scitech/include
ST_LIBDIR = scitech/lib/win32/vc
# ---------------------------------------
# Define some build variables
@ -702,13 +700,10 @@ endif
endif
ifeq ($(VID_TARGET),win)
CL_CPPFLAGS += -idirafter $(DX_INC)
SW_CPPFLAGS += -idirafter $(ST_INC)
SW_OBJS += vid_win.o
GL_OBJS += vid_wgl.o
SW_LIBS += mgllt gdi32 # gdi32 needs to come after mgllt
GL_LIBS += gdi32
CL_LIBS += gdi32
GL_LIBS += comctl32
SW_LFLAGS += $(call libdir-check,$(ST_LIBDIR))
endif
ifeq ($(VID_TARGET),sdl)
SW_OBJS += vid_sdl.o sdl_common.o

View File

@ -95,9 +95,6 @@ Sys_FileTime(const char *path)
FILE *f;
int ret;
#ifndef SERVERONLY
int t = VID_ForceUnlockedAndReturnState();
#endif
f = fopen(path, "rb");
if (f) {
fclose(f);
@ -105,9 +102,6 @@ Sys_FileTime(const char *path)
} else {
ret = -1;
}
#ifndef SERVERONLY
VID_ForceLockState(t);
#endif
return ret;
}
@ -206,7 +200,6 @@ Sys_Error(const char *error, ...)
if (!in_sys_error3) {
in_sys_error3 = 1;
VID_ForceUnlockedAndReturnState();
}
va_start(argptr, error);
@ -311,7 +304,6 @@ void
Sys_Quit(void)
{
#ifndef SERVERONLY
VID_ForceUnlockedAndReturnState();
Host_Shutdown();
if (tevent)
CloseHandle(tevent);

File diff suppressed because it is too large Load Diff

View File

@ -1,292 +0,0 @@
/****************************************************************************
*
* Copyright (C) 1996 SciTech Software
* All rights reserved.
*
* Filename: $Workfile: debug.h $
* Version: $Revision: 1.17 $
*
* Language: ANSI C
* Environment: any
*
* Description: General header file for operating system portable code.
*
* $Date: 04 Mar 1997 11:34:08 $ $Author: KendallB $
*
****************************************************************************/
#ifndef __DEBUG_H
#define __DEBUG_H
/* We have the following defines to identify the compilation environment:
*
* __16BIT__ Compiling for 16 bit code (any environment)
* __32BIT__ Compiling for 32 bit code (any environment)
* __MSDOS__ Compiling for MS-DOS (includes __WINDOWS16__, __WIN386__)
* __REALDOS__ Compiling for MS-DOS (excludes __WINDOWS16__)
* __MSDOS16__ Compiling for 16 bit MS-DOS
* __MSDOS32__ Compiling for 32 bit MS-DOS
* __WINDOWS__ Compiling for Windows
* __WINDOWS16__ Compiling for 16 bit Windows (__MSDOS__ also defined)
* __WINDOWS32__ Compiling for 32 bit Windows
* __WIN386__ Compiling for Watcom C++ Win386 extended Windows
* __OS2__ Compiling for OS/2
* __OS2_16__ Compiling for 16 bit OS/2
* __OS2_32__ Compiling for 32 bit OS/2
* __UNIX__ Compiling for Unix
*
*/
#ifdef __SC__
#if __INTSIZE == 4
#define __SC386__
#endif
#endif
#ifdef __GNUC__
#define __cdecl /* GCC doesn't know about __cdecl modifiers */
#define __FLAT__ /* GCC is always 32 bit flat model */
#define __HAS_BOOL__ /* Latest GNU C++ has bool type */
#endif
#ifdef __BORLANDC__
#if (__BORLANDC__ >= 0x500) || defined(CLASSLIB_DEFS_H)
#define __HAS_BOOL__ /* Borland C++ 5.0 and later define bool type */
#endif
#endif
/* For the Metaware High C/C++ compiler, there is no _cdecl calling
* convention. The conventions can be changed, but it is a complicated
* process involving #pragmas, and all externally referenced functions
* will use stack based calling conventions. We also need to change the
* global aliasing conventions to use underscores for external function
* and variables names, so that our assembler routines will link
* correctly (except of course the main function - man what a PAIN!).
*/
#ifdef __HIGHC__
#define __cdecl
#define __FLAT__ /* High C is always 32 bit flat model */
#pragma Global_aliasing_convention("_%r")
extern main();
#pragma Alias(main,"main")
#endif
#if defined(__MSDOS__) || defined(__DOS__) || defined(__DPMI32__) || (defined(M_I86) && !defined(__SC386__))
#ifndef __MSDOS__
#define __MSDOS__
#endif
#if defined(__386__) || defined(__FLAT__) || defined(__NT__) || defined(__SC386__)
#ifndef __MSDOS32__
#define __MSDOS32__
#endif
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __REALDOS__
#define __REALDOS__
#endif
#elif (defined(_Windows) || defined(_WINDOWS)) && !defined(__DPMI16__)
#ifndef __16BIT__
#define __16BIT__
#endif
#ifndef __WINDOWS16__
#define __WINDOWS16__
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#ifndef __MSDOS__
#define __MSDOS__
#endif
#else
#ifndef __16BIT__
#define __16BIT__
#endif
#ifndef __MSDOS16__
#define __MSDOS16__
#endif
#ifndef __REALDOS__
#define __REALDOS__
#endif
#endif
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __WINDOWS32__
#define __WINDOWS32__
#endif
#ifndef _WIN32
#define _WIN32 /* Microsoft Win32 SDK headers use _WIN32 */
#endif
#ifndef WIN32
#define WIN32 /* OpenGL headers use WIN32 */
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#elif defined(__WINDOWS_386__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __WIN386__
#define __WIN386__
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#ifndef __MSDOS__
#define __MSDOS__
#endif
#elif defined(__OS2__)
#ifndef __OS2__ /* TODO: to be completed */
#define __OS2__
#define __OS2_32__ /* Default to 32 bit OS/2 */
#endif
#else
#define __UNIX__ /* TODO: to be completed */
#endif
/* We have the following defines to define the calling conventions for
* publicly accesible functions:
*
* _PUBAPI - Compiler default calling conventions for all public 'C' functions
* _ASMAPI - Calling conventions for all public assembler functions
* _DLLAPI - Calling conventions for all DLL exported functions
* _DLLVAR - Modifier to export/import globals in 32 bit DLL's
* _EXPORT - Expands to _export when compiling a DLL
* _VARAPI - Modifiers for variables; Watcom C++ mangles C++ globals
*/
#define _PUBAPI
#define _ASMAPI __cdecl
#if defined(_MSC_VER) && defined(_WIN32) && !defined(__SC__)
#define __PASCAL __stdcall
#define __export
#define __import
#else
#define __PASCAL __pascal
#endif
#if defined(__WATCOMC__)
#define _VARAPI __cdecl
#else
#define _VARAPI
#endif
#if defined(__WINDOWS__)
#ifdef BUILD_DLL
#define _DLLASM __export __cdecl
#define _EXPORT __export
#ifdef __WINDOWS32__
#define _DLLAPI __export __PASCAL
#define _DLLVAR __export
#else
#define _DLLAPI __export __far __pascal
#define _DLLVAR
#endif
#else
#define _DLLASM __cdecl
#define _EXPORT
#ifdef __WINDOWS32__
#define _DLLAPI __PASCAL
#define _DLLVAR __import
#else
#define _DLLAPI __far __pascal
#define _DLLVAR
#endif
#endif
#else
#define _EXPORT
#define _DLLAPI
#define _DLLVAR
#endif
/* Useful macros */
#define PRIVATE static
#define PUBLIC
#ifdef DEBUG
# define DBG(x) x
#else
# define DBG(x)
#endif
#ifndef NULL
# define NULL 0L
#endif
#ifndef MAX
# define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
# define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
#endif
#ifndef ABS
# define ABS(a) ((a) >= 0 ? (a) : -(a))
#endif
#ifndef SIGN
# define SIGN(a) ((a) > 0 ? 1 : -1)
#endif
/* General typedefs */
#ifndef __GENDEFS
#define __GENDEFS
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef int ibool; /* Integer boolean type */
#ifndef __cplusplus
#define bool ibool /* Standard C */
#else
#ifndef __HAS_BOOL__
#define bool ibool /* Older C++ compilers */
#endif
#endif /* __cplusplus */
#endif /* __GENDEFS */
/* Includes Windows headers, as they define TRUE and FALSE */
#ifdef __WINDOWS__
#ifndef _WINDOWS_ /* Dont include if already included */
#ifndef __WIN386__
#define STRICT
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#endif
/* Boolean truth values */
#undef false
#undef true
#undef NO
#undef YES
#undef FALSE
#undef TRUE
#ifdef __cplusplus /* Cast to bool's for C++ code */
#define false ((bool)0)
#define true ((bool)1)
#define NO ((bool)0)
#define YES ((bool)1)
#define FALSE ((bool)0)
#define TRUE ((bool)1)
#else /* Define to 0 and 1 for C code */
#define false 0
#define true 1
#define NO 0
#define YES 1
#define FALSE 0
#define TRUE 1
#endif
#endif /* __DEBUG_H */

View File

@ -1,84 +0,0 @@
/****************************************************************************
*
* MegaGraph Graphics Library
*
* Copyright (C) 1996 SciTech Software.
* All rights reserved.
*
* Filename: $Workfile: mgldos.h $
* Version: $Revision: 1.9 $
*
* Language: ANSI C
* Environment: IBM PC (MS DOS)
*
* Description: Header file for the MGLDOS binding for the MSDOS environment.
*
* $Date: 30 Jan 1997 17:31:58 $ $Author: KendallB $
*
****************************************************************************/
#ifndef __MGLDOS_H
#define __MGLDOS_H
#ifndef MGLDOS
#define MGLDOS
#endif
/*---------------------- Macros and type definitions ----------------------*/
typedef void *MGL_HWND;
/*------------------------- Function Prototypes ---------------------------*/
#ifdef __cplusplus
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
/* Initialise the MGL for fullscreen output */
bool MGLAPI MGL_init(m_int * driver, m_int * mode, const char *mglpath);
/* Change the active display mode. You must destroy all display device
* contexts before calling this function, and re-create them again with
* the new display mode. Does not affect any event handling hooks.
*/
bool MGLAPI MGL_changeDisplayMode(m_int mode);
/* Disable/enable event handling (call before calling MGL_init */
void MGLAPI MGL_useEvents(bool use);
/* Device context management */
MGLDC *MGLAPI MGL_createDisplayDC(m_int numBuffers);
MGLDC *MGLAPI MGL_createScrollingDC(m_int virtualX, m_int virtualY,
m_int numBuffers);
MGLDC *MGLAPI MGL_createOffscreenDC(void);
MGLDC *MGLAPI MGL_createLinearOffscreenDC(void);
MGLDC *MGLAPI MGL_createMemoryDC(m_int xSize, m_int ySize,
m_int bitsPerPixel, pixel_format_t *pf);
bool MGLAPI MGL_destroyDC(MGLDC *dc);
/* Generic helper functions */
ulong MGLAPI MGL_getTicks(void);
ulong MGLAPI MGL_getTickResolution(void);
void MGLAPI MGL_delay(m_int millseconds);
void MGLAPI MGL_beep(m_int freq, m_int milliseconds);
void MGLAPI MGL_suspend(void);
void MGLAPI MGL_resume(void);
/* Fullscreen specific routines */
void MGLAPI MGL_setPaletteSnowLevel(MGLDC *dc, m_int level);
m_int MGLAPI MGL_getPaletteSnowLevel(MGLDC *dc);
/* Determine if a specific scancode'ed key is held down (PC specific) */
bool MGLAPI EVT_isKeyDown(uchar scanCode);
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif
#endif /* __MGLDOS_H */

View File

@ -1,153 +0,0 @@
/****************************************************************************
*
* MegaGraph Graphics Library
*
* Copyright (C) 1996 SciTech Software.
* All rights reserved.
*
* Filename: $Workfile: mglwin.h $
* Version: $Revision: 1.14 $
*
* Language: ANSI C
* Environment: IBM PC (MS DOS)
*
* Description: Header file for the MGLWIN bindings for MS Windows using
* WinG in a window and WinDirect for full screen. The MGLWIN
* binding only targets Win32 applications, so cannot be used
* for 16 bit Windows development.
*
* $Date: 14 Mar 1997 16:09:34 $ $Author: KendallB $
*
****************************************************************************/
#ifndef __MGLWIN_H
#define __MGLWIN_H
#ifndef MGLWIN
#define MGLWIN
#endif
/*---------------------- Macros and type definitions ----------------------*/
typedef HWND MGL_HWND;
typedef HDC MGL_HDC;
typedef HINSTANCE MGL_HINSTANCE;
/*------------------------- Function Prototypes ---------------------------*/
#ifdef __cplusplus
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
/* Initialise the MGL for fullscreen output */
bool MGLAPI MGL_init(m_int * driver, m_int * mode, const char *mglpath);
/* Initialise the MGL just for Windowed output, not full screen */
bool MGLAPI MGL_initWindowed(const char *mglpath);
/* Function to register a fullscreen window with the MGL. If you wish
* for the MGL to use your own window for fullscreen modes, you can
* register it with this function. Note that when the MGL goes into
* fullscreen modes, the attributes, size and position of the window are
* modified to make it into a fullscreen Window necessary to cover the
* entire desktop, and the state of the window will be restore to the original
* format on return to normal GDI mode.
*
* Note that if you are using a common window for Windowed mode and fullscreen
* modes of your application, you will need to ensure that certain messages
* that you window normally handles in windowed modes are ignored when in
* fullscreen modes.
*/
void MGLAPI MGL_registerFullScreenWindow(HWND hwndFullScreen);
/* Function to register a fullscreen event handling window procedure.
* If you wish to do your own event handling, you can register your window
* procedure with the MGL using this function and it will be called
* when there are messages to be handled. You can still call the MGL_event()
* functions even if you have registered an event handling procedure.
*/
void MGLAPI MGL_registerEventProc(WNDPROC userWndProc);
/* Change the active display mode. You must destroy all display device
* contexts before calling this function, and re-create them again with
* the new display mode. Does not affect any event handling hooks.
*/
bool MGLAPI MGL_changeDisplayMode(m_int mode);
/* Obtain the handle to the MGL fullscreen window when in fullscreen modes */
MGL_HWND MGLAPI MGL_getFullScreenWindow(void);
/* Tell the MGL what your applications main window is */
void MGLAPI MGL_setMainWindow(MGL_HWND hwnd);
/* Tell the MGL your applications instance handle (call before all funcs!) */
void MGLAPI MGL_setAppInstance(MGL_HINSTANCE hInstApp);
/* Device context management */
MGLDC *MGLAPI MGL_createDisplayDC(m_int numBuffers);
MGLDC *MGLAPI MGL_createSrollingDC(m_int virtualX, m_int virtualY,
m_int numBuffers);
MGLDC *MGLAPI MGL_createOffscreenDC(void);
MGLDC *MGLAPI MGL_createLinearOffscreenDC(void);
MGLDC *MGLAPI MGL_createWindowedDC(MGL_HWND hwnd);
MGLDC *MGLAPI MGL_createMemoryDC(m_int xSize, m_int ySize,
m_int bitsPerPixel, pixel_format_t *pf);
bool MGLAPI MGL_destroyDC(MGLDC *dc);
/* Get a Windows HDC for the MGL device context. You can use this returned
* HDC to get GDI to draw to the device context surface, such as rendering
* and using TrueType fonts with the MGL. If a Windows compatible HDC is not
* available, this function will return NULL.
*/
HDC MGLAPI MGL_getWinDC(MGLDC *dc);
/* Associate a Window manager DC with the MGLDC for painting */
bool MGLAPI MGL_setWinDC(MGLDC *dc, MGL_HDC hdc);
/* Activate the WindowDC's palette */
bool MGLAPI MGL_activatePalette(MGLDC *dc, bool unrealize);
/* Let the MGL know when your application is being activated or deactivated.
* This function only needs to be called when running in Windowed modes and
* you have set the system palette to SYSPAL_NOSTATIC mode, to ensure
* that the MGL can properly re-map your application palette when your
* app is not active and allow Windows to re-map your bitmap colors on the
* fly. This function should be passed a pointer to the currently active
* MGL Windowed DC and a flag to indicate whether the app is in the background
* or not.
*/
void MGLAPI MGL_appActivate(MGLDC *winDC, bool active);
/* Generic helper functions */
ulong MGLAPI MGL_getTicks(void);
ulong MGLAPI MGL_getTickResolution(void);
void MGLAPI MGL_delay(m_int millseconds);
void MGLAPI MGL_beep(m_int freq, m_int milliseconds);
/* Fullscreen specific routines */
void MGLAPI MGL_setPaletteSnowLevel(MGLDC *dc, m_int level);
m_int MGLAPI MGL_getPaletteSnowLevel(MGLDC *dc);
/* Determine if a specific scancode'ed key is held down (PC specific) */
bool MGLAPI EVT_isKeyDown(uchar scanCode);
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif
#endif /* __MGLWIN_H */

File diff suppressed because it is too large Load Diff

Binary file not shown.