OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4FoW.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 C4FOW_H
17 #define C4FOW_H
18 
20 #include "graphics/C4Surface.h"
21 #include "graphics/C4FacetEx.h"
22 #include "lib/C4Rect.h"
23 #include "object/C4Object.h"
26 #include "graphics/C4Shader.h"
27 
33 {
34 public:
35  C4FragTransform(): x(1.0f), y(1.0f), x0(0.0f), y0(0.0f) {}
36 
37  // Multiplies from left
38  inline void Translate(float dx, float dy)
39  {
40  x0 += dx;
41  y0 += dy;
42  }
43 
44  // Multiplies from left
45  inline void Scale(float sx, float sy)
46  {
47  x *= sx;
48  y *= sy;
49 
50  x0 *= sx;
51  y0 *= sy;
52  }
53 
54  inline void Get2x3(float transform[6])
55  {
56  transform[0] = x;
57  transform[1] = 0.f;
58  transform[2] = x0;
59  transform[3] = 0.f;
60  transform[4] = y;
61  transform[5] = y0;
62  }
63 
64 private:
65  float x, y;
66  float x0, y0;
67 };
68 
70  C4FoWFSU_ProjectionMatrix, // projection matrix
71  C4FoWFSU_Texture, // source texture
72 
74 };
75 
79 
81 };
82 
84  C4FoWRSU_ProjectionMatrix, // projection matrix
85  C4FoWRSU_VertexOffset, // offset applied to vertex (TODO: could be encoded in projection matrix)
86 
88 };
89 
93 
95 };
96 
101 class C4FoW
102 {
103 public:
104  C4FoW();
105  ~C4FoW();
106 
107 private:
109  class C4FoWLight *pLights;
110 
112  class C4FoWLight *deleted_lights;
113 
114 public:
116 
117  // Shader to use for updating the frame buffer
119  // Shader to use for rendering the lights
121 
122  void ClearDeletedLights();
123 
125  void Add(C4Object *pObj);
127  void Remove(C4Object *pObj);
128 
130  void Update(C4Rect r, C4Player *player);
132  void Invalidate(C4Rect r);
133 
134  void Render(class C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4Player *pPlr, const StdProjectionMatrix& projectionMatrix);
135 
136 private:
137 #ifndef USE_CONSOLE
138  // Shader for updating the frame buffer
139  C4Shader FramebufShader;
140  C4Shader RenderShader;
141 #endif
142 };
143 
144 #endif // C4FOW_H
void Invalidate(C4Rect r)
Definition: C4FoW.cpp:225
void Translate(float dx, float dy)
Definition: C4FoW.h:38
C4FoW()
Definition: C4FoW.cpp:24
C4Shader * GetFramebufShader()
Definition: C4FoW.cpp:51
Definition: C4Rect.h:29
C4FoWFramebufShaderUniforms
Definition: C4FoW.h:69
C4FoWFramebufShaderAttributes
Definition: C4FoW.h:76
~C4FoW()
Definition: C4FoW.cpp:29
C4FoWRenderShaderAttributes
Definition: C4FoW.h:90
void Scale(float sx, float sy)
Definition: C4FoW.h:45
void ClearDeletedLights()
Definition: C4FoW.cpp:38
void Update(C4Rect r, C4Player *player)
Definition: C4FoW.cpp:233
void Add(C4Object *pObj)
Definition: C4FoW.cpp:169
C4FoWAmbient Ambient
Definition: C4FoW.h:115
void Remove(C4Object *pObj)
Definition: C4FoW.cpp:205
Definition: C4FoW.h:101
C4FragTransform()
Definition: C4FoW.h:35
void Get2x3(float transform[6])
Definition: C4FoW.h:54
C4Shader * GetRenderShader()
Definition: C4FoW.cpp:110
void Render(class C4FoWRegion *pRegion, const C4TargetFacet *pOnScreen, C4Player *pPlr, const StdProjectionMatrix &projectionMatrix)
Definition: C4FoW.cpp:242
C4FoWRenderShaderUniforms
Definition: C4FoW.h:83