OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4FoWAmbient.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2014-2016, The OpenClonk Team and contributors
5  *
6  * Distributed under the terms of the ISC license; see accompanying file
7  * "COPYING" for details.
8  *
9  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
10  * See accompanying file "TRADEMARK" for details.
11  *
12  * To redistribute this file separately, substitute the full license texts
13  * for the above references.
14  */
15 
16 #ifndef C4FOWAMBIENT_H
17 #define C4FOWAMBIENT_H
18 
20 
21 #include "landscape/C4Landscape.h"
22 #ifndef USE_CONSOLE
23 #include <GL/glew.h>
24 #endif
25 
30 {
31 public:
32  C4FoWAmbient();
33  ~C4FoWAmbient();
34 
35 #ifndef USE_CONSOLE
36  GLuint Tex{0};
37 #endif
38 
39 private:
40  // Parameters
41  double Resolution{0.};
42  double Radius{0.};
43  double FullCoverage{0.};
44  // Landscape size
45  unsigned int LandscapeX{0};
46  unsigned int LandscapeY{0};
47  // Size of ambient map
48  unsigned int SizeX{0};
49  unsigned int SizeY{0};
50  // Brightness (not premultiplied)
51  double Brightness{1.};
52 public:
53  void Clear();
54 
55  void SetBrightness(double brightness) { Brightness = brightness; }
56  double GetBrightness() const { return Brightness; }
57 
58  // High resolution will make the map coarser, but speed up the generation process
59  // and save video memory.
60  // The radius specifies the radius of landscape pixels that are sampled around each pixel
61  // to obtain the ambient light.
62  // full_coverage is a number between 0 and 1, and it specifies what portion of the full circle
63  // needs to be illuminated for full ambient light intensity.
64  void CreateFromLandscape(const C4Landscape& landscape, double resolution, double radius, double full_coverage);
65 
66  // Update the map after the landscape has changed in the region indicated by update.
67  void UpdateFromLandscape(const C4Landscape& landscape, const C4Rect& update);
68 
69  // Fills a 2x3 matrix to transform fragment coordinates to ambient map texture coordinates
70  void GetFragTransform(const struct FLOAT_RECT& vpRect, const C4Rect& clipRect, const C4Rect& outRect, float ambientTransform[6]) const;
71 
72  unsigned int GetLandscapeWidth() const { return LandscapeX; }
73  unsigned int GetLandscapeHeight() const { return LandscapeY; }
74 };
75 
76 #endif // C4FOWAMBIENT_H
unsigned int GetLandscapeWidth() const
Definition: C4FoWAmbient.h:72
void UpdateFromLandscape(const C4Landscape &landscape, const C4Rect &update)
double GetBrightness() const
Definition: C4FoWAmbient.h:56
void CreateFromLandscape(const C4Landscape &landscape, double resolution, double radius, double full_coverage)
unsigned int GetLandscapeHeight() const
Definition: C4FoWAmbient.h:73
Definition: C4Rect.h:27
void SetBrightness(double brightness)
Definition: C4FoWAmbient.h:55
void GetFragTransform(const struct FLOAT_RECT &vpRect, const C4Rect &clipRect, const C4Rect &outRect, float ambientTransform[6]) const