OpenClonk
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 "graphics/C4Shader.h"
24 
25 #define C4SkyPM_Fixed 0 // sky parallax mode: fixed
26 #define C4SkyPM_Wind 1 // sky parallax mode: blown by the wind
27 
28 class C4Sky
29 {
30 public:
31  C4Sky() { Default(); }
32  ~C4Sky();
33  void Default(); // zero fields
34 
35  bool Init(bool fSavegame, std::string names = "");
36  void Clear();
37  void SetColor(int32_t iIndex, int32_t iRed, int32_t iGreen, int32_t iBlue);
38  void SetFadePalette(int32_t *ipColors);
39  void Draw(C4TargetFacet &cgo); // draw sky
40  DWORD GetSkyFadeClr(int32_t iY); // get sky color at iY
41  void Execute(); // move sky
42  bool SetModulation(DWORD dwWithClr, DWORD dwBackClr); // adjust the way the sky is blitted
43  DWORD GetModulation(bool fBackClr)
44  { return fBackClr ? BackClr : Modulation; }
45  void CompileFunc(StdCompiler *pComp);
46 protected:
47  int32_t Width, Height;
48  uint32_t Modulation;
49  int32_t BackClr; // background color behind sky
50  bool BackClrEnabled; // is the background color enabled?
51 public:
52  class C4Surface * Surface;
53  C4Shader Shader; // shader to draw sky w/o dynamic light (global viewport)
54  C4Shader ShaderLight; // shader to draw sky with dynamic light (player viewport)
55  C4Real xdir,ydir; // sky movement speed
56  C4Real x,y; // sky movement pos
57  int32_t ParX, ParY; // parallax movement in xdir/ydir
58  uint32_t FadeClr1, FadeClr2;
59  int32_t ParallaxMode; // sky scrolling mode
60 };
61 
62 #endif
uint32_t DWORD
Definition: C4Real.h:59
Definition: C4Sky.h:29
void SetFadePalette(int32_t *ipColors)
Definition: C4Sky.cpp:30
DWORD GetModulation(bool fBackClr)
Definition: C4Sky.h:43
int32_t Height
Definition: C4Sky.h:47
void Default()
Definition: C4Sky.cpp:142
C4Real y
Definition: C4Sky.h:56
void SetColor(int32_t iIndex, int32_t iRed, int32_t iGreen, int32_t iBlue)
bool BackClrEnabled
Definition: C4Sky.h:50
void CompileFunc(StdCompiler *pComp)
Definition: C4Sky.cpp:237
bool SetModulation(DWORD dwWithClr, DWORD dwBackClr)
Definition: C4Sky.cpp:229
int32_t ParX
Definition: C4Sky.h:57
C4Real x
Definition: C4Sky.h:56
void Execute()
Definition: C4Sky.cpp:167
uint32_t FadeClr1
Definition: C4Sky.h:58
int32_t Width
Definition: C4Sky.h:47
int32_t ParallaxMode
Definition: C4Sky.h:59
class C4Surface * Surface
Definition: C4Sky.h:52
void Draw(C4TargetFacet &cgo)
Definition: C4Sky.cpp:180
C4Sky()
Definition: C4Sky.h:31
C4Shader ShaderLight
Definition: C4Sky.h:54
uint32_t Modulation
Definition: C4Sky.h:48
~C4Sky()
Definition: C4Sky.cpp:154
DWORD GetSkyFadeClr(int32_t iY)
Definition: C4Sky.cpp:221
bool Init(bool fSavegame, std::string names="")
Definition: C4Sky.cpp:46
C4Real xdir
Definition: C4Sky.h:55
void Clear()
Definition: C4Sky.cpp:159
int32_t ParY
Definition: C4Sky.h:57
C4Shader Shader
Definition: C4Sky.h:53
uint32_t FadeClr2
Definition: C4Sky.h:58
C4Real ydir
Definition: C4Sky.h:55
int32_t BackClr
Definition: C4Sky.h:49