- in headless mode avoid init of sdl's video surface so that we stay in console window (no graphics window shown)

This commit is contained in:
Mark Vejvoda 2011-09-27 07:01:08 +00:00
parent c68aa74fcf
commit 9caff9dac3
7 changed files with 169 additions and 132 deletions

View File

@ -325,6 +325,10 @@ void Renderer::init() {
Config &config= Config::getInstance();
loadConfig();
if(this->masterserverMode == true) {
return;
}
if(config.getBool("CheckGlCaps")){
checkGlCaps();
}
@ -335,10 +339,6 @@ void Renderer::init() {
config.save();
}
if(this->masterserverMode == true) {
return;
}
modelManager[rsGlobal]->init();
textureManager[rsGlobal]->init();
fontManager[rsGlobal]->init();
@ -364,9 +364,6 @@ void Renderer::initGame(const Game *game){
this->game= game;
//worldToScreenPosCache.clear();
//check gl caps
checkGlOptionalCaps();
//vars
shadowMapFrame= 0;
waterAnim= 0;
@ -377,6 +374,9 @@ void Renderer::initGame(const Game *game){
return;
}
//check gl caps
checkGlOptionalCaps();
//shadows
if(shadows == sProjected || shadows == sShadowMapping) {
static_cast<ModelRendererGl*>(modelRenderer)->setSecondaryTexCoordUnit(2);

View File

@ -2431,6 +2431,7 @@ int glestMain(int argc, char** argv) {
if( hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) {
isMasterServerModeEnabled = true;
Window::setMasterserverMode(isMasterServerModeEnabled);
}
//off_t fileSize = getFileSize(argv[0]);

View File

@ -798,7 +798,9 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
UnitParticleSystem *ups = new UnitParticleSystem(200);
(*it)->setValues(ups);
ups->setPos(getCurrVector());
if(getFaction()->getTexture()) {
ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
unitParticleSystems.push_back(ups);
Renderer::getInstance().manageParticleSystem(ups, rsGame);
}
@ -1446,7 +1448,9 @@ void Unit::updateTimedParticles() {
UnitParticleSystem *ups = new UnitParticleSystem(200);
pst->setValues(ups);
ups->setPos(getCurrVector());
if(getFaction()->getTexture()) {
ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
unitParticleSystems.push_back(ups);
Renderer::getInstance().manageParticleSystem(ups, rsGame);
@ -1682,7 +1686,9 @@ bool Unit::update() {
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(getCurrVector());
if(getFaction()->getTexture()) {
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
Renderer::getInstance().manageParticleSystem(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups, rsGame);
//printf("+ #1 APPLY ATTACK BOOST SELF PARTICLE to unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId());
@ -1736,7 +1742,9 @@ bool Unit::update() {
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(getCurrVector());
if(getFaction()->getTexture()) {
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
Renderer::getInstance().manageParticleSystem(currentAttackBoostOriginatorEffect.currentAppliedEffect->ups, rsGame);
//printf("+ #2 APPLY ATTACK BOOST SELF PARTICLE to unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId());
@ -1834,7 +1842,9 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
effect->ups = new UnitParticleSystem(200);
effect->upst->setValues(effect->ups);
effect->ups->setPos(getCurrVector());
if(getFaction()->getTexture()) {
effect->ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
Renderer::getInstance().manageParticleSystem(effect->ups, rsGame);
}
}
@ -2725,7 +2735,9 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
UnitParticleSystem *ups = new UnitParticleSystem(200);
pst->setValues(ups);
ups->setPos(getCurrVector());
if(getFaction()->getTexture()) {
ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
damageParticleSystems.push_back(ups);
damageParticleSystemsInUse[i] = ups;
Renderer::getInstance().manageParticleSystem(ups, rsGame);
@ -2746,7 +2758,9 @@ void Unit::startDamageParticles() {
UnitParticleSystem *ups = new UnitParticleSystem(200);
pst->setValues(ups);
ups->setPos(getCurrVector());
if(getFaction()->getTexture()) {
ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
damageParticleSystems.push_back(ups);
damageParticleSystemsInUse[i] = ups;
Renderer::getInstance().manageParticleSystem(ups, rsGame);

View File

@ -2041,7 +2041,9 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
psProj->setPath(startPos, endPos);
psProj->setObserver(new ParticleDamager(unit, this, gameCamera));
psProj->setVisible(visible);
if(unit->getFaction()->getTexture()) {
psProj->setFactionColor(unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
renderer.manageParticleSystem(psProj, rsGame);
}
else{
@ -2053,7 +2055,9 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
psSplash= pstSplash->create();
psSplash->setPos(endPos);
psSplash->setVisible(visible);
if(unit->getFaction()->getTexture()) {
psSplash->setFactionColor(unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
}
renderer.manageParticleSystem(psSplash, rsGame);
if(pstProj!=NULL){
psProj->link(psSplash);

View File

@ -111,6 +111,8 @@ private:
static void setKeystate(SDL_keysym state) { keystate = state; }
static bool masterserverMode;
protected:
int w, h;
static bool isActive;
@ -130,6 +132,9 @@ public:
Window();
virtual ~Window();
static void setMasterserverMode(bool value) { Window::masterserverMode = value;}
static bool getMasterserverMode() { return Window::masterserverMode;}
static bool getTryVSynch() { return tryVSynch; }
static void setTryVSynch(bool value) { tryVSynch = value; }

View File

@ -113,6 +113,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
screen = NULL;
}
if(Window::getMasterserverMode() == false) {
screen = SDL_SetVideoMode(resW, resH, colorBits, flags);
if(screen == 0) {
std::ostringstream msg;
@ -158,6 +159,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
SDL_WM_GrabInput(SDL_GRAB_OFF);
}
}
void PlatformContextGl::end() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -185,8 +187,10 @@ void PlatformContextGl::makeCurrent() {
}
void PlatformContextGl::swapBuffers() {
if(Window::getMasterserverMode() == false) {
SDL_GL_SwapBuffers();
}
}
const char *getPlatformExtensions(const PlatformContextGl *pcgl) {

View File

@ -60,6 +60,8 @@ int Window::lastShowMouseState = 0;
bool Window::tryVSynch = false;
bool Window::masterserverMode = false;
// ========== PUBLIC ==========
Window::Window() {
@ -356,6 +358,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
if(stencilBits >= 0)
newStencilBits = stencilBits;
if(Window::masterserverMode == false) {
if(fullscreen_anti_aliasing == true) {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
@ -390,6 +393,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
glTexEnvf(GL_TEXTURE_FILTER_CONTROL,GL_TEXTURE_LOD_BIAS, lodBias );
}
}
}
#ifdef WIN32
@ -416,6 +420,7 @@ void Window::toggleFullscreen() {
Use 0 for Height, Width, and Color Depth to keep the current values. */
if(Window::allowAltEnterFullscreenToggle == true) {
if(this->masterserverMode == false) {
SDL_Surface *cur_surface = SDL_GetVideoSurface();
if(cur_surface != NULL) {
Window::isFullScreen = !((cur_surface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);
@ -470,6 +475,7 @@ void Window::toggleFullscreen() {
SDL_SetClipRect(*surface, &clip);
}
}
else {
HWND handle = GetSDLWindow();
if(Window::isFullScreen == true) {
@ -489,11 +495,14 @@ void Window::toggleFullscreen() {
#else
if(Window::allowAltEnterFullscreenToggle == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(Window::masterserverMode == false) {
SDL_Surface *cur_surface = SDL_GetVideoSurface();
if(cur_surface != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
SDL_WM_ToggleFullScreen(cur_surface);
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
#endif