]> icculus.org git repositories - btb/d2x.git/blob - 3d/setup.c
fix compiler errors in MPW w/o OpenGL
[btb/d2x.git] / 3d / setup.c
1 /* $Id: setup.c,v 1.6 2004-08-28 23:17:45 schaffner Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14 /*
15  * 
16  * Setup for 3d library
17  * 
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include <conf.h>
22 #endif
23
24 #ifdef RCS
25 static char rcsid[] = "$Id: setup.c,v 1.6 2004-08-28 23:17:45 schaffner Exp $";
26 #endif
27
28 #include <stdlib.h>
29
30 #include "error.h"
31
32 #include "3d.h"
33 #include "globvars.h"
34 #include "clipper.h"
35 //#include "div0.h"
36
37 #ifdef OGL
38 #include "ogl_init.h"
39 #else
40 #include "texmap.h"  // for init_interface_vars_to_assembler()
41 #endif
42
43 //initialize the 3d system
44 void g3_init(void)
45 {
46 //      div0_init(DM_ERROR);
47         atexit(g3_close);
48 }
49
50 //close down the 3d system
51 void g3_close(void) {}
52
53 //start the frame
54 void g3_start_frame(void)
55 {
56         fix s;
57
58         //set int w,h & fixed-point w,h/2
59         Canv_w2 = (Canvas_width  = grd_curcanv->cv_bitmap.bm_w)<<15;
60         Canv_h2 = (Canvas_height = grd_curcanv->cv_bitmap.bm_h)<<15;
61 #ifdef __powerc
62         fCanv_w2 = f2fl((Canvas_width  = grd_curcanv->cv_bitmap.bm_w)<<15);
63         fCanv_h2 = f2fl((Canvas_height = grd_curcanv->cv_bitmap.bm_h)<<15);
64 #endif
65
66         //compute aspect ratio for this canvas
67
68         s = fixmuldiv(grd_curscreen->sc_aspect,Canvas_height,Canvas_width);
69
70         if (s <= f1_0) {           //scale x
71                 Window_scale.x = s;
72                 Window_scale.y = f1_0;
73         }
74         else {
75                 Window_scale.y = fixdiv(f1_0,s);
76                 Window_scale.x = f1_0;
77         }
78         
79         Window_scale.z = f1_0;          //always 1
80
81         init_free_points();
82
83 #ifdef D1XD3D
84         Win32_start_frame ();
85 #else
86 #ifdef OGL
87         ogl_start_frame();
88 #else
89         init_interface_vars_to_assembler();             //for the texture-mapper
90 #endif
91 #endif
92
93 }
94
95 //this doesn't do anything, but is here for completeness
96 void g3_end_frame(void)
97 {
98 #ifdef D1XD3D
99         Win32_end_frame ();
100 #endif
101 #ifdef OGL
102         ogl_end_frame();
103 #endif
104
105 //      Assert(free_point_num==0);
106         free_point_num = 0;
107
108 }
109
110