]> icculus.org git repositories - btb/d2x.git/blob - 3d/setup.c
Minor sync with d1x
[btb/d2x.git] / 3d / setup.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-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13 /*
14  * $Source: /cvs/cvsroot/d2x/3d/setup.c,v $
15  * $Revision: 1.3 $
16  * $Author: bradleyb $
17  * $Date: 2001-10-31 03:54:51 $
18  * 
19  * Setup for 3d library
20  * 
21  * $Log: not supported by cvs2svn $
22  * Revision 1.2  2001/01/31 15:17:48  bradleyb
23  * Makefile and conf.h fixes
24  *
25  * Revision 1.1.1.1  2001/01/19 03:29:58  bradleyb
26  * Import of d2x-0.0.8
27  *
28  * Revision 1.3  1999/10/07 02:27:14  donut
29  * OGL includes to remove warnings
30  *
31  * Revision 1.2  1999/09/21 04:05:55  donut
32  * mostly complete OGL implementation (still needs bitmap handling (reticle), and door/fan textures are corrupt)
33  *
34  * Revision 1.1.1.1  1999/06/14 21:57:50  donut
35  * Import of d1x 1.37 source.
36  *
37  * Revision 1.4  1995/10/11  00:27:04  allender
38  * bash free_num_points to 0
39  *
40  * Revision 1.3  1995/09/13  11:31:58  allender
41  * calc for fCanv_w2 and fCanv_h2
42  *
43  * Revision 1.2  1995/06/25  21:57:57  allender
44  * *** empty log message ***
45  *
46  * Revision 1.1  1995/05/05  08:52:54  allender
47  * Initial revision
48  *
49  * Revision 1.1  1995/04/17  03:59:01  matt
50  * Initial revision
51  * 
52  * 
53  */
54
55 #ifdef HAVE_CONFIG_H
56 #include <conf.h>
57 #endif
58
59 #ifdef RCS
60 static char rcsid[] = "$Id: setup.c,v 1.3 2001-10-31 03:54:51 bradleyb Exp $";
61 #endif
62
63 #include <stdlib.h>
64
65 #include "error.h"
66
67 #include "3d.h"
68 #include "globvars.h"
69 #include "clipper.h"
70 //#include "div0.h"
71
72 #ifdef OGL
73 #include "ogl_init.h"
74 #endif
75
76 //initialize the 3d system
77 void g3_init(void)
78 {
79 //      div0_init(DM_ERROR);
80         atexit(g3_close);
81 }
82
83 //close down the 3d system
84 void g3_close(void) {}
85
86 extern void init_interface_vars_to_assembler(void);
87
88 //start the frame
89 void g3_start_frame(void)
90 {
91         fix s;
92
93         //set int w,h & fixed-point w,h/2
94         Canv_w2 = (Canvas_width  = grd_curcanv->cv_bitmap.bm_w)<<15;
95         Canv_h2 = (Canvas_height = grd_curcanv->cv_bitmap.bm_h)<<15;
96 #ifdef __powerc
97         fCanv_w2 = f2fl((Canvas_width  = grd_curcanv->cv_bitmap.bm_w)<<15);
98         fCanv_h2 = f2fl((Canvas_height = grd_curcanv->cv_bitmap.bm_h)<<15);
99 #endif
100
101         //compute aspect ratio for this canvas
102
103         s = fixmuldiv(grd_curscreen->sc_aspect,Canvas_height,Canvas_width);
104
105         if (s <= f1_0) {           //scale x
106                 Window_scale.x = s;
107                 Window_scale.y = f1_0;
108         }
109         else {
110                 Window_scale.y = fixdiv(f1_0,s);
111                 Window_scale.x = f1_0;
112         }
113         
114         Window_scale.z = f1_0;          //always 1
115
116         init_free_points();
117
118 #ifdef D1XD3D
119         Win32_start_frame ();
120 #else
121 #ifdef OGL
122         ogl_start_frame();
123 #else
124         init_interface_vars_to_assembler();             //for the texture-mapper
125 #endif
126 #endif
127
128 }
129
130 //this doesn't do anything, but is here for completeness
131 void g3_end_frame(void)
132 {
133 #ifdef D1XD3D
134         Win32_end_frame ();
135 #endif
136 #ifdef OGL
137         ogl_end_frame();
138 #endif
139
140 //      Assert(free_point_num==0);
141         free_point_num = 0;
142
143 }
144
145