2014-11-16 17:57:42 +00:00
|
|
|
|
|
|
|
#include "C4Include.h"
|
|
|
|
#include "C4FoWDrawStrategy.h"
|
|
|
|
#include "C4FoWLight.h"
|
|
|
|
#include "C4FoWRegion.h"
|
|
|
|
#include "C4DrawGL.h"
|
|
|
|
|
|
|
|
|
|
|
|
void C4FoWDrawLightTextureStrategy::Begin(int32_t passPar)
|
|
|
|
{
|
|
|
|
pass = passPar;
|
|
|
|
|
|
|
|
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
|
|
|
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE);
|
|
|
|
if(pass == 0)
|
|
|
|
{
|
|
|
|
glBlendEquation( GL_FUNC_ADD );
|
|
|
|
}
|
|
|
|
else if(pass == 1)
|
|
|
|
{
|
|
|
|
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawLightTextureStrategy::End(int32_t pass)
|
|
|
|
{
|
|
|
|
glBlendEquation( GL_FUNC_ADD );
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawLightTextureStrategy::DrawVertex(float x, float y, bool shadeLight)
|
|
|
|
{
|
|
|
|
if(pass == 0)
|
|
|
|
{
|
|
|
|
float dx = x - light->getX();
|
|
|
|
float dy = y - light->getY();
|
|
|
|
float dist = sqrt(dx*dx+dy*dy);
|
2014-11-21 14:32:33 +00:00
|
|
|
float mult = Min(0.5f / light->getNormalSize(), 0.5f / dist);
|
2015-02-12 22:05:55 +00:00
|
|
|
float normX = Clamp(0.5f + dx * mult, 0.0f, 1.0f) / 1.5f;
|
|
|
|
float normY = Clamp(0.5f + dy * mult, 0.0f, 1.0f) / 1.5f;
|
2014-11-20 20:48:46 +00:00
|
|
|
if(shadeLight) glColor3f(0.5f, normX, normY);
|
2015-01-15 11:30:29 +00:00
|
|
|
else glColor3f(0.0f, 0.5f/1.5f, 0.5f/1.5f);
|
2014-11-16 17:57:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-20 20:48:46 +00:00
|
|
|
glColor3f(0.0f, 0.5f/1.5f, 0.5f/1.5f);
|
2014-11-16 17:57:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// global coords -> region coords
|
|
|
|
x += -region->getRegion().x;
|
|
|
|
y += -region->getRegion().y;
|
|
|
|
|
|
|
|
glVertex2f(x,y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawLightTextureStrategy::DrawDarkVertex(float x, float y)
|
|
|
|
{
|
|
|
|
DrawVertex(x,y, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawLightTextureStrategy::DrawLightVertex(float x, float y)
|
|
|
|
{
|
|
|
|
DrawVertex(x,y, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawWireframeStrategy::Begin(int32_t pass)
|
|
|
|
{
|
|
|
|
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawWireframeStrategy::End(int32_t pass)
|
|
|
|
{
|
|
|
|
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
|
|
|
glBlendEquation( GL_FUNC_ADD );
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawWireframeStrategy::DrawVertex(float x, float y)
|
|
|
|
{
|
|
|
|
// global coords -> screen pos and zoom
|
|
|
|
x += screen->X - screen->TargetX;
|
|
|
|
y += screen->Y - screen->TargetY;
|
|
|
|
pGL->ApplyZoom(x,y);
|
|
|
|
glVertex2f(x,y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawWireframeStrategy::DrawDarkVertex(float x, float y)
|
|
|
|
{
|
|
|
|
if(!draw) return;
|
|
|
|
glColor3f(0.5f, 0.5f, 0.0f);
|
|
|
|
DrawVertex(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void C4FoWDrawWireframeStrategy::DrawLightVertex(float x, float y)
|
|
|
|
{
|
|
|
|
if(!draw) return;
|
|
|
|
glColor3f(1.0f, 0.0f, 0.0f);
|
|
|
|
DrawVertex(x, y);
|
|
|
|
}
|
|
|
|
|