OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Sky.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2013-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Small member of the landscape class to handle the sky background */
19 
20 #ifndef INC_C4Sky
21 #define INC_C4Sky
22 
23 #include "lib/C4Real.h"
24 #include "graphics/C4Shader.h"
25 
26 #define C4SkyPM_Fixed 0 // sky parallax mode: fixed
27 #define C4SkyPM_Wind 1 // sky parallax mode: blown by the wind
28 
29 class C4Sky
30 {
31 public:
32  C4Sky() { Default(); }
33  ~C4Sky();
34  void Default(); // zero fields
35 
36  bool Init(bool fSavegame, std::string names = "");
37  void Clear();
38  void SetColor(int32_t iIndex, int32_t iRed, int32_t iGreen, int32_t iBlue);
39  void SetFadePalette(int32_t *ipColors);
40  void Draw(C4TargetFacet &cgo); // draw sky
41  DWORD GetSkyFadeClr(int32_t iY); // get sky color at iY
42  void Execute(); // move sky
43  bool SetModulation(DWORD dwWithClr, DWORD dwBackClr); // adjust the way the sky is blitted
44  DWORD GetModulation(bool fBackClr)
45  { return fBackClr ? BackClr : Modulation; }
46  void CompileFunc(StdCompiler *pComp);
47 protected:
48  int32_t Width, Height;
49  uint32_t Modulation;
50  int32_t BackClr; // background color behind sky
51  bool BackClrEnabled; // is the background color enabled?
52 public:
53  class C4Surface * Surface;
54  C4Shader Shader; // shader to draw sky w/o dynamic light (global viewport)
55  C4Shader ShaderLight; // shader to draw sky with dynamic light (player viewport)
56  C4Real xdir,ydir; // sky movement speed
57  C4Real x,y; // sky movement pos
58  int32_t ParX, ParY; // parallax movement in xdir/ydir
59  uint32_t FadeClr1, FadeClr2;
60  int32_t ParallaxMode; // sky scrolling mode
61 };
62 
63 #endif
C4Sky()
Definition: C4Sky.h:32
DWORD GetModulation(bool fBackClr)
Definition: C4Sky.h:44
~C4Sky()
Definition: C4Sky.cpp:155
class C4Surface * Surface
Definition: C4Sky.h:53
int32_t ParallaxMode
Definition: C4Sky.h:60
void Execute()
Definition: C4Sky.cpp:168
void Default()
Definition: C4Sky.cpp:143
C4Shader ShaderLight
Definition: C4Sky.h:55
void Clear()
Definition: C4Sky.cpp:160
void CompileFunc(StdCompiler *pComp)
Definition: C4Sky.cpp:238
Definition: C4Sky.h:29
C4Real x
Definition: C4Sky.h:57
Definition: C4Real.h:58
void SetFadePalette(int32_t *ipColors)
Definition: C4Sky.cpp:31
C4Real y
Definition: C4Sky.h:57
uint32_t FadeClr1
Definition: C4Sky.h:59
void Draw(C4TargetFacet &cgo)
Definition: C4Sky.cpp:181
C4Shader Shader
Definition: C4Sky.h:54
int32_t ParX
Definition: C4Sky.h:58
C4Real ydir
Definition: C4Sky.h:56
bool BackClrEnabled
Definition: C4Sky.h:51
bool SetModulation(DWORD dwWithClr, DWORD dwBackClr)
Definition: C4Sky.cpp:230
bool Init(bool fSavegame, std::string names="")
Definition: C4Sky.cpp:47
int32_t BackClr
Definition: C4Sky.h:50
void SetColor(int32_t iIndex, int32_t iRed, int32_t iGreen, int32_t iBlue)
int32_t ParY
Definition: C4Sky.h:58
uint32_t Modulation
Definition: C4Sky.h:49
C4Real xdir
Definition: C4Sky.h:56
DWORD GetSkyFadeClr(int32_t iY)
Definition: C4Sky.cpp:222
uint32_t DWORD
int32_t Width
Definition: C4Sky.h:48
uint32_t FadeClr2
Definition: C4Sky.h:59
int32_t Height
Definition: C4Sky.h:48