1 // SONIC ROBO BLAST 2
2 //-----------------------------------------------------------------------------
3 // Copyright (C) 1993-1996 by id Software, Inc.
4 // Copyright (C) 1998-2000 by DooM Legacy Team.
5 // Copyright (C) 1999-2020 by Sonic Team Junior.
6 //
7 // This program is free software distributed under the
8 // terms of the GNU General Public License, version 2.
9 // See the 'LICENSE' file for more details.
10 //-----------------------------------------------------------------------------
11 /// \file  r_sky.c
12 /// \brief Sky rendering
13 ///        The SRB2 sky is a texture map like any
14 ///        wall, wrapping around. A 1024 columns equal 360 degrees.
15 ///        The default sky map is 256 columns and repeats 4 times
16 ///        on a 320 screen.
17 
18 #include "doomdef.h"
19 #include "doomstat.h"
20 #include "r_sky.h"
21 #include "r_local.h"
22 #include "w_wad.h"
23 #include "z_zone.h"
24 
25 #include "p_maputl.h" // P_PointOnLineSide
26 
27 //
28 // sky mapping
29 //
30 
31 /**	\brief Needed to store the number of the dummy sky flat.
32 	Used for rendering, as well as tracking projectiles etc.
33 */
34 INT32 skyflatnum;
35 
36 /**	\brief the lump number of the sky texture
37 */
38 INT32 skytexture;
39 
40 /**	\brief the horizon line in a 256x128 sky texture
41 */
42 INT32 skytexturemid;
43 
44 /**	\brief the scale of the sky
45 */
46 fixed_t skyscale;
47 
48 /** \brief used for keeping track of the current sky
49 */
50 INT32 levelskynum;
51 INT32 globallevelskynum;
52 
53 /**	\brief	The R_SetupSkyDraw function
54 
55 	Called at loadlevel after skytexture is set, or when sky texture changes.
56 
57 	\warning wallcolfunc should be set at R_ExecuteSetViewSize()
58 	I don't bother because we don't use low detail anymore
59 
60 	\return	void
61 */
R_SetupSkyDraw(void)62 void R_SetupSkyDraw(void)
63 {
64 	// the horizon line in a 256x128 sky texture
65 	skytexturemid = (textures[skytexture]->height/2)<<FRACBITS;
66 
67 	R_SetSkyScale();
68 }
69 
70 /**	\brief	The R_SetSkyScale function
71 
72 	set the correct scale for the sky at setviewsize
73 
74 	\return void
75 */
R_SetSkyScale(void)76 void R_SetSkyScale(void)
77 {
78 	fixed_t difference = vid.fdupx-(vid.dupx<<FRACBITS);
79 	skyscale = FixedDiv(fovtan, vid.fdupx+difference);
80 }
81