//Draw all visible windows. void WindowManager::draw() { GFXHudMode( true ); //Load identity matrices. GFXColorf( GUI_OPAQUE_WHITE() ); GFXDisable( DEPTHTEST ); GFXEnable( DEPTHWRITE ); GFXDisable( LIGHTING ); GFXDisable( CULLFACE ); GFXClear( GFXTRUE ); GFXDisable( DEPTHWRITE ); GFXBlendMode( SRCALPHA, INVSRCALPHA ); GFXDisable( TEXTURE1 ); GFXEnable( TEXTURE0 ); //Just loop through all the windows, and remember if anything gets drawn. //Since the first window in the list is drawn first, z-order is //maintained. First entry is the bottom window, last is the top window. //FIXME mbyron -- I think the event manager needs to get involved with window z-order. //(Mouse events should go to windows in zorder, shouldn't they?) for (size_t i = 0; i < m_windows.size(); i++) { if ( m_windows[i]->controller() )//it's a controller m_windows[i]->controller()->draw();//that can draw if ( i < m_windows.size() ) m_windows[i]->draw(); } //Emulate EndGUIFrame. static VSSprite MouseVSSprite( "mouse.spr", BILINEAR, GFXTRUE ); static Texture dummy( "white.bmp", 0, NEAREST, TEXTURE2D, TEXTURE_2D, GFXTRUE ); GFXDisable( CULLFACE ); ConditionalCursorDraw( true ); //Figure position of cursor sprite. float sizex = 0.0, sizey = 0.0; const Point loc = globalEventManager().mouseLoc(); MouseVSSprite.GetSize( sizex, sizey ); float tempx = 0.0, tempy = 0.0; MouseVSSprite.GetPosition( tempx, tempy ); MouseVSSprite.SetPosition( tempx+loc.x+sizex/2, tempy+loc.y+sizey/2 ); dummy.MakeActive(); GFXBlendMode( SRCALPHA, INVSRCALPHA ); GFXColorf( GUI_OPAQUE_WHITE() ); //Draw the cursor sprite. GFXEnable( TEXTURE0 ); GFXDisable( DEPTHTEST ); GFXDisable( TEXTURE1 ); MouseVSSprite.Draw(); GFXHudMode( false ); GFXEnable( CULLFACE ); MouseVSSprite.SetPosition( tempx, tempy ); }
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 SphereDisplay::Draw(const Sensor& sensor, VSSprite *frontSprite, VSSprite *rearSprite) { assert(frontSprite || rearSprite); // There should be at least one radar display radarTime += GetElapsedTime(); leftRadar.SetSprite(frontSprite); rightRadar.SetSprite(rearSprite); if (frontSprite) frontSprite->Draw(); if (rearSprite) rearSprite->Draw(); Sensor::TrackCollection tracks = sensor.FindTracksInRange(); // FIXME: Consider using std::sort instead of the z-buffer GFXEnable(DEPTHTEST); GFXEnable(DEPTHWRITE); DrawBackground(sensor, leftRadar); DrawBackground(sensor, rightRadar); for (Sensor::TrackCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it) { static bool draw_both = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "draw_blips_on_both_radar", "false" )); if (it->GetPosition().z < 0 || draw_both) { // Draw tracks behind the ship DrawTrack(sensor, rightRadar, *it,true); } if (it->GetPosition().z >= 0 || draw_both) { // Draw tracks in front of the ship DrawTrack(sensor, leftRadar, *it); } } GFXPointSize(1); GFXDisable(DEPTHTEST); GFXDisable(DEPTHWRITE); }
bool SpriteStarVlist::BeginDrawState(const QVector ¢er, const Vector &velocity, const Vector & torque, bool roll, bool yawpitch, int whichTex) { UpdateGraphics(); GFXEnable(TEXTURE0); decal[whichTex]->MakeActive(); GFXDisable(CULLFACE); GFXColorMaterial(AMBIENT|DIFFUSE); vlist[whichTex]->LoadDrawState(); vlist[whichTex]->BeginDrawState(); return false; }
//Draw lower-right part of rectangle's "shadow". void drawLowRightShadow( const Rect &rect, const GFXColor &color, float lineWidth ) { GFXDisable( TEXTURE0 ); GFXLineWidth( lineWidth ); GFXColorf( color ); const float verts[3 * 3] = { rect.origin.x, rect.origin.y, 0, rect.origin.x+rect.size.width, rect.origin.y, 0, rect.origin.x+rect.size.width, rect.origin.y+rect.size.height, 0, }; GFXDraw( GFXLINESTRIP, verts, 3 ); GFXEnable( TEXTURE0 ); }
//Draw a rectangle using the specified color. void drawRect( const Rect &rect, const GFXColor &color ) { GFXDisable( TEXTURE0 ); GFXColorf( color ); const float verts[4 * 3] = { rect.left(), rect.top(), 0, rect.right(), rect.top(), 0, rect.right(), rect.bottom(), 0, rect.left(), rect.bottom(), 0, }; GFXDraw( GFXQUAD, verts, 4 ); GFXEnable( TEXTURE0 ); }
//Draw the outline of a rectangle using the specified color. void drawRectOutline( const Rect &rect, const GFXColor &color, float lineWidth ) { GFXDisable( TEXTURE0 ); GFXLineWidth( lineWidth ); GFXColorf( color ); const float verts[5 * 3] = { rect.left(), rect.top(), 0, rect.right(), rect.top(), 0, rect.right(), rect.bottom(), 0, rect.left(), rect.bottom(), 0, rect.left(), rect.top(), 0, }; GFXDraw( GFXLINESTRIP, verts, 5 ); GFXEnable( TEXTURE0 ); }
void SphereDisplay::DrawTargetMarker(const Vector& position, float trackSize) { // Crosshair const float crossSize = 8.0; const float xcross = crossSize / g_game.x_resolution; const float ycross = crossSize / g_game.y_resolution; // The crosshair wiggles as it moves around. The wiggling is less noticable // when the crosshair is drawn with the smooth option. GFXEnable(SMOOTH); GFXLineWidth(trackSize); GFXBegin(GFXLINE); GFXVertex3f(position.x + xcross, position.y, 0.0f); GFXVertex3f(position.x - xcross, position.y, 0.0f); GFXVertex3f(position.x, position.y - ycross, 0.0f); GFXVertex3f(position.x, position.y + ycross, 0.0f); GFXEnd(); GFXDisable(SMOOTH); }
void SphereDisplay::DrawBackground(const Sensor& sensor, const ViewArea& radarView) { // Split crosshair if (!radarView.IsActive()) return; GFXColor groundColor = radarView.GetColor(); float velocity = sensor.GetPlayer()->GetWarpVelocity().Magnitude(); float logvelocity = 3.0; // std::log10(1000.0); if (velocity > 1000.0) { // Max logvelocity is log10(speed_of_light) = 10.46 logvelocity = std::log10(velocity); } const float size = 3.0 * logvelocity; // [9; 31] const float xground = size / g_game.x_resolution; const float yground = size / g_game.y_resolution; Vector center = radarView.Scale(Vector(0.0, 0.0, 0.0)); GFXEnable(SMOOTH); GFXLineWidth(1); GFXColorf(groundColor); GFXBegin(GFXLINE); GFXVertexf(Vector(center.x - 2.0 * xground, center.y, center.z)); GFXVertexf(Vector(center.x - xground, center.y, center.z)); GFXVertexf(Vector(center.x + 2.0 * xground, center.y, center.z)); GFXVertexf(Vector(center.x + xground, center.y, center.z)); GFXVertexf(Vector(center.x, center.y - 2.0 * yground, center.z)); GFXVertexf(Vector(center.x, center.y - yground, center.z)); GFXVertexf(Vector(center.x, center.y + 2.0 * yground, center.z)); GFXVertexf(Vector(center.x, center.y + yground, center.z)); GFXEnd(); GFXDisable(SMOOTH); }
void GFXVertexList::Draw( enum POLYTYPE *mode, const INDEX index, const int numlists, const int *offsets ) { //Hardware support for this seems... sketchy if (vbo_data == 0 && display_list != 0) { //Big issue: display lists cannot discriminate between lines/points/triangles, //so, for now, we'll limit smoothing to single-mode GFXVertexLists, which, by the way, //are the only ones being used, AFAIK. bool blendchange = false; if ( unique_mode && (numlists > 0) ) { switch (*mode) { case GFXLINE: case GFXLINESTRIP: case GFXPOLY: case GFXPOINT: if ( ( (*mode == GFXPOINT) && gl_options.smooth_points ) || ( (*mode != GFXPOINT) && gl_options.smooth_lines ) ) { BLENDFUNC src, dst; GFXGetBlendMode( src, dst ); if ( (dst != ZERO) && ( (src == ONE) || (src == SRCALPHA) ) ) { GFXPushBlendMode(); GFXBlendMode( SRCALPHA, dst ); GFXEnable( SMOOTH ); blendchange = true; } } break; default: break; } } GFXCallList( display_list ); if (blendchange) { GFXPopBlendMode(); GFXDisable( SMOOTH ); } ++gl_batches_this_frame; } else { int totoffset = 0; if (changed&HAS_INDEX) { long stride = changed&HAS_INDEX; GLenum indextype = (changed&INDEX_BYTE) ? GL_UNSIGNED_BYTE : ( (changed&INDEX_SHORT) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT ); bool use_vbo = vbo_data != 0; use_vbo = use_vbo && memcmp( &index, &this->index, sizeof (INDEX) ) == 0; if (use_vbo) { #ifndef NO_VBO_SUPPORT GFXBindElementBuffer( display_list ); #else use_vbo = false; #endif } else { #ifndef NO_VBO_SUPPORT if (vbo_data) GFXBindElementBuffer( 0 ); #endif } if (glMultiDrawElements_p != NULL && numlists > 1) { static std::vector< bool > drawn; static std::vector< const GLvoid* >glindices; static std::vector< GLsizei >glcounts; drawn.clear(); drawn.resize( numlists, false ); for (int i = 0; i < numlists; totoffset += offsets[i++]) if (!drawn[i]) { glindices.clear(); glcounts.clear(); int totcount = 0; for (long j = i, offs = totoffset; j < numlists; offs += offsets[j++]) { totcount += offsets[j]; if ( !drawn[j] && (mode[j] == mode[i]) ) { glindices.push_back( use_vbo ? (GLvoid*) (stride*offs) : (GLvoid*) &index.b[stride*offs] ); glcounts.push_back( offsets[j] ); drawn[j] = true; } } if (glindices.size() == 1) glDrawElements( PolyLookup( mode[i] ), glcounts[0], indextype, glindices[0] ); else glMultiDrawElements_p( PolyLookup( mode[i] ), &glcounts[0], indextype, &glindices[0], glindices.size() ); ++gl_batches_this_frame; gl_vertices_this_frame += totcount; } } else { for (int i = 0; i < numlists; i++) { glDrawElements( PolyLookup( mode[i] ), offsets[i], indextype, use_vbo ? (GLvoid*) (stride*totoffset) : (GLvoid*)&index.b[stride*totoffset] ); //changed&INDEX_BYTE == stride! totoffset += offsets[i]; ++gl_batches_this_frame; gl_vertices_this_frame += offsets[i]; } } } else { if (glMultiDrawArrays_p) { static std::vector< bool > drawn; static std::vector< GLint > gloffsets; static std::vector< GLsizei >glcounts; drawn.clear(); drawn.resize( numlists, false ); for (int i = 0; i < numlists; totoffset += offsets[i++]) if (!drawn[i]) { gloffsets.clear(); glcounts.clear(); int totcount = 0; for (int j = i, offs = totoffset; j < numlists; offs += offsets[j++]) { totcount += offsets[j]; if ( !drawn[j] && (mode[j] == mode[i]) ) { gloffsets.push_back( offs ); glcounts.push_back( offsets[j] ); drawn[j] = true; } } bool blendchange = false; switch (mode[i]) { case GFXLINE: case GFXLINESTRIP: case GFXPOLY: case GFXPOINT: if ( ( (mode[i] == GFXPOINT) && gl_options.smooth_points ) || ( (mode[i] != GFXPOINT) && gl_options.smooth_lines ) ) { BLENDFUNC src, dst; GFXGetBlendMode( src, dst ); if ( (dst != ZERO) && ( (src == ONE) || (src == SRCALPHA) ) ) { GFXPushBlendMode(); GFXBlendMode( SRCALPHA, dst ); GFXEnable( SMOOTH ); blendchange = true; } } break; default: break; } if (gloffsets.size() == 1) glDrawArrays( PolyLookup( mode[i] ), gloffsets[0], glcounts[0] ); else glMultiDrawArrays_p( PolyLookup( mode[i] ), &gloffsets[0], &glcounts[0], gloffsets.size() ); if (blendchange) { GFXPopBlendMode(); GFXDisable( SMOOTH ); } ++gl_batches_this_frame; gl_vertices_this_frame += totcount; } } else { for (int i = 0; i < numlists; i++) { bool blendchange = false; switch (mode[i]) { case GFXLINE: case GFXLINESTRIP: case GFXPOLY: case GFXPOINT: if ( ( (mode[i] == GFXPOINT) && gl_options.smooth_points ) || ( (mode[i] != GFXPOINT) && gl_options.smooth_lines ) ) { BLENDFUNC src, dst; GFXGetBlendMode( src, dst ); if ( (dst != ZERO) && ( (src == ONE) || (src == SRCALPHA) ) ) { GFXPushBlendMode(); GFXBlendMode( SRCALPHA, dst ); GFXEnable( SMOOTH ); blendchange = true; } } break; default: break; } glDrawArrays( PolyLookup( mode[i] ), totoffset, offsets[i] ); totoffset += offsets[i]; if (blendchange) { GFXPopBlendMode(); GFXDisable( SMOOTH ); } ++gl_batches_this_frame; gl_vertices_this_frame += offsets[i]; } } } } }
void SpriteStarVlist::EndDrawState(bool stretch, int whichTex) { vlist[whichTex]->EndDrawState(); GFXDisable(TEXTURE0); GFXEnable(CULLFACE); GFXColorMaterial(0); }
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); }
void Box::ProcessDrawQueue( int ) { if ( !draw_queue[0].size() ) return; GFXBlendMode( SRCALPHA, INVSRCALPHA ); GFXColor( 0.0, .90, .3, .4 ); GFXDisable( LIGHTING ); GFXDisable( TEXTURE0 ); GFXDisable( TEXTURE1 ); GFXDisable( DEPTHWRITE ); GFXDisable( CULLFACE ); //GFXBlendMode(ONE, ONE); while ( draw_queue[0].size() ) { GFXLoadMatrixModel( draw_queue[0].back().mat ); draw_queue[0].pop_back(); GFXBegin( GFXQUAD ); GFXColor4f( 0.0, 1.0, 0.0, 0.2 ); GFXVertex3f( corner_max.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_max.k ); GFXColor4f( 0.0, 1.0, 0.0, 0.2 ); GFXVertex3f( corner_min.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_min.k ); GFXColor4f( 0.0, .70, 0.0, 0.2 ); GFXVertex3f( corner_max.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_min.k ); GFXColor4f( 0.0, .70, 0.0, 0.2 ); GFXVertex3f( corner_max.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_max.k ); GFXColor4f( 0.0, .90, .3, 0.2 ); GFXVertex3f( corner_max.i, corner_max.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_max.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_max.i, corner_max.j, corner_min.k ); GFXColor4f( 0.0, .90, .3, 0.2 ); GFXVertex3f( corner_min.i, corner_max.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_min.k ); GFXVertex3f( corner_min.i, corner_min.j, corner_max.k ); GFXVertex3f( corner_min.i, corner_max.j, corner_max.k ); GFXEnd(); /* * vlist->Draw(); * if(quadstrips!=NULL) { * for(int a=0; a<numQuadstrips; a++) * quadstrips[a]->Draw() * ; * } */ } GFXEnable( DEPTHWRITE ); }
//#define UPDATEDEBUG //for hard to track down bugs void GameStarSystem::Draw(bool DrawCockpit) { double starttime=queryTime(); GFXEnable (DEPTHTEST); GFXEnable (DEPTHWRITE); saved_interpolation_blend_factor=interpolation_blend_factor = (1./PHY_NUM)*((PHY_NUM*time)/SIMULATION_ATOM+current_stage); GFXColor4f(1,1,1,1); if (DrawCockpit) { AnimatedTexture::UpdateAllFrame(); } for (unsigned int i=0;i<contterrains.size();++i) { contterrains[i]->AdjustTerrain(this); } Unit * par; bool alreadysetviewport=false; if ((par=_Universe->AccessCockpit()->GetParent())==NULL) { _Universe->AccessCamera()->UpdateGFX (GFXTRUE); } else { if (!par->isSubUnit()) { //now we can assume world is topps par-> cumulative_transformation = linear_interpolate (par->prev_physical_state,par->curr_physical_state,interpolation_blend_factor); Unit * targ = par->Target(); if (targ&&!targ->isSubUnit()) { targ-> cumulative_transformation = linear_interpolate (targ->prev_physical_state,targ->curr_physical_state,interpolation_blend_factor); } _Universe->AccessCockpit()->SetupViewPort(true); alreadysetviewport=true; } } double setupdrawtime=queryTime(); { cam_setup_phase=true; //int numships=0; Unit * saveparent=_Universe->AccessCockpit()->GetSaveParent(); Unit * targ=NULL; if (saveparent) { targ=saveparent->Target(); } //Array containing the two interesting units, so as not to have to copy-paste code Unit * camunits[2]={saveparent,targ}; float backup=SIMULATION_ATOM; unsigned int cur_sim_frame = _Universe->activeStarSystem()->getCurrentSimFrame(); for(int i=0;i<2;++i) { Unit *unit=camunits[i]; // Make sure unit is not null; if(unit&&!unit->isSubUnit()) { interpolation_blend_factor=calc_blend_factor(saved_interpolation_blend_factor,unit->sim_atom_multiplier,unit->cur_sim_queue_slot,cur_sim_frame); SIMULATION_ATOM = backup*unit->sim_atom_multiplier; ((GameUnit<Unit> *)unit)->GameUnit<Unit>::Draw(); } } interpolation_blend_factor=saved_interpolation_blend_factor; SIMULATION_ATOM=backup; //printf("Number of insystem ships: %d (%d FPS)\n",numships,(int)(1.f/GetElapsedTime())); ///this is the final, smoothly calculated cam _Universe->AccessCockpit()->SetupViewPort(true); cam_setup_phase=false; } setupdrawtime=queryTime()-setupdrawtime; GFXDisable (LIGHTING); bg->Draw(); double drawtime=queryTime(); double maxdrawtime=0; //Ballpark estimate of when an object of configurable size first becomes one pixel QVector drawstartpos=_Universe->AccessCamera()->GetPosition(); Collidable key_iterator(0,1,drawstartpos); UnitWithinRangeOfPosition<UnitDrawer> drawer(game_options.precull_dist,0,key_iterator); //Need to draw really big stuff (i.e. planets, deathstars, and other mind-bogglingly big things that shouldn't be culled despited extreme distance Unit* unit; if ((drawer.action.parent=_Universe->AccessCockpit()->GetParent())!=NULL) { drawer.action.parenttarget=drawer.action.parent->Target(); } for(un_iter iter=this->GravitationalUnits.createIterator();(unit=*iter)!=NULL;++iter) { float distance = (drawstartpos-unit->Position()).Magnitude()-unit->rSize(); if(distance < game_options.precull_dist) { drawer.action.grav_acquire(unit); } else { drawer.action.draw(unit); } } // Need to get iterator to approx camera position CollideMap::iterator parent=collidemap[Unit::UNIT_ONLY]->lower_bound(key_iterator); findObjectsFromPosition(this->collidemap[Unit::UNIT_ONLY],parent,&drawer,drawstartpos,0,true); drawer.action.drawParents();//draw units targeted by camera //FIXME maybe we could do bolts & units instead of unit only--and avoid bolt drawing step #if 0 for (unsigned int sim_counter=0;sim_counter<=SIM_QUEUE_SIZE;++sim_counter) { double tmp=queryTime(); Unit *unit; UnitCollection::UnitIterator iter = physics_buffer[sim_counter].createIterator(); float backup=SIMULATION_ATOM; unsigned int cur_sim_frame = _Universe->activeStarSystem()->getCurrentSimFrame(); while((unit = iter.current())!=NULL) { interpolation_blend_factor=calc_blend_factor(saved_interpolation_blend_factor,unit->sim_atom_multiplier,unit->cur_sim_queue_slot,cur_sim_frame); //if (par&&par->Target()==unit) { //printf ("i:%f s:%f m:%d c:%d l:%d\n",interpolation_blend_factor,saved_interpolation_blend_factor,unit->sim_atom_multiplier,sim_counter,current_sim_location); //} SIMULATION_ATOM = backup*unit->sim_atom_multiplier; ((GameUnit<Unit> *)unit)->Draw(); iter.advance(); } interpolation_blend_factor=saved_interpolation_blend_factor; SIMULATION_ATOM=backup; tmp=queryTime()-tmp; if (tmp>maxdrawtime)maxdrawtime=tmp; } #endif drawtime=queryTime()-drawtime; WarpTrailDraw(); GFXFogMode (FOG_OFF); GFXColor tmpcol (0,0,0,1); GFXGetLightContextAmbient(tmpcol); double processmesh=queryTime(); if (!game_options.draw_near_stars_in_front_of_planets) stars->Draw(); Mesh::ProcessZFarMeshes(); if (game_options.draw_near_stars_in_front_of_planets) stars->Draw(); GFXEnable (DEPTHTEST); GFXEnable (DEPTHWRITE); //need to wait for lights to finish GamePlanet::ProcessTerrains(); Terrain::RenderAll(); Mesh::ProcessUndrawnMeshes(true); processmesh=queryTime()-processmesh; Nebula * neb; Matrix ident; Identity(ident); //Atmosphere::ProcessDrawQueue(); GFXPopGlobalEffects(); GFXLightContextAmbient(tmpcol); if ((neb = _Universe->AccessCamera()->GetNebula())) { neb->SetFogState(); } Beam::ProcessDrawQueue(); Bolt::Draw(); // if (_Universe->AccessCamera()->GetNebula()!=NULL) GFXFogMode (FOG_OFF); Animation::ProcessDrawQueue(); Halo::ProcessDrawQueue(); particleTrail.DrawAndUpdate(); GameStarSystem::DrawJumpStars(); ConditionalCursorDraw(false); // static bool doInputDFA = XMLSupport::parse_bool (vs_config->getVariable ("graphics","MouseCursor","false")); if (DrawCockpit) { _Universe->AccessCockpit()->Draw(); // if (doInputDFA) { // GFXHudMode (true); // systemInputDFA->Draw(); // GFXHudMode (false); // } } double fintime=queryTime()-starttime; if (debugPerformance()) { printf("draw: %f setup %f units %f maxunit %f processmesh %f ",fintime,setupdrawtime,drawtime,maxdrawtime,processmesh); } }