int CParticleEffectBinding::DrawModel( int flags ) { VPROF_BUDGET( "CParticleEffectBinding::DrawModel", VPROF_BUDGETGROUP_PARTICLE_RENDERING ); #ifndef PARTICLEPROTOTYPE_APP if ( !r_DrawParticles.GetInt() ) return 0; #endif Assert( flags != 0 ); // If we're in commander mode and it's trying to draw the effect, // exit out. If the effect has FLAGS_ALWAYSSIMULATE set, then it'll come back // in here and simulate at the end of the frame. if( !g_pClientMode->ShouldDrawParticles() ) return 0; SetDrawn( true ); // Don't do anything if there are no particles. if( !m_nActiveParticles ) return 1; // Reset the transformation matrix to identity. VMatrix mTempModel, mTempView; RenderStart( mTempModel, mTempView ); // Setup to redo our bbox? bool bBucketSort = random->RandomInt( 0, BUCKET_SORT_EVERY_N ) == 0; // Set frametime to zero if we've already rendered this frame. float flFrameTime = 0; if ( m_FrameCode != m_pParticleMgr->m_FrameCode ) { m_FrameCode = m_pParticleMgr->m_FrameCode; flFrameTime = Helper_GetFrameTime(); } // For each material, render... // This does an incremental bubble sort. It only does one pass every frame, and it will shuffle // unsorted particles one step towards where they should be. bool bWireframe = false; FOR_EACH_LL( m_Materials, iMaterial ) { CEffectMaterial *pMaterial = m_Materials[iMaterial]; if ( pMaterial->m_pGroup->m_pPageMaterial && pMaterial->m_pGroup->m_pPageMaterial->NeedsPowerOfTwoFrameBufferTexture() ) { UpdateRefractTexture(); } DrawMaterialParticles( bBucketSort, pMaterial, flFrameTime, bWireframe ); }
void TexturedLine::Render() { if(!lineTexture) return; Vect lineDir = (pointB-pointA).Norm(); float halfWidth = width*0.5f; Camera *viewCam = level->GetCurrentCamera(); Vect camPos = viewCam->GetWorldPos(); Vect crossLine; DepthWriteEnable(FALSE); EnableBlending(TRUE); if(lineTexture->HasAlpha()) BlendFunction(GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA); else BlendFunction(GS_BLEND_ONE, GS_BLEND_ONE); LoadTexture(lineTexture); LoadDefault3DSampler(); MatrixPush(); MatrixTranslate(GetWorldPos()); MatrixRotate(GetWorldRot()); RenderStart(); Vect endAdjust = (lineDir*halfWidth); Vect backEnd = (pointA-endAdjust); Vect frontEnd = (pointB+endAdjust); Color(color); crossLine = (camPos-backEnd).Cross(lineDir).Norm() * halfWidth; Vertex(backEnd+crossLine); TexCoord(1.0f, 0.0f); Vertex(backEnd-crossLine); TexCoord(0.0f, 0.0f); crossLine = (camPos-pointA).Cross(lineDir).Norm() * halfWidth; Vertex(pointA+crossLine); TexCoord(1.0f, 0.5f); Vertex(pointA-crossLine); TexCoord(0.0f, 0.5f); crossLine = (camPos-pointB).Cross(lineDir).Norm() * halfWidth; Vertex(pointB+crossLine); TexCoord(1.0f, 0.5f); Vertex(pointB-crossLine); TexCoord(0.0f, 0.5f); crossLine = (camPos-frontEnd).Cross(lineDir).Norm() * halfWidth; Vertex(frontEnd+crossLine); TexCoord(1.0f, 1.0f); Vertex(frontEnd-crossLine); TexCoord(0.0f, 1.0f); RenderStop(GS_TRIANGLESTRIP); MatrixPop(); LoadTexture(NULL); }
/** * Renders all the components of the moving map * @param canvas The drawing canvas * @param rc The area to draw in */ void MapWindow::Render(Canvas &canvas, const RECT &rc) { // Calculate screen positions RenderStart(canvas, rc); // Render terrain, groundline and topology and reset pen, brush and font RenderMapLayer(canvas); if (thread_generation != ui_generation) return; /* cancel */ // Render the AAT areas and airspace RenderAreas(canvas, rc); if (thread_generation != ui_generation) return; /* cancel */ // Render the snail trail /// @todo trail should be drawn above task shaded sections RenderTrail(canvas); DrawThermalEstimate(canvas); // Render task, waypoints and marks RenderTaskElements(canvas, rc); if (thread_generation != ui_generation) return; /* cancel */ // Render topology on top of airspace, to keep the text readable if (topology != NULL && SettingsMap().EnableTopology) topology->DrawLabels(canvas, projection, label_block, SettingsMap()); // Render glide through terrain range RenderGlide(canvas, rc); if (thread_generation != ui_generation) return; /* cancel */ // Render weather/terrain max/min values canvas.select(Fonts::Title); m_background.DrawSpotHeights(canvas, projection, label_block); // Render lower symbology RenderSymbology_lower(canvas, rc); // Render aircraft symbol (and FLARM traffic) RenderAirborne(canvas, rc); // Render upper symbology RenderSymbology_upper(canvas, rc); #ifdef DRAWLOAD canvas.select(Fonts::Map); TCHAR load[80]; _stprintf(load, _T("draw %d gps %d idle %d"), GetAverageTime(), Calculated().time_process_gps, Calculated().time_process_idle); canvas.text(rc.left, rc.top, load); #endif }