OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 <GL/glew.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  C4Player *pPlayer;
39  std::unique_ptr<C4Surface> pSurface, pBackSurface;
40  C4Rect Region, OldRegion;
41  FLOAT_RECT ViewportRegion; // Region covered by visible viewport
42 
43 #ifndef USE_CONSOLE
44  GLuint hFrameBufDraw, hFrameBufRead;
45  GLuint hVBO;
46  unsigned int vaoid;
47 #endif
48 
49 public:
50  const C4FoW* getFoW() const { return pFoW; }
51  const C4Rect &getRegion() const { return Region; }
52  const FLOAT_RECT &getViewportRegion() const { return ViewportRegion; }
53  int32_t getSurfaceHeight() const;
54  int32_t getSurfaceWidth() const;
55 
56 #ifndef USE_CONSOLE
57  GLuint getSurfaceName() const;
58 #endif
59 
60  void Update(C4Rect r, const FLOAT_RECT& vp);
61  bool Render(const C4TargetFacet *pOnScreen = nullptr);
62 
63  // Fills a 2x3 matrix to transform fragment coordinates to light texture coordinates
64  void GetFragTransform(const C4Rect& clipRect, const C4Rect& outRect, float lightTransform[6]) const;
65 private:
66 #ifndef USE_CONSOLE
67  bool BindFramebuf(GLuint prev_fb);
68 #endif
69 };
70 
71 #endif
const FLOAT_RECT & getViewportRegion() const
Definition: C4FoWRegion.h:52
Definition: C4Rect.h:27
void Update(C4Rect r, const FLOAT_RECT &vp)
const C4FoW * getFoW() const
Definition: C4FoWRegion.h:50
int32_t getSurfaceHeight() const
GLuint getSurfaceName() const
int32_t getSurfaceWidth() const
Definition: C4FoW.h:101
void GetFragTransform(const C4Rect &clipRect, const C4Rect &outRect, float lightTransform[6]) const
const C4Rect & getRegion() const
Definition: C4FoWRegion.h:51
bool Render(const C4TargetFacet *pOnScreen=nullptr)
C4FoWRegion(C4FoW *pFoW, C4Player *pPlayer)
Definition: C4FoWRegion.cpp:21