static void TerrainMakeActive( const TerrainTexture &text ) { if (text.tex.t) { GFXEnable( TEXTURE0 ); text.tex.t->MakeActive(); } else { GFXDisable( TEXTURE0 ); } GFXBlendMode( text.blendSrc, text.blendDst ); if (text.reflect) GFXEnable( TEXTURE1 ); else GFXDisable( TEXTURE1 ); GFXSelectMaterial( text.material ); }
void Stars::Draw() { static bool stars_dont_move = XMLSupport::parse_bool (vs_config->getVariable("graphics","stars_dont_move","false")); if (stars_dont_move)return; const QVector cp (_Universe->AccessCamera()->GetPosition()); UpdatePosition(cp); // GFXLightContextAmbient(GFXColor(0,0,0,1)); GFXColor (1,1,1,1); GFXLoadIdentity(MODEL); GFXDisable(DEPTHWRITE); GFXDisable (TEXTURE0); GFXDisable (TEXTURE1); GFXEnable (DEPTHTEST); static bool near_stars_alpha=XMLSupport::parse_bool(vs_config->getVariable("graphics","near_stars_alpha","false")); static bool near_stars_alpha_blend=XMLSupport::parse_bool(vs_config->getVariable("graphics","near_stars_alpha_blend","false")); static float AlphaTestingCutoff =XMLSupport::parse_float(vs_config->getVariable("graphics","stars_alpha_test_cutoff",".2")); if (near_stars_alpha) { GFXAlphaTest (GREATER,AlphaTestingCutoff); if (!near_stars_alpha_blend) { GFXBlendMode(ONE,ZERO); } else { GFXBlendMode(SRCALPHA,INVSRCALPHA); } GFXEnable(DEPTHWRITE); } else { if (blend) { GFXBlendMode (ONE,ONE); } else { GFXBlendMode (ONE,ZERO); } } int ligh; GFXSelectMaterial (0); if (fade) { static float star_spread_attenuation = XMLSupport::parse_float(vs_config->getVariable("graphics","star_spread_attenuation",".2")); GFXPushGlobalEffects(); GFXLight FadeLight (true, GFXColor (cp.i,cp.j,cp.k), GFXColor (0,0,0,1), GFXColor (0,0,0,1), GFXColor (1,1,1,1), GFXColor (.01,0,1/(star_spread_attenuation*star_spread_attenuation*spread*spread))); GFXCreateLight (ligh,FadeLight,true); GFXEnable (LIGHTING); } else { GFXDisable (LIGHTING); } _Universe->AccessCamera()->UpdateGFX(GFXFALSE,GFXFALSE,GFXFALSE); int LC=0,LN=vlist->NumTextures(); for (LC=0; LC<LN; ++LC) { bool stretch=vlist->BeginDrawState(_Universe->AccessCamera()->GetR().Scale(-spread).Cast(),_Universe->AccessCamera()->GetVelocity(),_Universe->AccessCamera()->GetAngularVelocity(),false,false,LC); int i; for (i=0; i<STARnumvlist; i++) { if (i>=1) GFXTranslateModel (pos[i]-pos[i-1]); else GFXTranslateModel (pos[i]); vlist->Draw(stretch,LC); } GFXTranslateModel(-pos[i-1]); vlist->EndDrawState(stretch,LC); } if (near_stars_alpha) { GFXAlphaTest(ALWAYS,0); } else { GFXEnable(DEPTHWRITE); } GFXBlendMode(ONE,ZERO); _Universe->AccessCamera()->UpdateGFX(GFXTRUE,GFXFALSE,GFXFALSE) ; GFXEnable (TEXTURE0); GFXEnable (TEXTURE1); if (fade) { GFXDeleteLight (ligh); GFXPopGlobalEffects(); } GFXLoadIdentity(MODEL); }