]> icculus.org git repositories - btb/d2x.git/blob - unused/win95/gfx.c
remove rcs tags
[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
16
17
18 #define _WIN32
19 #define WIN95
20 #define WIN32_LEAN_AND_MEAN
21
22 #include <windows.h>
23 #include <windowsx.h>
24
25 #include <stdio.h>
26
27 #include "ddraw.h"
28
29 #include "pstypes.h"
30 #include "mem.h"
31 #include "mono.h"
32 #include "args.h"
33 #include "error.h"
34 #include "winapp.h"
35
36 #include "dd.h"
37 #include "direct3d.h"
38
39
40
41 //      Globals
42 //      ----------------------------------------------------------------------------
43
44 static BOOL                                             gfx_initialized=0;// GFX flag
45 static BOOL                                             d3d_enhanced=0; //   3D enhanced?
46 static FILE                                     *LogFile=NULL;          // Log File!
47
48
49 //      Function prototypes
50 //      ----------------------------------------------------------------------------
51
52 #ifdef NDEBUG
53 #define WRITELOG(t)
54 #define LOGINIT(n)
55 #define LOGCLOSE
56 #else
57 #define WRITELOG(t) if (LogFile) { fprintf t; fflush(LogFile); }
58 #define LOGINIT(n) LogFile = fopen(n, "wt"); 
59 #define LOGCLOSE if (LogFile) fclose(LogFile);
60 #endif
61
62
63
64 /* gfx Philosophy
65         
66         The GFX system is a higher level abstraction that is independent of the
67         DD-DDGR interface.   gfx uses the DD-DDGR interface, but not the other way
68         around.   You may use GFX calls and DD-DDGR calls interchangably with older
69         functions.  Any newer graphic functionality for Descent 2 will use
70         GFX calls
71 */
72
73
74 //      Initialization
75 //      ----------------------------------------------------------------------------
76
77 /* gfxInit
78                 
79                 When called at game initialization, this will initialize the DirectDraw
80                 system.  Then we initialize other graphic components if called for.
81         
82 */
83
84 BOOL gfxInit(int hw_acc)
85 {
86 //      Initialize Direct Draw and DDGR system.
87
88         if (gfx_initialized) return TRUE;
89
90         if (!DDInit(DDGR_FULLSCREEN)) 
91                 return FALSE;
92
93         grd_curscreen = (grs_screen *)malloc(sizeof(grs_screen));
94         W95DisplayMode = SM95_640x480x8;
95
96         gr_init();
97         dd_gr_init();
98         dd_gr_init_screen();
99
100 //      Initialize 3D system if available.
101         if (hw_acc) 
102         {
103                 if (!d3d_init()) 
104                         Error("Unable to initialize 3D Hardware.");
105                 d3d_enhanced = 1;
106         }
107         else d3d_enhanced = 0;
108
109         gfx_initialized = 1;
110
111         return TRUE;
112 }
113
114
115 void gfxClose(void)
116 {
117         if (!gfx_initialized) return;
118         gfx_initialized = 0;    
119 }