Debian Codegraph @

common/3d/setup.cpp

raw
1 /*
2 * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
3 * It is copyright by its individual contributors, as recorded in the
4 * project's Git history. See COPYING.txt at the top level for license
5 * terms and a link to the Git history.
6 */
7 /*
8 *
9 * Setup for 3d library
10 *
11 */
12
13
14 #include <stdlib.h>
15
16 #include "dxxerror.h"
17
18 #include "3d.h"
19 #include "globvars.h"
20
21 #if DXX_USE_OGL
22 #include "ogl_init.h"
23 #else
24 #include "texmap.h" // for init_interface_vars_to_assembler()
25 #endif
26 #include "gr.h"
27
28 namespace dcx {
29
30 //start the frame
31 void g3_start_frame(grs_canvas &canvas)
32 {
33 fix s;
34
35 //set int w,h & fixed-point w,h/2
36 const int Canvas_width = canvas.cv_bitmap.bm_w;
37 const int Canvas_height = canvas.cv_bitmap.bm_h;
38 Canv_w2 = Canvas_width << 15;
39 Canv_h2 = Canvas_height << 15;
40 #ifdef __powerc
41 fCanv_w2 = f2fl((Canvas_width)<<15);
42 fCanv_h2 = f2fl((Canvas_height)<<15);
43 #endif
44
45 //compute aspect ratio for this canvas
46
47 s = fixmuldiv(grd_curscreen->sc_aspect,Canvas_height,Canvas_width);
48
49 if (s <= f1_0) { //scale x
50 Window_scale.x = s;
51 Window_scale.y = f1_0;
52 }
53 else {
54 Window_scale.y = fixdiv(f1_0,s);
55 Window_scale.x = f1_0;
56 }
57
58 Window_scale.z = f1_0; //always 1
59
60 #if DXX_USE_OGL
61 ogl_start_frame(canvas);
62 #else
63 init_interface_vars_to_assembler(); //for the texture-mapper
64 #endif
65 }
66
67 }