- added initial work to better manage rendering (but not yet enabled)
- added new commandline parameter: --version - some thread cleanup to try adjusted timings when threads shutdown
This commit is contained in:
parent
5356a3de23
commit
c7c9e69567
|
@ -26,7 +26,7 @@ using namespace Shared::Platform;
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
const string mailString= "contact_game@glest.org";
|
const string mailString= "contact_game@glest.org";
|
||||||
const string glestVersionString= "v3.3.5-beta7";
|
const string glestVersionString= "v3.3.5-beta7.1";
|
||||||
|
|
||||||
string getCrashDumpFileName(){
|
string getCrashDumpFileName(){
|
||||||
return "glest" + glestVersionString + ".dmp";
|
return "glest" + glestVersionString + ".dmp";
|
||||||
|
|
|
@ -33,7 +33,7 @@ using namespace Shared::Platform;
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
// if FPS is less than this we start to skip 3D renders
|
// if FPS is less than this we start to skip 3D renders
|
||||||
int MIN_RENDER_FPS_ALLOWED = 15;
|
//int MIN_RENDER_FPS_ALLOWED = 15;
|
||||||
|
|
||||||
Game *thisGamePtr = NULL;
|
Game *thisGamePtr = NULL;
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ Game::Game(Program *program, const GameSettings *gameSettings):
|
||||||
this->gameSettings= *gameSettings;
|
this->gameSettings= *gameSettings;
|
||||||
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
||||||
|
|
||||||
MIN_RENDER_FPS_ALLOWED = Config::getInstance().getInt("MIN_RENDER_FPS_ALLOWED",intToStr(MIN_RENDER_FPS_ALLOWED).c_str());
|
//MIN_RENDER_FPS_ALLOWED = Config::getInstance().getInt("MIN_RENDER_FPS_ALLOWED",intToStr(MIN_RENDER_FPS_ALLOWED).c_str());
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] MIN_RENDER_FPS_ALLOWED = %d\n",__FILE__,__FUNCTION__,__LINE__,MIN_RENDER_FPS_ALLOWED);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] MIN_RENDER_FPS_ALLOWED = %d\n",__FILE__,__FUNCTION__,__LINE__,MIN_RENDER_FPS_ALLOWED);
|
||||||
|
|
||||||
mouseX=0;
|
mouseX=0;
|
||||||
mouseY=0;
|
mouseY=0;
|
||||||
|
@ -169,7 +169,7 @@ void Game::load(){
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
if(loadingImageUsed == false){
|
if(loadingImageUsed == false){
|
||||||
// try to use a faction related loading screen
|
// try to use a faction related loading screen
|
||||||
|
@ -249,7 +249,7 @@ void Game::load(){
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ void Game::load(){
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ void Game::load(){
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ void Game::load(){
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
|
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -315,19 +315,19 @@ void Game::init()
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
world.init(this, gameSettings.getDefaultUnits());
|
world.init(this, gameSettings.getDefaultUnits());
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
gui.init(this);
|
gui.init(this);
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
chatManager.init(&console, world.getThisTeamIndex());
|
chatManager.init(&console, world.getThisTeamIndex());
|
||||||
console.clearStoredLines();
|
console.clearStoredLines();
|
||||||
|
@ -337,7 +337,7 @@ void Game::init()
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
scriptManager.init(&world, &gameCamera);
|
scriptManager.init(&world, &gameCamera);
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ void Game::init()
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
//wheather particle systems
|
//wheather particle systems
|
||||||
if(world.getTileset()->getWeather() == wRainy){
|
if(world.getTileset()->getWeather() == wRainy){
|
||||||
|
@ -388,7 +388,7 @@ void Game::init()
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
//sounds
|
//sounds
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
|
@ -442,6 +442,8 @@ void Game::update(){
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Chrono chrono;
|
||||||
|
chrono.start();
|
||||||
|
|
||||||
// a) Updates non dependent on speed
|
// a) Updates non dependent on speed
|
||||||
|
|
||||||
|
@ -459,6 +461,8 @@ void Game::update(){
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
//update
|
//update
|
||||||
for(int i=0; i<updateLoops; ++i){
|
for(int i=0; i<updateLoops; ++i){
|
||||||
|
@ -475,18 +479,22 @@ void Game::update(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//World
|
//World
|
||||||
world.update();
|
world.update();
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
// Commander
|
// Commander
|
||||||
commander.updateNetwork();
|
commander.updateNetwork();
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//Gui
|
//Gui
|
||||||
gui.update();
|
gui.update();
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//Particle systems
|
//Particle systems
|
||||||
|
@ -496,6 +504,7 @@ void Game::update(){
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
renderer.updateParticleManager(rsGame);
|
renderer.updateParticleManager(rsGame);
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
|
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
@ -552,9 +561,9 @@ void Game::renderWorker() {
|
||||||
//program->getWindow()->makeCurrentGl();
|
//program->getWindow()->makeCurrentGl();
|
||||||
|
|
||||||
//renderFps++;
|
//renderFps++;
|
||||||
if(renderFps >= MIN_RENDER_FPS_ALLOWED) {
|
//if(renderFps >= MIN_RENDER_FPS_ALLOWED) {
|
||||||
render3d();
|
render3d();
|
||||||
}
|
//}
|
||||||
//if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
//if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -1048,7 +1057,7 @@ void Game::render3d(){
|
||||||
//shadow map
|
//shadow map
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
chrono.start();
|
chrono.start();
|
||||||
renderer.renderShadowsToTexture();
|
renderer.renderShadowsToTexture(renderFps);
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
|
|
||||||
//clear buffers
|
//clear buffers
|
||||||
|
@ -1072,13 +1081,13 @@ void Game::render3d(){
|
||||||
//units
|
//units
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
chrono.start();
|
chrono.start();
|
||||||
renderer.renderUnits();
|
renderer.renderUnits(renderFps,world.getFrameCount());
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
|
|
||||||
//objects
|
//objects
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
chrono.start();
|
chrono.start();
|
||||||
renderer.renderObjects();
|
renderer.renderObjects(renderFps,world.getFrameCount());
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
|
|
||||||
//water
|
//water
|
||||||
|
@ -1165,6 +1174,36 @@ void Game::render2d(){
|
||||||
str+= "\n";
|
str+= "\n";
|
||||||
str+= "Visible quad area: " + floatToStr(visibleQuad.area()) +"\n";
|
str+= "Visible quad area: " + floatToStr(visibleQuad.area()) +"\n";
|
||||||
|
|
||||||
|
int visibleUnitCount = 0;
|
||||||
|
for(int i=0; i< world.getFactionCount(); ++i){
|
||||||
|
for(int j=0; j< world.getFaction(i)->getUnitCount(); ++j){
|
||||||
|
Unit *unit = world.getFaction(i)->getUnit(j);
|
||||||
|
if(world.toRenderUnit(unit, visibleQuad)) {
|
||||||
|
visibleUnitCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
str+= "Visible unit count: " + intToStr(visibleUnitCount) +"\n";
|
||||||
|
|
||||||
|
int visibleObjectCount = 0;
|
||||||
|
Map *map= world.getMap();
|
||||||
|
int thisTeamIndex= world.getThisTeamIndex();
|
||||||
|
PosQuadIterator pqi(map, visibleQuad, Map::cellScale);
|
||||||
|
while(pqi.next()){
|
||||||
|
const Vec2i &pos= pqi.getPos();
|
||||||
|
bool isPosVisible = map->isInside(pos.x, pos.y);
|
||||||
|
if(isPosVisible == true) {
|
||||||
|
Vec2i mapPos = Map::toSurfCoords(pos);
|
||||||
|
SurfaceCell *sc= map->getSurfaceCell(mapPos.x, mapPos.y);
|
||||||
|
Object *o= sc->getObject();
|
||||||
|
bool isExplored = (sc->isExplored(thisTeamIndex) && o!=NULL);
|
||||||
|
if(isExplored == true) {
|
||||||
|
visibleObjectCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
str+= "Visible object count: " + intToStr(visibleObjectCount) +"\n";
|
||||||
|
|
||||||
// resources
|
// resources
|
||||||
for(int i=0; i<world.getFactionCount(); ++i){
|
for(int i=0; i<world.getFactionCount(); ++i){
|
||||||
str+= "Player "+intToStr(i)+" res: ";
|
str+= "Player "+intToStr(i)+" res: ";
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "faction.h"
|
#include "faction.h"
|
||||||
#include "factory_repository.h"
|
#include "factory_repository.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
@ -40,6 +41,24 @@ namespace Glest { namespace Game{
|
||||||
|
|
||||||
bool MeshCallbackTeamColor::noTeamColors = false;
|
bool MeshCallbackTeamColor::noTeamColors = false;
|
||||||
|
|
||||||
|
// if FPS is less than this we start to skip 3D renders
|
||||||
|
int MIN_RENDER_FPS_ALLOWED = -1;
|
||||||
|
int MIN_RENDER_LAG_ALLOWED = 1;
|
||||||
|
int MAX_RENDER_LAG_ITEMCOUNT_ALLOWED = 60;
|
||||||
|
|
||||||
|
bool RenderEntity::operator<(const RenderEntity &rhs) const {
|
||||||
|
if(this->type == retUnit || this->type == retUnitFast) {
|
||||||
|
return(this->unit->getLastRenderFrame() < rhs.unit->getLastRenderFrame());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return(this->o->getLastRenderFrame() < rhs.o->getLastRenderFrame());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RenderEntity::operator()(const RenderEntity &lhs,const RenderEntity &rhs) const {
|
||||||
|
return lhs < lhs;
|
||||||
|
}
|
||||||
|
|
||||||
void MeshCallbackTeamColor::execute(const Mesh *mesh){
|
void MeshCallbackTeamColor::execute(const Mesh *mesh){
|
||||||
|
|
||||||
//team color
|
//team color
|
||||||
|
@ -1244,95 +1263,99 @@ void Renderer::renderSurface(){
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderObjects() {
|
void Renderer::renderObjects(const int renderFps, const int worldFrameCount) {
|
||||||
const World *world= game->getWorld();
|
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||||
const Map *map= world->getMap();
|
renderObjectsFast();
|
||||||
|
|
||||||
assertGl();
|
|
||||||
const Texture2D *fowTex= world->getMinimap()->getFowTexture();
|
|
||||||
Vec3f baseFogColor= world->getTileset()->getFogColor()*computeLightColor(world->getTimeFlow()->getTime());
|
|
||||||
|
|
||||||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_FOG_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
|
|
||||||
|
|
||||||
if(shadows==sShadowMapping){
|
|
||||||
glActiveTexture(shadowTexUnit);
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, shadowMapHandle);
|
|
||||||
|
|
||||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
|
||||||
enableProjectiveTexturing();
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
const World *world= game->getWorld();
|
||||||
|
const Map *map= world->getMap();
|
||||||
|
|
||||||
glActiveTexture(baseTexUnit);
|
assertGl();
|
||||||
|
const Texture2D *fowTex= world->getMinimap()->getFowTexture();
|
||||||
|
Vec3f baseFogColor= world->getTileset()->getFogColor()*computeLightColor(world->getTimeFlow()->getTime());
|
||||||
|
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_FOG_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
|
||||||
glAlphaFunc(GL_GREATER, 0.5f);
|
|
||||||
|
|
||||||
//modelRenderer->begin(true, true, false);
|
if(shadows==sShadowMapping){
|
||||||
int thisTeamIndex= world->getThisTeamIndex();
|
glActiveTexture(shadowTexUnit);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
std::vector<RenderEntity> vctEntity;
|
glBindTexture(GL_TEXTURE_2D, shadowMapHandle);
|
||||||
|
|
||||||
PosQuadIterator pqi(map, visibleQuad, Map::cellScale);
|
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||||
while(pqi.next()){
|
enableProjectiveTexturing();
|
||||||
const Vec2i &pos= pqi.getPos();
|
}
|
||||||
bool isPosVisible = map->isInside(pos.x, pos.y);
|
|
||||||
if(isPosVisible == true) {
|
|
||||||
Vec2i mapPos = Map::toSurfCoords(pos);
|
|
||||||
SurfaceCell *sc= map->getSurfaceCell(mapPos.x, mapPos.y);
|
|
||||||
Object *o= sc->getObject();
|
|
||||||
bool isExplored = (sc->isExplored(thisTeamIndex) && o!=NULL);
|
|
||||||
if(isExplored == true) {
|
|
||||||
|
|
||||||
|
glActiveTexture(baseTexUnit);
|
||||||
|
|
||||||
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
glAlphaFunc(GL_GREATER, 0.5f);
|
||||||
|
|
||||||
|
//modelRenderer->begin(true, true, false);
|
||||||
|
int thisTeamIndex= world->getThisTeamIndex();
|
||||||
|
|
||||||
|
std::vector<RenderEntity> vctEntity;
|
||||||
|
|
||||||
|
PosQuadIterator pqi(map, visibleQuad, Map::cellScale);
|
||||||
|
while(pqi.next()){
|
||||||
|
const Vec2i &pos= pqi.getPos();
|
||||||
|
bool isPosVisible = map->isInside(pos.x, pos.y);
|
||||||
|
if(isPosVisible == true) {
|
||||||
|
Vec2i mapPos = Map::toSurfCoords(pos);
|
||||||
|
SurfaceCell *sc= map->getSurfaceCell(mapPos.x, mapPos.y);
|
||||||
|
Object *o= sc->getObject();
|
||||||
|
bool isExplored = (sc->isExplored(thisTeamIndex) && o!=NULL);
|
||||||
|
if(isExplored == true) {
|
||||||
|
/*
|
||||||
|
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||||
|
int renderLag = worldFrameCount - o->getLastRenderFrame();
|
||||||
|
if(renderLag > MIN_RENDER_LAG_ALLOWED) {
|
||||||
|
vctEntity.push_back(RenderEntity(retObject,o,mapPos,NULL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*/
|
||||||
|
vctEntity.push_back(RenderEntity(retObject,o,mapPos,NULL));
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modelRenderer->begin(true, true, false);
|
||||||
|
renderObjectList(vctEntity,baseFogColor,renderFps, worldFrameCount);
|
||||||
|
modelRenderer->end();
|
||||||
|
|
||||||
|
//restore
|
||||||
|
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::renderObjectList(std::vector<RenderEntity> &vctEntity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount) {
|
||||||
|
// Need to do something to manage bad FPS
|
||||||
/*
|
/*
|
||||||
const Model *objModel= o->getModel();
|
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||||
const Vec3f &v= o->getConstPos();
|
// Oldest rendered objects go to top
|
||||||
|
std::sort(vctEntity.begin(), vctEntity.end());
|
||||||
|
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
||||||
|
RenderEntity &entity = vctEntity[idx];
|
||||||
|
prepareObjectForRender(entity);
|
||||||
|
renderObject(entity,baseFogColor,renderFps, worldFrameCount);
|
||||||
|
|
||||||
//ambient and diffuse color is taken from cell color
|
if(idx >= MAX_RENDER_LAG_ITEMCOUNT_ALLOWED) {
|
||||||
//float fowFactor= fowTex->getPixmap()->getPixelf(pos.x/Map::cellScale, pos.y/Map::cellScale);
|
break;
|
||||||
float fowFactor= fowTex->getPixmap()->getPixelf(mapPos.x,mapPos.y);
|
|
||||||
|
|
||||||
Vec4f color= Vec4f(Vec3f(fowFactor), 1.f);
|
|
||||||
glColor4fv(color.ptr());
|
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (color*ambFactor).ptr());
|
|
||||||
glFogfv(GL_FOG_COLOR, (baseFogColor*fowFactor).ptr());
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(v.x, v.y, v.z);
|
|
||||||
glRotatef(o->getRotation(), 0.f, 1.f, 0.f);
|
|
||||||
|
|
||||||
objModel->updateInterpolationData(0.f, true);
|
|
||||||
|
|
||||||
modelRenderer->render(objModel);
|
|
||||||
|
|
||||||
triangleCount+= objModel->getTriangleCount();
|
|
||||||
pointCount+= objModel->getVertexCount();
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
*/
|
|
||||||
|
|
||||||
vctEntity.push_back(RenderEntity(retObject,o,mapPos,NULL));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
modelRenderer->begin(true, true, false);
|
*/
|
||||||
renderObjectList(vctEntity,baseFogColor);
|
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
||||||
modelRenderer->end();
|
RenderEntity &entity = vctEntity[idx];
|
||||||
|
prepareObjectForRender(entity);
|
||||||
//restore
|
renderObject(entity,baseFogColor,renderFps, worldFrameCount);
|
||||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
}
|
||||||
glPopAttrib();
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::renderObjectList(std::vector<RenderEntity> &vctEntity,const Vec3f &baseFogColor) {
|
|
||||||
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
|
||||||
RenderEntity &entity = vctEntity[idx];
|
|
||||||
prepareObjectForRender(entity);
|
|
||||||
renderObject(entity,baseFogColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::prepareObjectForRender(RenderEntity &entity) {
|
void Renderer::prepareObjectForRender(RenderEntity &entity) {
|
||||||
|
@ -1346,7 +1369,7 @@ void Renderer::prepareObjectForRender(RenderEntity &entity) {
|
||||||
entity.setState(resInterpolated);
|
entity.setState(resInterpolated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderObject(RenderEntity &entity,const Vec3f &baseFogColor) {
|
void Renderer::renderObject(RenderEntity &entity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount) {
|
||||||
Object *o = entity.o;
|
Object *o = entity.o;
|
||||||
Vec2i &mapPos = entity.mapPos;
|
Vec2i &mapPos = entity.mapPos;
|
||||||
if(o != NULL) {
|
if(o != NULL) {
|
||||||
|
@ -1374,6 +1397,7 @@ void Renderer::renderObject(RenderEntity &entity,const Vec3f &baseFogColor) {
|
||||||
//objModel->updateInterpolationData(0.f, true);
|
//objModel->updateInterpolationData(0.f, true);
|
||||||
|
|
||||||
modelRenderer->render(objModel);
|
modelRenderer->render(objModel);
|
||||||
|
o->setLastRenderFrame(worldFrameCount);
|
||||||
|
|
||||||
triangleCount+= objModel->getTriangleCount();
|
triangleCount+= objModel->getTriangleCount();
|
||||||
pointCount+= objModel->getVertexCount();
|
pointCount+= objModel->getVertexCount();
|
||||||
|
@ -1510,8 +1534,7 @@ void Renderer::renderWater(){
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderUnits(){
|
void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
|
||||||
Unit *unit;
|
|
||||||
const World *world= game->getWorld();
|
const World *world= game->getWorld();
|
||||||
MeshCallbackTeamColor meshCallbackTeamColor;
|
MeshCallbackTeamColor meshCallbackTeamColor;
|
||||||
|
|
||||||
|
@ -1535,58 +1558,27 @@ void Renderer::renderUnits(){
|
||||||
std::vector<RenderEntity> vctEntity;
|
std::vector<RenderEntity> vctEntity;
|
||||||
|
|
||||||
for(int i=0; i<world->getFactionCount(); ++i){
|
for(int i=0; i<world->getFactionCount(); ++i){
|
||||||
// meshCallbackTeamColor.setTeamTexture(world->getFaction(i)->getTexture());
|
|
||||||
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
|
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
|
||||||
unit= world->getFaction(i)->getUnit(j);
|
Unit *unit = world->getFaction(i)->getUnit(j);
|
||||||
if(world->toRenderUnit(unit, visibleQuad)) {
|
if(world->toRenderUnit(unit, visibleQuad)) {
|
||||||
|
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||||
/*
|
int unitRenderLag = worldFrameCount - unit->getLastRenderFrame();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
if(unitRenderLag > MIN_RENDER_LAG_ALLOWED) {
|
||||||
glPushMatrix();
|
vctEntity.push_back(RenderEntity(retUnit,NULL,Vec2i(),unit,world->getFaction(i)->getTexture()));
|
||||||
|
}
|
||||||
//translate
|
|
||||||
Vec3f currVec= unit->getCurrVectorFlat();
|
|
||||||
glTranslatef(currVec.x, currVec.y, currVec.z);
|
|
||||||
|
|
||||||
//rotate
|
|
||||||
glRotatef(unit->getRotation(), 0.f, 1.f, 0.f);
|
|
||||||
glRotatef(unit->getVerticalRotation(), 1.f, 0.f, 0.f);
|
|
||||||
|
|
||||||
//dead alpha
|
|
||||||
float alpha= 1.0f;
|
|
||||||
const SkillType *st= unit->getCurrSkill();
|
|
||||||
if(st->getClass()==scDie && static_cast<const DieSkillType*>(st)->getFade()){
|
|
||||||
alpha= 1.0f-unit->getAnimProgress();
|
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr());
|
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
vctEntity.push_back(RenderEntity(retUnit,NULL,Vec2i(),unit,world->getFaction(i)->getTexture()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//render
|
|
||||||
const Model *model= unit->getCurrentModel();
|
|
||||||
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive());
|
|
||||||
|
|
||||||
modelRenderer->render(model);
|
|
||||||
triangleCount+= model->getTriangleCount();
|
|
||||||
pointCount+= model->getVertexCount();
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
unit->setVisible(true);
|
|
||||||
*/
|
|
||||||
|
|
||||||
vctEntity.push_back(RenderEntity(retUnit,NULL,Vec2i(),unit,world->getFaction(i)->getTexture()));
|
|
||||||
}
|
}
|
||||||
else
|
else if(unit->getVisible() == true){
|
||||||
{
|
|
||||||
unit->setVisible(false);
|
unit->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modelRenderer->begin(true, true, true, &meshCallbackTeamColor);
|
modelRenderer->begin(true, true, true, &meshCallbackTeamColor);
|
||||||
renderUnitList(vctEntity,&meshCallbackTeamColor);
|
renderUnitList(vctEntity,&meshCallbackTeamColor,renderFps, worldFrameCount);
|
||||||
modelRenderer->end();
|
modelRenderer->end();
|
||||||
|
|
||||||
//restore
|
//restore
|
||||||
|
@ -1597,15 +1589,31 @@ void Renderer::renderUnits(){
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderUnitList(std::vector<RenderEntity> &vctEntity,MeshCallbackTeamColor *meshCallbackTeamColor) {
|
void Renderer::renderUnitList(std::vector<RenderEntity> &vctEntity,MeshCallbackTeamColor *meshCallbackTeamColor,const int renderFps, const int worldFrameCount) {
|
||||||
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
// Need to do something to manage bad FPS
|
||||||
RenderEntity &entity = vctEntity[idx];
|
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||||
prepareUnitForRender(entity);
|
// Oldest rendered units go to top
|
||||||
renderUnit(entity,meshCallbackTeamColor);
|
std::sort(vctEntity.begin(), vctEntity.end());
|
||||||
|
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
||||||
|
RenderEntity &entity = vctEntity[idx];
|
||||||
|
prepareUnitForRender(entity);
|
||||||
|
renderUnit(entity,meshCallbackTeamColor,renderFps, worldFrameCount);
|
||||||
|
|
||||||
|
if(idx >= MAX_RENDER_LAG_ITEMCOUNT_ALLOWED) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
||||||
|
RenderEntity &entity = vctEntity[idx];
|
||||||
|
prepareUnitForRender(entity);
|
||||||
|
renderUnit(entity,meshCallbackTeamColor,renderFps, worldFrameCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderUnit(RenderEntity &entity,MeshCallbackTeamColor *meshCallbackTeamColor) {
|
void Renderer::renderUnit(RenderEntity &entity,MeshCallbackTeamColor *meshCallbackTeamColor,const int renderFps, const int worldFrameCount) {
|
||||||
Unit *unit = entity.unit;
|
Unit *unit = entity.unit;
|
||||||
if(unit != NULL) {
|
if(unit != NULL) {
|
||||||
if(meshCallbackTeamColor != NULL) {
|
if(meshCallbackTeamColor != NULL) {
|
||||||
|
@ -1640,11 +1648,13 @@ void Renderer::renderUnit(RenderEntity &entity,MeshCallbackTeamColor *meshCallba
|
||||||
//model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive());
|
//model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive());
|
||||||
|
|
||||||
modelRenderer->render(model);
|
modelRenderer->render(model);
|
||||||
|
unit->setLastRenderFrame(worldFrameCount);
|
||||||
triangleCount+= model->getTriangleCount();
|
triangleCount+= model->getTriangleCount();
|
||||||
pointCount+= model->getVertexCount();
|
pointCount+= model->getVertexCount();
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
unit->setVisible(true);
|
unit->setVisible(true);
|
||||||
|
|
||||||
if(allowRenderUnitTitles == true) {
|
if(allowRenderUnitTitles == true) {
|
||||||
// Add to the pending render unit title list
|
// Add to the pending render unit title list
|
||||||
renderUnitTitleList.push_back(std::pair<Unit *,Vec3f>(unit,computeScreenPosition(unit->getCurrVectorFlat())) );
|
renderUnitTitleList.push_back(std::pair<Unit *,Vec3f>(unit,computeScreenPosition(unit->getCurrVectorFlat())) );
|
||||||
|
@ -2295,163 +2305,165 @@ void Renderer::computeSelected(Selection::UnitContainer &units, const Vec2i &pos
|
||||||
|
|
||||||
// ==================== shadows ====================
|
// ==================== shadows ====================
|
||||||
|
|
||||||
void Renderer::renderShadowsToTexture(){
|
void Renderer::renderShadowsToTexture(const int renderFps){
|
||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
if(shadows==sProjected || shadows==sShadowMapping){
|
if(renderFps >= MIN_RENDER_FPS_ALLOWED) {
|
||||||
|
if(shadows==sProjected || shadows==sShadowMapping){
|
||||||
|
|
||||||
shadowMapFrame= (shadowMapFrame + 1) % (shadowFrameSkip + 1);
|
shadowMapFrame= (shadowMapFrame + 1) % (shadowFrameSkip + 1);
|
||||||
|
|
||||||
if(shadowMapFrame==0){
|
if(shadowMapFrame==0){
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_VIEWPORT_BIT | GL_POLYGON_BIT);
|
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_VIEWPORT_BIT | GL_POLYGON_BIT);
|
||||||
|
|
||||||
if(shadows==sShadowMapping){
|
if(shadows==sShadowMapping){
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
|
||||||
else{
|
|
||||||
float color= 1.0f-shadowAlpha;
|
|
||||||
glColor3f(color, color, color);
|
|
||||||
glClearColor(1.f, 1.f, 1.f, 1.f);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
chrono.start();
|
|
||||||
|
|
||||||
//clear color buffer
|
|
||||||
//
|
|
||||||
//set viewport, we leave one texel always in white to avoid problems
|
|
||||||
glViewport(1, 1, shadowTextureSize-2, shadowTextureSize-2);
|
|
||||||
|
|
||||||
if(nearestLightPos.w==0.f){
|
|
||||||
//directional light
|
|
||||||
|
|
||||||
//light pos
|
|
||||||
assert(game != NULL);
|
|
||||||
assert(game->getWorld() != NULL);
|
|
||||||
const TimeFlow *tf= game->getWorld()->getTimeFlow();
|
|
||||||
assert(tf != NULL);
|
|
||||||
float ang= tf->isDay()? computeSunAngle(tf->getTime()): computeMoonAngle(tf->getTime());
|
|
||||||
ang= radToDeg(ang);
|
|
||||||
|
|
||||||
//push and set projection
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
if(game->getGameCamera()->getState()==GameCamera::sGame){
|
|
||||||
glOrtho(-35, 5, -15, 15, -1000, 1000);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
glOrtho(-30, 30, -20, 20, -1000, 1000);
|
float color= 1.0f-shadowAlpha;
|
||||||
|
glColor3f(color, color, color);
|
||||||
|
glClearColor(1.f, 1.f, 1.f, 1.f);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//push and set modelview
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
glMatrixMode(GL_MODELVIEW);
|
chrono.start();
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
glRotatef(15, 0, 1, 0);
|
//clear color buffer
|
||||||
|
//
|
||||||
|
//set viewport, we leave one texel always in white to avoid problems
|
||||||
|
glViewport(1, 1, shadowTextureSize-2, shadowTextureSize-2);
|
||||||
|
|
||||||
glRotatef(ang, 1, 0, 0);
|
if(nearestLightPos.w==0.f){
|
||||||
glRotatef(90, 0, 1, 0);
|
//directional light
|
||||||
Vec3f pos= game->getGameCamera()->getPos();
|
|
||||||
|
|
||||||
glTranslatef(static_cast<int>(-pos.x), 0, static_cast<int>(-pos.z));
|
//light pos
|
||||||
|
assert(game != NULL);
|
||||||
|
assert(game->getWorld() != NULL);
|
||||||
|
const TimeFlow *tf= game->getWorld()->getTimeFlow();
|
||||||
|
assert(tf != NULL);
|
||||||
|
float ang= tf->isDay()? computeSunAngle(tf->getTime()): computeMoonAngle(tf->getTime());
|
||||||
|
ang= radToDeg(ang);
|
||||||
|
|
||||||
|
//push and set projection
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
if(game->getGameCamera()->getState()==GameCamera::sGame){
|
||||||
|
glOrtho(-35, 5, -15, 15, -1000, 1000);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
glOrtho(-30, 30, -20, 20, -1000, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//push and set modelview
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glRotatef(15, 0, 1, 0);
|
||||||
|
|
||||||
|
glRotatef(ang, 1, 0, 0);
|
||||||
|
glRotatef(90, 0, 1, 0);
|
||||||
|
Vec3f pos= game->getGameCamera()->getPos();
|
||||||
|
|
||||||
|
glTranslatef(static_cast<int>(-pos.x), 0, static_cast<int>(-pos.z));
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
chrono.start();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//non directional light
|
||||||
|
|
||||||
|
//push projection
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
gluPerspective(150, 1.f, perspNearPlane, perspFarPlane);
|
||||||
|
|
||||||
|
//push modelview
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
glRotatef(-90, -1, 0, 0);
|
||||||
|
glTranslatef(-nearestLightPos.x, -nearestLightPos.y-2, -nearestLightPos.z);
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
chrono.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(shadows==sShadowMapping){
|
||||||
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
glPolygonOffset(1.0f, 0.001f);
|
||||||
|
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
chrono.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
//render 3d
|
||||||
|
renderUnitsFast();
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
chrono.start();
|
||||||
|
|
||||||
|
renderObjectsFast();
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
chrono.start();
|
||||||
|
|
||||||
|
//read color buffer
|
||||||
|
glBindTexture(GL_TEXTURE_2D, shadowMapHandle);
|
||||||
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, shadowTextureSize, shadowTextureSize);
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
chrono.start();
|
chrono.start();
|
||||||
}
|
|
||||||
else{
|
|
||||||
//non directional light
|
|
||||||
|
|
||||||
//push projection
|
//get elemental matrices
|
||||||
|
Matrix4f matrix1;
|
||||||
|
matrix1[0]= 0.5f; matrix1[4]= 0.f; matrix1[8]= 0.f; matrix1[12]= 0.5f;
|
||||||
|
matrix1[1]= 0.f; matrix1[5]= 0.5f; matrix1[9]= 0.f; matrix1[13]= 0.5f;
|
||||||
|
matrix1[2]= 0.f; matrix1[6]= 0.f; matrix1[10]= 0.5f; matrix1[14]= 0.5f;
|
||||||
|
matrix1[3]= 0.f; matrix1[7]= 0.f; matrix1[11]= 0.f; matrix1[15]= 1.f;
|
||||||
|
|
||||||
|
Matrix4f matrix2;
|
||||||
|
glGetFloatv(GL_PROJECTION_MATRIX, matrix2.ptr());
|
||||||
|
|
||||||
|
Matrix4f matrix3;
|
||||||
|
glGetFloatv(GL_MODELVIEW_MATRIX, matrix3.ptr());
|
||||||
|
|
||||||
|
//pop both matrices
|
||||||
|
glPopMatrix();
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
|
||||||
gluPerspective(150, 1.f, perspNearPlane, perspFarPlane);
|
|
||||||
|
|
||||||
//push modelview
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
glMatrixMode(GL_MODELVIEW);
|
chrono.start();
|
||||||
glPushMatrix();
|
|
||||||
glLoadIdentity();
|
//compute texture matrix
|
||||||
glRotatef(-90, -1, 0, 0);
|
glLoadMatrixf(matrix1.ptr());
|
||||||
glTranslatef(-nearestLightPos.x, -nearestLightPos.y-2, -nearestLightPos.z);
|
glMultMatrixf(matrix2.ptr());
|
||||||
|
glMultMatrixf(matrix3.ptr());
|
||||||
|
glGetFloatv(GL_TRANSPOSE_PROJECTION_MATRIX_ARB, shadowMapMatrix.ptr());
|
||||||
|
|
||||||
|
//pop
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPopAttrib();
|
||||||
|
|
||||||
|
assertGl();
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
chrono.start();
|
chrono.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shadows==sShadowMapping){
|
|
||||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
||||||
glPolygonOffset(1.0f, 0.001f);
|
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
chrono.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
//render 3d
|
|
||||||
renderUnitsFast();
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
chrono.start();
|
|
||||||
|
|
||||||
renderObjectsFast();
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
chrono.start();
|
|
||||||
|
|
||||||
//read color buffer
|
|
||||||
glBindTexture(GL_TEXTURE_2D, shadowMapHandle);
|
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, shadowTextureSize, shadowTextureSize);
|
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
chrono.start();
|
|
||||||
|
|
||||||
//get elemental matrices
|
|
||||||
Matrix4f matrix1;
|
|
||||||
matrix1[0]= 0.5f; matrix1[4]= 0.f; matrix1[8]= 0.f; matrix1[12]= 0.5f;
|
|
||||||
matrix1[1]= 0.f; matrix1[5]= 0.5f; matrix1[9]= 0.f; matrix1[13]= 0.5f;
|
|
||||||
matrix1[2]= 0.f; matrix1[6]= 0.f; matrix1[10]= 0.5f; matrix1[14]= 0.5f;
|
|
||||||
matrix1[3]= 0.f; matrix1[7]= 0.f; matrix1[11]= 0.f; matrix1[15]= 1.f;
|
|
||||||
|
|
||||||
Matrix4f matrix2;
|
|
||||||
glGetFloatv(GL_PROJECTION_MATRIX, matrix2.ptr());
|
|
||||||
|
|
||||||
Matrix4f matrix3;
|
|
||||||
glGetFloatv(GL_MODELVIEW_MATRIX, matrix3.ptr());
|
|
||||||
|
|
||||||
//pop both matrices
|
|
||||||
glPopMatrix();
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
chrono.start();
|
|
||||||
|
|
||||||
//compute texture matrix
|
|
||||||
glLoadMatrixf(matrix1.ptr());
|
|
||||||
glMultMatrixf(matrix2.ptr());
|
|
||||||
glMultMatrixf(matrix3.ptr());
|
|
||||||
glGetFloatv(GL_TRANSPOSE_PROJECTION_MATRIX_ARB, shadowMapMatrix.ptr());
|
|
||||||
|
|
||||||
//pop
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glPopAttrib();
|
|
||||||
|
|
||||||
assertGl();
|
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
chrono.start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2779,7 +2791,7 @@ void Renderer::prepareUnitFastForRender(RenderEntity &entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//render objects for selection purposes
|
//render objects for selection purposes
|
||||||
void Renderer::renderObjectsFast(){
|
void Renderer::renderObjectsFast() {
|
||||||
const World *world= game->getWorld();
|
const World *world= game->getWorld();
|
||||||
const Map *map= world->getMap();
|
const Map *map= world->getMap();
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,8 @@ public:
|
||||||
CopyAll(obj);
|
CopyAll(obj);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
bool operator<(const RenderEntity &rhs) const;
|
||||||
|
bool operator()(const RenderEntity &lhs,const RenderEntity &rhs) const;
|
||||||
|
|
||||||
RenderEntityType type;
|
RenderEntityType type;
|
||||||
Object *o;
|
Object *o;
|
||||||
|
@ -332,16 +334,16 @@ public:
|
||||||
|
|
||||||
//complex rendering
|
//complex rendering
|
||||||
void renderSurface();
|
void renderSurface();
|
||||||
void renderObjects();
|
void renderObjects(const int renderFps, const int worldFrameCount);
|
||||||
void renderObject(RenderEntity &entity,const Vec3f &baseFogColor);
|
void renderObject(RenderEntity &entity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount);
|
||||||
void prepareObjectForRender(RenderEntity &entity);
|
void prepareObjectForRender(RenderEntity &entity);
|
||||||
void renderObjectList(std::vector<RenderEntity> &vctEntity,const Vec3f &baseFogColor);
|
void renderObjectList(std::vector<RenderEntity> &vctEntity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount);
|
||||||
|
|
||||||
void renderWater();
|
void renderWater();
|
||||||
void renderUnits();
|
void renderUnits(const int renderFps, const int worldFrameCount);
|
||||||
void prepareUnitForRender(RenderEntity &entity);
|
void prepareUnitForRender(RenderEntity &entity);
|
||||||
void renderUnitList(std::vector<RenderEntity> &vctEntity,MeshCallbackTeamColor *meshCallbackTeamColor);
|
void renderUnitList(std::vector<RenderEntity> &vctEntity,MeshCallbackTeamColor *meshCallbackTeamColor,const int renderFps, const int worldFrameCount);
|
||||||
void renderUnit(RenderEntity &entity,MeshCallbackTeamColor *meshCallbackTeamColor);
|
void renderUnit(RenderEntity &entity,MeshCallbackTeamColor *meshCallbackTeamColor,const int renderFps, const int worldFrameCount);
|
||||||
|
|
||||||
void renderSelectionEffects();
|
void renderSelectionEffects();
|
||||||
void renderWaterEffects();
|
void renderWaterEffects();
|
||||||
|
@ -363,7 +365,7 @@ public:
|
||||||
void clearZBuffer();
|
void clearZBuffer();
|
||||||
|
|
||||||
//shadows
|
//shadows
|
||||||
void renderShadowsToTexture();
|
void renderShadowsToTexture(const int renderFps);
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
void loadConfig();
|
void loadConfig();
|
||||||
|
|
|
@ -265,6 +265,18 @@ void MainWindow::setProgram(Program *program) {
|
||||||
// =====================================================
|
// =====================================================
|
||||||
SystemFlags debugger;
|
SystemFlags debugger;
|
||||||
|
|
||||||
|
bool hasCommandArgument(int argc, char** argv,string argName) {
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
for(int idx = 1; idx < argc; idx++) {
|
||||||
|
if(stricmp(argName.c_str(),argv[idx]) == 0) {
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int glestMain(int argc, char** argv){
|
int glestMain(int argc, char** argv){
|
||||||
|
|
||||||
#ifdef SL_LEAK_DUMP
|
#ifdef SL_LEAK_DUMP
|
||||||
|
@ -279,6 +291,10 @@ int glestMain(int argc, char** argv){
|
||||||
printf("%s, STREFLOP NOT enabled.\n",getNetworkVersionString().c_str());
|
printf("%s, STREFLOP NOT enabled.\n",getNetworkVersionString().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(hasCommandArgument(argc, argv,"--version") == true) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::init();
|
SystemFlags::init();
|
||||||
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled = true;
|
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled = true;
|
||||||
SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled = true;
|
SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled = true;
|
||||||
|
|
|
@ -34,7 +34,7 @@ Object::Object(ObjectType *objectType, const Vec3f &pos){
|
||||||
RandomGen random;
|
RandomGen random;
|
||||||
|
|
||||||
random.init(static_cast<int>(pos.x*pos.z));
|
random.init(static_cast<int>(pos.x*pos.z));
|
||||||
|
this->lastRenderFrame = 0;
|
||||||
this->objectType= objectType;
|
this->objectType= objectType;
|
||||||
resource= NULL;
|
resource= NULL;
|
||||||
this->pos= pos + Vec3f(random.randRange(-0.6f, 0.6f), 0.0f, random.randRange(-0.6f, 0.6f));
|
this->pos= pos + Vec3f(random.randRange(-0.6f, 0.6f), 0.0f, random.randRange(-0.6f, 0.6f));
|
||||||
|
|
|
@ -30,13 +30,14 @@ using Shared::Graphics::Vec3f;
|
||||||
/// A map object: tree, stone...
|
/// A map object: tree, stone...
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class Object{
|
class Object {
|
||||||
private:
|
private:
|
||||||
ObjectType *objectType;
|
ObjectType *objectType;
|
||||||
Resource *resource;
|
Resource *resource;
|
||||||
Vec3f pos;
|
Vec3f pos;
|
||||||
float rotation;
|
float rotation;
|
||||||
int variation;
|
int variation;
|
||||||
|
int lastRenderFrame;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Object(ObjectType *objectType, const Vec3f &pos);
|
Object(ObjectType *objectType, const Vec3f &pos);
|
||||||
|
@ -53,6 +54,10 @@ public:
|
||||||
bool getWalkable() const;
|
bool getWalkable() const;
|
||||||
|
|
||||||
void setResource(const ResourceType *resourceType, const Vec2i &pos);
|
void setResource(const ResourceType *resourceType, const Vec2i &pos);
|
||||||
|
|
||||||
|
int getLastRenderFrame() const { return lastRenderFrame; }
|
||||||
|
void setLastRenderFrame(int value) { lastRenderFrame = value; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -147,6 +147,8 @@ Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map
|
||||||
this->targetField = fLand;
|
this->targetField = fLand;
|
||||||
this->targetVec = Vec3f(0.0);
|
this->targetVec = Vec3f(0.0);
|
||||||
this->targetPos = Vec2i(0);
|
this->targetPos = Vec2i(0);
|
||||||
|
this->lastRenderFrame = 0;
|
||||||
|
this->visible = true;
|
||||||
|
|
||||||
level= NULL;
|
level= NULL;
|
||||||
loadType= NULL;
|
loadType= NULL;
|
||||||
|
@ -544,7 +546,9 @@ void Unit::setTargetPos(const Vec2i &targetPos){
|
||||||
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
|
logSynchData(string(__FILE__) + string("::") + string(__FUNCTION__) + string(" Line: ") + intToStr(__LINE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::setVisible(const bool visible){
|
void Unit::setVisible(const bool visible) {
|
||||||
|
this->visible = visible;
|
||||||
|
|
||||||
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it!=unitParticleSystems.end(); ++it){
|
for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it!=unitParticleSystems.end(); ++it){
|
||||||
(*it)->setVisible(visible);
|
(*it)->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,6 +197,8 @@ private:
|
||||||
CardinalDir modelFacing;
|
CardinalDir modelFacing;
|
||||||
|
|
||||||
std::string lastSynchDataString;
|
std::string lastSynchDataString;
|
||||||
|
int lastRenderFrame;
|
||||||
|
bool visible;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
||||||
|
@ -270,6 +272,7 @@ public:
|
||||||
void setTargetVec(const Vec3f &targetVec);
|
void setTargetVec(const Vec3f &targetVec);
|
||||||
void setMeetingPos(const Vec2i &meetingPos);
|
void setMeetingPos(const Vec2i &meetingPos);
|
||||||
void setVisible(const bool visible);
|
void setVisible(const bool visible);
|
||||||
|
bool getVisible() const { return visible; }
|
||||||
|
|
||||||
//render related
|
//render related
|
||||||
const Model *getCurrentModel() const;
|
const Model *getCurrentModel() const;
|
||||||
|
@ -317,6 +320,9 @@ public:
|
||||||
|
|
||||||
bool isMeetingPointSettable() const;
|
bool isMeetingPointSettable() const;
|
||||||
|
|
||||||
|
int getLastRenderFrame() const { return lastRenderFrame; }
|
||||||
|
void setLastRenderFrame(int value) { lastRenderFrame = value; }
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -68,7 +68,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
//load tech tree xml info
|
//load tech tree xml info
|
||||||
try{
|
try{
|
||||||
|
@ -91,7 +91,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
//armor types
|
//armor types
|
||||||
const XmlNode *armorTypesNode= techTreeNode->getChild("armor-types");
|
const XmlNode *armorTypesNode= techTreeNode->getChild("armor-types");
|
||||||
|
@ -119,7 +119,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
//load factions
|
//load factions
|
||||||
str= dir+"/factions/*.";
|
str= dir+"/factions/*.";
|
||||||
|
@ -139,7 +139,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
//SDL_PumpEvents();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,14 +178,18 @@ void World::loadScenario(const string &path, Checksum *checksum){
|
||||||
// ==================== misc ====================
|
// ==================== misc ====================
|
||||||
|
|
||||||
void World::update(){
|
void World::update(){
|
||||||
|
Chrono chrono;
|
||||||
|
chrono.start();
|
||||||
|
|
||||||
++frameCount;
|
++frameCount;
|
||||||
|
|
||||||
//time
|
//time
|
||||||
timeFlow.update();
|
timeFlow.update();
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//water effects
|
//water effects
|
||||||
waterEffects.update();
|
waterEffects.update();
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//units
|
//units
|
||||||
for(int i=0; i<getFactionCount(); ++i){
|
for(int i=0; i<getFactionCount(); ++i){
|
||||||
|
@ -193,6 +197,7 @@ void World::update(){
|
||||||
unitUpdater.updateUnit(getFaction(i)->getUnit(j));
|
unitUpdater.updateUnit(getFaction(i)->getUnit(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//undertake the dead
|
//undertake the dead
|
||||||
for(int i=0; i<getFactionCount(); ++i){
|
for(int i=0; i<getFactionCount(); ++i){
|
||||||
|
@ -206,6 +211,7 @@ void World::update(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//food costs
|
//food costs
|
||||||
for(int i=0; i<techTree->getResourceTypeCount(); ++i){
|
for(int i=0; i<techTree->getResourceTypeCount(); ++i){
|
||||||
|
@ -216,18 +222,21 @@ void World::update(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//fow smoothing
|
//fow smoothing
|
||||||
if(fogOfWarSmoothing && ((frameCount+1) % (fogOfWarSmoothingFrameSkip+1))==0){
|
if(fogOfWarSmoothing && ((frameCount+1) % (fogOfWarSmoothingFrameSkip+1))==0){
|
||||||
float fogFactor= static_cast<float>(frameCount%GameConstants::updateFps)/GameConstants::updateFps;
|
float fogFactor= static_cast<float>(frameCount%GameConstants::updateFps)/GameConstants::updateFps;
|
||||||
minimap.updateFowTex(clamp(fogFactor, 0.f, 1.f));
|
minimap.updateFowTex(clamp(fogFactor, 0.f, 1.f));
|
||||||
}
|
}
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
//tick
|
//tick
|
||||||
if(frameCount%GameConstants::updateFps==0){
|
if(frameCount%GameConstants::updateFps==0){
|
||||||
computeFow();
|
computeFow();
|
||||||
tick();
|
tick();
|
||||||
}
|
}
|
||||||
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::tick(){
|
void World::tick(){
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define MAIN_FUNCTION(X) int main(int argc, char **argv) \
|
#define MAIN_FUNCTION(X) int main(int argc, char **argv) \
|
||||||
{ std::cout << "About to init SDL..." << "\n"; \
|
{ \
|
||||||
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { \
|
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { \
|
||||||
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; \
|
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; \
|
||||||
return 1; \
|
return 1; \
|
||||||
|
|
|
@ -97,11 +97,13 @@ void BaseThread::shutdownAndWait(BaseThread *pThread) {
|
||||||
if(pThread->getRunningStatus() == false) {
|
if(pThread->getRunningStatus() == false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(0);
|
sleep(1);
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
sleep(1);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
sleep(0);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,9 +152,8 @@ SystemFlags::~SystemFlags() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemFlags::Close() {
|
void SystemFlags::Close() {
|
||||||
printf("START Closing logfiles\n");
|
|
||||||
|
|
||||||
if(SystemFlags::debugLogFileList.size() > 0) {
|
if(SystemFlags::debugLogFileList.size() > 0) {
|
||||||
|
printf("START Closing logfiles\n");
|
||||||
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList.begin();
|
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList.begin();
|
||||||
iterMap != SystemFlags::debugLogFileList.end(); iterMap++) {
|
iterMap != SystemFlags::debugLogFileList.end(); iterMap++) {
|
||||||
SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second;
|
SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second;
|
||||||
|
@ -176,7 +175,9 @@ void SystemFlags::Close() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("END Closing logfiles\n");
|
if(SystemFlags::debugLogFileList.size() > 0) {
|
||||||
|
printf("END Closing logfiles\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
|
|
Loading…
Reference in New Issue