18 #include "precompiled.h" 
   54     m_Simulation(simulation), m_Dirty(true), m_Texture(0), m_smoothFbo(0), m_MapSize(0), m_TextureSize(0), whichTex(true)
 
   67             LOGERROR(L
"Failed to load SmoothLOS shader, disabling.");
 
  126     glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &originalFBO);
 
  128     pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 
m_smoothFbo);
 
  129     pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 
 
  132     GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
 
  133     if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
 
  135         LOGWARNING(L
"LOS framebuffer object incomplete: 0x%04X", status);
 
  145     shader->BindTexture(str_losTex1, 
m_Texture);
 
  148     shader->Uniform(str_delta, (
float)
g_Renderer.GetTimeManager().GetFrameDelta() * 4.0f, 0.0f, 0.0f, 0.0f);
 
  150     glPushAttrib(GL_VIEWPORT_BIT); 
 
  154         glColor4f(1.f, 1.f, 1.f, 1.f);
 
  155         glTexCoord2f(1.0, 1.0); glVertex2f(1,1);
 
  156         glTexCoord2f(0.0, 1.0); glVertex2f(-1,1);       
 
  157         glTexCoord2f(0.0, 0.0); glVertex2f(-1,-1);
 
  158         glTexCoord2f(1.0, 0.0); glVertex2f(1,-1);
 
  165     pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0);
 
  167     pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, originalFBO);
 
  219         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_TextureSize, m_TextureSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texData);
 
  220         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
  221         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
  222         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 
  223         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
  226         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_TextureSize, m_TextureSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texData);
 
  227         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
  228         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
  229         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 
  230         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
  234     glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, m_TextureSize, m_TextureSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texData);
 
  235     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
  236     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
  237     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 
  238     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
  262         float s = 
m_MapSize / (float)m_TextureSize;
 
  280     bool recreated = 
false;
 
  287     PROFILE(
"recompute LOS texture");
 
  289     std::vector<u8> losData;
 
  293     if (!cmpRangeManager)
 
  321     u8 *dataPtr = losData;
 
  324     for (
size_t j = 0; j < g_BlurSize/2; ++j)
 
  325         for (
size_t i = 0; i < rowSize; ++i)
 
  328     for (
size_t j = 0; j < h; ++j)
 
  331         for (
size_t i = 0; i < g_BlurSize/2; ++i)
 
  335         for (
size_t i = 0; i < w; ++i)
 
  346         for (
size_t i = 0; i < g_BlurSize/2; ++i)
 
  351     for (
size_t j = 0; j < g_BlurSize/2; ++j)
 
  352         for (
size_t i = 0; i < rowSize; ++i)
 
  357     for (
size_t j = g_BlurSize/2; j < h + g_BlurSize/2; ++j)
 
  359         for (
size_t i = 0; i < w; ++i)
 
  361             u8* d = &losData[i+j*rowSize];
 
  376     for (
size_t j = 0; j < h; ++j)
 
  378         for (
size_t i = 0; i < w; ++i)
 
  380             u8* d = &losData[i+j*rowSize];
 
bool IsVisible_UncheckedRange(ssize_t i, ssize_t j)
Returns whether the given vertex is visible (i.e. 
 
void RecomputeTexture(int unit)
 
virtual CLosQuerier GetLosQuerier(player_id_t player)=0
Returns a CLosQuerier for checking whether vertex positions are visible to the given player (or other...
 
CLOSTexture(CSimulation2 &simulation)
 
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z 
 
CMatrix3D m_MinimapTextureMatrix
 
GLuint GetTextureSmooth()
 
void GenerateBitmap(ICmpRangeManager::CLosQuerier los, u8 *losData, size_t w, size_t h)
 
CShaderTechniquePtr m_smoothShader
 
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton 'system' components. 
 
Public API for simulation system. 
 
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero. 
 
T round_up_to_pow2(T x)
round up to next larger power of two. 
 
bool IsExplored_UncheckedRange(ssize_t i, ssize_t j)
Returns whether the given vertex is explored (i.e. 
 
CSimulation2 & m_Simulation
 
GLuint GetTexture()
Recomputes the LOS texture if necessary, and returns the texture handle. 
 
void MakeDirty()
Marks the LOS texture as needing recomputation. 
 
CGame * g_Game
Globally accessible pointer to the CGame object. 
 
virtual u16 GetVerticesPerSide()=0
Returns number of vertices per side on the terrain. 
 
size_t GetBitmapSize(size_t w, size_t h)
 
static bool IsInitialised()
 
A simplified syntax for accessing entity components. 
 
void ConstructTexture(int unit)
 
const float * GetMinimapTextureMatrix()
Returns a matrix to map (0,0)-(1,1) texture coordinates onto LOS texture coordinates, in the form expected by glLoadMatrixf. 
 
CMatrix3D m_TextureMatrix
 
Object providing efficient abstracted access to the LOS state. 
 
void BindTexture(int unit)
Recomputes the LOS texture if necessary, and binds it to the requested texture unit. 
 
static const size_t g_BlurSize
 
const CMatrix3D & GetTextureMatrix()
Returns a matrix to map (x,y,z) world coordinates onto (u,v) LOS texture coordinates, in the form expected by glLoadMatrixf. 
 
shared_ptr< CShaderProgram > CShaderProgramPtr