2015-02-16 17:36:18 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014-2015, The OpenClonk Team and contributors
|
|
|
|
*
|
|
|
|
* Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
* "COPYING" for details.
|
|
|
|
*
|
|
|
|
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
* See accompanying file "TRADEMARK" for details.
|
|
|
|
*
|
|
|
|
* To redistribute this file separately, substitute the full license texts
|
|
|
|
* for the above references.
|
|
|
|
*/
|
2014-11-17 14:35:50 +00:00
|
|
|
|
|
|
|
#ifndef C4FOWAMBIENT_H
|
|
|
|
#define C4FOWAMBIENT_H
|
|
|
|
|
|
|
|
//#include <GL/gl.h>
|
|
|
|
#include <C4Landscape.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
This class manages a texture that holds the ambient light intensity
|
|
|
|
*/
|
|
|
|
class C4FoWAmbient
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
C4FoWAmbient();
|
|
|
|
~C4FoWAmbient();
|
|
|
|
|
2015-06-17 19:30:56 +00:00
|
|
|
#ifndef USE_CONSOLE
|
2014-11-17 14:35:50 +00:00
|
|
|
GLuint Tex;
|
2015-06-17 19:30:56 +00:00
|
|
|
#endif
|
2014-11-17 14:35:50 +00:00
|
|
|
|
|
|
|
private:
|
2014-11-18 17:37:29 +00:00
|
|
|
// Parameters
|
|
|
|
double Resolution;
|
|
|
|
double Radius;
|
|
|
|
double FullCoverage;
|
2014-11-17 14:35:50 +00:00
|
|
|
// Landscape size
|
|
|
|
unsigned int LandscapeX;
|
|
|
|
unsigned int LandscapeY;
|
|
|
|
// Size of ambient map
|
|
|
|
unsigned int SizeX;
|
|
|
|
unsigned int SizeY;
|
2014-11-19 16:18:07 +00:00
|
|
|
// Brightness (not premultiplied)
|
|
|
|
double Brightness;
|
2014-11-17 14:35:50 +00:00
|
|
|
public:
|
|
|
|
void Clear();
|
|
|
|
|
2014-11-19 16:18:07 +00:00
|
|
|
void SetBrightness(double brightness) { Brightness = brightness; }
|
|
|
|
double GetBrightness() const { return Brightness; }
|
|
|
|
|
2014-11-17 14:35:50 +00:00
|
|
|
// High resolution will make the map coarser, but speed up the generation process
|
|
|
|
// and save video memory.
|
|
|
|
// The radius specifies the radius of landscape pixels that are sampled around each pixel
|
|
|
|
// to obtain the ambient light.
|
|
|
|
// full_coverage is a number between 0 and 1, and it specifies what portion of the full circle
|
|
|
|
// needs to be illuminated for full ambient light intensity.
|
|
|
|
void CreateFromLandscape(const C4Landscape& landscape, double resolution, double radius, double full_coverage);
|
|
|
|
|
2014-11-18 17:37:29 +00:00
|
|
|
// Update the map after the landscape has changed in the region indicated by update.
|
|
|
|
void UpdateFromLandscape(const C4Landscape& landscape, const C4Rect& update);
|
|
|
|
|
2014-11-23 21:29:51 +00:00
|
|
|
// Fills a 2x3 matrix to transform fragment coordinates to ambient map texture coordinates
|
2015-01-07 16:29:48 +00:00
|
|
|
void GetFragTransform(const FLOAT_RECT& vpRect, const C4Rect& clipRect, const C4Rect& outRect, float ambientTransform[6]) const;
|
2014-11-23 21:29:51 +00:00
|
|
|
|
2014-11-17 14:35:50 +00:00
|
|
|
unsigned int GetLandscapeWidth() const { return LandscapeX; }
|
|
|
|
unsigned int GetLandscapeHeight() const { return LandscapeY; }
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // C4FOWAMBIENT_H
|