]> icculus.org git repositories - btb/d2x.git/blob - unused/win95/gfx.c
comments/formatting
[btb/d2x.git] / unused / win95 / gfx.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14
15 #pragma off (unreferenced)
16 static char rcsid[] = "$Id: gfx.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $";
17 #pragma on (unreferenced)
18
19
20
21
22 #define _WIN32
23 #define WIN95
24 #define WIN32_LEAN_AND_MEAN
25
26 #include <windows.h>
27 #include <windowsx.h>
28
29 #include <stdio.h>
30
31 #include "ddraw.h"
32
33 #include "pstypes.h"
34 #include "mem.h"
35 #include "mono.h"
36 #include "args.h"
37 #include "error.h"
38 #include "winapp.h"
39
40 #include "dd.h"
41 #include "direct3d.h"
42
43
44
45 //      Globals
46 //      ----------------------------------------------------------------------------
47
48 static BOOL                                             gfx_initialized=0;// GFX flag
49 static BOOL                                             d3d_enhanced=0; //   3D enhanced?
50 static FILE                                     *LogFile=NULL;          // Log File!
51
52
53 //      Function prototypes
54 //      ----------------------------------------------------------------------------
55
56 #ifdef NDEBUG
57 #define WRITELOG(t)
58 #define LOGINIT(n)
59 #define LOGCLOSE
60 #else
61 #define WRITELOG(t) if (LogFile) { fprintf t; fflush(LogFile); }
62 #define LOGINIT(n) LogFile = fopen(n, "wt"); 
63 #define LOGCLOSE if (LogFile) fclose(LogFile);
64 #endif
65
66
67
68 /* gfx Philosophy
69         
70         The GFX system is a higher level abstraction that is independent of the
71         DD-DDGR interface.   gfx uses the DD-DDGR interface, but not the other way
72         around.   You may use GFX calls and DD-DDGR calls interchangably with older
73         functions.  Any newer graphic functionality for Descent 2 will use
74         GFX calls
75 */
76
77
78 //      Initialization
79 //      ----------------------------------------------------------------------------
80
81 /* gfxInit
82                 
83                 When called at game initialization, this will initialize the DirectDraw
84                 system.  Then we initialize other graphic components if called for.
85         
86 */
87
88 BOOL gfxInit(int hw_acc)
89 {
90 //      Initialize Direct Draw and DDGR system.
91
92         if (gfx_initialized) return TRUE;
93
94         if (!DDInit(DDGR_FULLSCREEN)) 
95                 return FALSE;
96
97         grd_curscreen = (grs_screen *)malloc(sizeof(grs_screen));
98         W95DisplayMode = SM95_640x480x8;
99
100         gr_init();
101         dd_gr_init();
102         dd_gr_init_screen();
103
104 //      Initialize 3D system if available.
105         if (hw_acc) 
106         {
107                 if (!d3d_init()) 
108                         Error("Unable to initialize 3D Hardware.");
109                 d3d_enhanced = 1;
110         }
111         else d3d_enhanced = 0;
112
113         gfx_initialized = 1;
114
115         return TRUE;
116 }
117
118
119 void gfxClose(void)
120 {
121         if (!gfx_initialized) return;
122         gfx_initialized = 0;    
123 }