OpenClonk
C4FoWRegion.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 C4FOWREGION_H
17 #define C4FOWREGION_H
18 
20 #include "lib/C4Rect.h"
21 #include "graphics/C4FacetEx.h"
22 #include "player/C4Player.h"
23 #include "landscape/fow/C4FoW.h"
24 #ifndef USE_CONSOLE
25 #include <epoxy/gl.h>
26 #endif
27 
28 class C4Surface;
29 
31 {
32 public:
33  C4FoWRegion(C4FoW *pFoW, C4Player *pPlayer);
34  ~C4FoWRegion();
35 
36 private:
37  C4FoW *pFoW;
38 #ifndef USE_CONSOLE
39  C4Player *pPlayer;
40 #endif
41  std::unique_ptr<C4Surface> pSurface, pBackSurface;
42  C4Rect Region, OldRegion;
43  FLOAT_RECT ViewportRegion; // Region covered by visible viewport
44 
45 #ifndef USE_CONSOLE
46  GLuint hFrameBufDraw, hFrameBufRead;
47  GLuint hVBO;
48  unsigned int vaoid;
49 #endif
50 
51 public:
52  const C4FoW* getFoW() const { return pFoW; }
53  const C4Rect &getRegion() const { return Region; }
54  const FLOAT_RECT &getViewportRegion() const { return ViewportRegion; }
55  int32_t getSurfaceHeight() const;
56  int32_t getSurfaceWidth() const;
57 
58 #ifndef USE_CONSOLE
59  GLuint getSurfaceName() const;
60 #endif
61 
62  void Update(C4Rect r, const FLOAT_RECT& vp);
63  bool Render(const C4TargetFacet *pOnScreen = nullptr);
64 
65  // Fills a 2x3 matrix to transform fragment coordinates to light texture coordinates
66  void GetFragTransform(const C4Rect& clipRect, const C4Rect& outRect, float lightTransform[6]) const;
67 private:
68 #ifndef USE_CONSOLE
69  bool BindFramebuf(GLuint prev_fb);
70 #endif
71 };
72 
73 #endif
Definition: C4FoW.h:102
GLuint getSurfaceName() const
int32_t getSurfaceHeight() const
const C4Rect & getRegion() const
Definition: C4FoWRegion.h:53
const C4FoW * getFoW() const
Definition: C4FoWRegion.h:52
C4FoWRegion(C4FoW *pFoW, C4Player *pPlayer)
Definition: C4FoWRegion.cpp:21
void Update(C4Rect r, const FLOAT_RECT &vp)
const FLOAT_RECT & getViewportRegion() const
Definition: C4FoWRegion.h:54
int32_t getSurfaceWidth() const
void GetFragTransform(const C4Rect &clipRect, const C4Rect &outRect, float lightTransform[6]) const
bool Render(const C4TargetFacet *pOnScreen=nullptr)
Definition: C4Rect.h:28