void UnitDrawerStateARB::SetNanoColor(const float4& color) const { if (color.a > 0.0f) { glColorf4(color); } else { glColorf3(OnesVector); } }
static void DrawUnitDebugPieceTree(const LocalModelPiece* p, const LocalModelPiece* lap, int lapf, CMatrix44f mat) { mat.Translate(p->pos.x, p->pos.y, p->pos.z); mat.RotateY(-p->rot[1]); mat.RotateX(-p->rot[0]); mat.RotateZ(-p->rot[2]); glPushMatrix(); glMultMatrixf(mat.m); if (p->visible && !p->GetCollisionVolume()->IsDisabled()) { if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColor3f((1.0f - ((gs->frameNum - lapf) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(p->GetCollisionVolume()); if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColorf3(defaultColVolColor); } } glPopMatrix(); for (unsigned int i = 0; i < p->childs.size(); i++) { DrawUnitDebugPieceTree(p->childs[i], lap, lapf, mat); } }
static inline void DrawObjectMidAndAimPos(const CSolidObject* o) { GLUquadricObj* q = gluNewQuadric(); glDisable(GL_DEPTH_TEST); if (o->aimPos != o->midPos) { // draw the aim-point glPushMatrix(); glTranslatef3(o->relAimPos * WORLD_TO_OBJECT_SPACE); glColor3f(1.0f, 0.0f, 0.0f); gluQuadricDrawStyle(q, GLU_FILL); gluSphere(q, 2.0f, 5, 5); glPopMatrix(); } { // draw the mid-point, keep this transform on the stack glTranslatef3(o->relMidPos * WORLD_TO_OBJECT_SPACE); glColor3f(1.0f, 0.0f, 1.0f); gluQuadricDrawStyle(q, GLU_FILL); gluSphere(q, 2.0f, 5, 5); glColorf3(DEFAULT_VOLUME_COLOR); } glEnable(GL_DEPTH_TEST); gluDeleteQuadric(q); }
static void DrawUnitDebugPieceTree(const LocalModelPiece* p, const LocalModelPiece* lap, int lapf, CMatrix44f mat) { const float3& rot = p->GetRotation(); mat.Translate(p->GetPosition()); mat.RotateY(-rot[1]); mat.RotateX(-rot[0]); mat.RotateZ(-rot[2]); glPushMatrix(); glMultMatrixf(mat.m); if (p->scriptSetVisible && !p->GetCollisionVolume()->IgnoreHits()) { if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColor3f((1.0f - ((gs->frameNum - lapf) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(p->GetCollisionVolume()); if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColorf3(DEFAULT_VOLUME_COLOR); } } glPopMatrix(); for (unsigned int i = 0; i < p->children.size(); i++) { DrawUnitDebugPieceTree(p->children[i], lap, lapf, mat); } }
static inline void DrawFeatureColVol(const CFeature* f) { if (f->collisionVolume && !f->collisionVolume->IsDisabled()) { if (!f->IsInLosForAllyTeam(gu->myAllyTeam) && !gu->spectatingFullView) return; if (!camera->InView(f->pos, f->drawRadius)) return; glPushMatrix(); glMultMatrixf(f->transMatrix.m); glTranslatef3(f->relMidPos * float3(-1.0f, 1.0f, 1.0f)); GLUquadricObj* q = gluNewQuadric(); // draw the centerpos glColor3f(1.0f, 0.0f, 1.0f); gluQuadricDrawStyle(q, GLU_FILL); gluSphere(q, 2.0f, 5, 5); glColorf3(defaultColVolColor); gluQuadricDrawStyle(q, GLU_LINE); DrawCollisionVolume(f->collisionVolume, q); gluDeleteQuadric(q); glPopMatrix(); } }
void UnitDrawerStateFFP::SetNanoColor(const float4& color) const { if (color.a > 0.0f) { UnitDrawerStateFFP::DisableTextures(); glColorf4(color); } else { UnitDrawerStateFFP::EnableTextures(); glColorf3(OnesVector); } }
static inline void DrawUnitColVol(const CUnit* unit) { if (!(unit->losStatus[gu->myAllyTeam] & LOS_INLOS) && !gu->spectatingFullView) return; if (!camera->InView(unit->drawMidPos, unit->drawRadius)) return; glPushMatrix(); glMultMatrixf(unit->GetTransformMatrix()); glTranslatef3(unit->relMidPos * float3(-1.0f, 1.0f, 1.0f)); GLUquadricObj* q = gluNewQuadric(); // draw the aimpoint glColor3f(1.0f, 0.0f, 1.0f); gluQuadricDrawStyle(q, GLU_FILL); gluSphere(q, 2.0f, 5, 5); glColorf3(defaultColVolColor); gluQuadricDrawStyle(q, GLU_LINE); if (unit->unitDef->usePieceCollisionVolumes) { //! draw only the piece volumes for less clutter CMatrix44f mat(unit->relMidPos * float3(0.0f, -1.0f, 0.0f)); DrawUnitDebugPieceTree(unit->localmodel->GetRoot(), unit->lastAttackedPiece, unit->lastAttackedPieceFrame, mat, q); } else { if (!unit->collisionVolume->IsDisabled()) { //! make it fade red under attack if (unit->lastAttack > 0 && ((gs->frameNum - unit->lastAttack) < 150)) { glColor3f((1.0f - ((gs->frameNum - unit->lastAttack) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(unit->collisionVolume, q); if (unit->lastAttack > 0 && ((gs->frameNum - unit->lastAttack) < 150)) { glColorf3(defaultColVolColor); } } } gluDeleteQuadric(q); glPopMatrix(); }
static inline void DrawUnitColVol(const CUnit* u) { if (!(u->losStatus[gu->myAllyTeam] & LOS_INLOS) && !gu->spectatingFullView) return; if (!camera->InView(u->drawMidPos, u->drawRadius)) return; const CollisionVolume* v = u->collisionVolume; const bool vCustomType = (v->GetVolumeType() < CollisionVolume::COLVOL_TYPE_SPHERE); const bool vCustomDims = ((v->GetOffsets()).SqLength() >= 1.0f || math::fabs(v->GetBoundingRadius() - u->radius) >= 1.0f); glPushMatrix(); glMultMatrixf(u->GetTransformMatrix()); DrawObjectMidAndAimPos(u); if (v->DefaultToPieceTree()) { // draw only the piece volumes for less clutter CMatrix44f mat(u->relMidPos * float3(0.0f, -1.0f, 0.0f)); DrawUnitDebugPieceTree(u->localModel->GetRoot(), u->lastAttackedPiece, u->lastAttackedPieceFrame, mat); } else { if (!v->IgnoreHits()) { // make it fade red under attack if (u->lastAttackFrame > 0 && ((gs->frameNum - u->lastAttackFrame) < 150)) { glColor3f((1.0f - ((gs->frameNum - u->lastAttackFrame) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(v); if (u->lastAttackFrame > 0 && ((gs->frameNum - u->lastAttackFrame) < 150)) { glColorf3(DEFAULT_VOLUME_COLOR); } } } if (vCustomType || vCustomDims) { // assume this is a custom volume glColor3f(0.5f, 0.5f, 0.5f); glScalef(u->radius, u->radius, u->radius); glWireSphere(&volumeDisplayListIDs[0], 20, 20); } glPopMatrix(); }
void ProfileDrawer::Draw() { GML_STDMUTEX_LOCK_NOPROF(time); // Draw // draw the background of the window glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 0.0f, 0.5f, 0.5f); if(!profiler.profile.empty()){ glBegin(GL_TRIANGLE_STRIP); glVertex3f(start_x, end_y, 0); glVertex3f(end_x, end_y, 0); glVertex3f(start_x, end_y-profiler.profile.size()*0.024f-0.01f, 0); glVertex3f(end_x, end_y-profiler.profile.size()*0.024f-0.01f, 0); glEnd(); } std::map<std::string, CTimeProfiler::TimeRecord>::iterator pi; // draw the textual info (total-time, short-time percentual time, timer-name) int y = 0; font->Begin(); for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++y) { #if GML_MUTEX_PROFILER if (pi->first.size()<5 || pi->first.substr(pi->first.size()-5,5).compare("Mutex")!=0) { --y; continue; } const float fStartY = start_y - y * 0.020f; #else const float fStartY = start_y - y * 0.024f; #endif const float s = ((float)pi->second.total) / 1000.0f; const float p = pi->second.percent * 100; float fStartX = start_x + 0.005f + 0.015f + 0.005f; // print total-time running since application start fStartX += 0.09f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2fs", s); // print percent of CPU time used within the last 500ms fStartX += 0.08f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2f%%", p); // print timer name fStartX += 0.01f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM, "%s", pi->first.c_str()); } font->End(); // draw the Timer selection boxes glPushMatrix(); glTranslatef(start_x + 0.005f, start_y, 0); glScalef(0.015f, 0.02f, 0.02f); for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi){ glColorf3((float3)pi->second.color); glBegin(GL_QUADS); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(1,1,0); glVertex3f(0,1,0); glEnd(); // draw the 'graph view disabled' cross if (!pi->second.showGraph) { glColor3f(1,0,0); glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,1,0); glEnd(); } glTranslatef(0,-1.2f,0); } glPopMatrix(); // draw the graph for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi) { if (!pi->second.showGraph) { continue; } CVertexArray* va = GetVertexArray(); va->Initialize(); const float steps_x = (end_x - start_x) / CTimeProfiler::TimeRecord::frames_size; for (size_t a=0; a < CTimeProfiler::TimeRecord::frames_size; ++a) { // profile runtime; eg 0.5f means: uses 50% of a CPU (during that frame) // This may be more then 1.0f, in case an operation // which ran over many frames, ended in this one. const float p = ((float)pi->second.frames[a]) / 1000.0f * GAME_SPEED; const float x = start_x + (a * steps_x); const float y = 0.02f + (p * 0.4f); va->AddVertex0(float3(x, y, 0.0f)); } glColorf3((float3)pi->second.color); va->DrawArray0(GL_LINE_STRIP); } glEnable(GL_TEXTURE_2D); }
void CUnit::Draw() { glPushMatrix(); float3 interPos=pos+speed*gu->timeOffset; if (physicalState == Flying && unitDef->canmove) { //aircraft or skidding ground unit CMatrix44f transMatrix(interPos,-rightdir,updir,frontdir); glMultMatrixf(&transMatrix[0]); } else if(upright || !unitDef->canmove) { glTranslatef3(interPos); if(heading!=0) glRotatef(heading*(180.0/32768.0),0,1,0); } else { float3 frontDir=GetVectorFromHeading(heading); //making local copies of vectors float3 upDir=ground->GetSmoothNormal(pos.x,pos.z); float3 rightDir=frontDir.cross(upDir); rightDir.Normalize(); frontDir=upDir.cross(rightDir); CMatrix44f transMatrix(interPos,-rightDir,upDir,frontDir); glMultMatrixf(&transMatrix[0]); } if(beingBuilt && unitDef->showNanoFrame) { if(shadowHandler->inShadowPass) { if(buildProgress>0.66) localmodel->Draw(); } else { float height=model->height; float start=model->miny; glEnable(GL_CLIP_PLANE0); glEnable(GL_CLIP_PLANE1); //float col=fabs(128.0-((gs->frameNum*4)&255))/255.0+0.5f; float3 fc;// fc frame color if(gu->teamNanospray) { unsigned char* tcol=gs->Team(team)->color; fc = float3(tcol[0]*(1./255.),tcol[1]*(1./255.),tcol[2]*(1./255.)); } else { fc = unitDef->nanoColor; } glColorf3(fc); unitDrawer->UnitDrawingTexturesOff(model); double plane[4]= {0,-1,0,start+height*buildProgress*3}; glClipPlane(GL_CLIP_PLANE0 ,plane); double plane2[4]= {0,1,0,-start-height*(buildProgress*10-9)}; glClipPlane(GL_CLIP_PLANE1 ,plane2); glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); localmodel->Draw(); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); if(buildProgress>0.33) { glColorf3(fc*1.4f); double plane[4]= {0,-1,0,start+height*(buildProgress*3-1)}; glClipPlane(GL_CLIP_PLANE0 ,plane); double plane2[4]= {0,1,0,-start-height*(buildProgress*3-2)}; glClipPlane(GL_CLIP_PLANE1 ,plane2); localmodel->Draw(); } glDisable(GL_CLIP_PLANE1); unitDrawer->UnitDrawingTexturesOn(model); if(buildProgress>0.66) { double plane[4]= {0,-1,0,start+height*(buildProgress*3-2)}; glClipPlane(GL_CLIP_PLANE0 ,plane); if(shadowHandler->drawShadows && !water->drawReflection) { glPolygonOffset(1,1); glEnable(GL_POLYGON_OFFSET_FILL); } localmodel->Draw(); if(shadowHandler->drawShadows && !water->drawReflection) { glDisable(GL_POLYGON_OFFSET_FILL); } } glDisable(GL_CLIP_PLANE0); } } else { localmodel->Draw(); } if(gu->drawdebug) { glPushMatrix(); glTranslatef3(frontdir*relMidPos.z + updir*relMidPos.y + rightdir*relMidPos.x); GLUquadricObj* q=gluNewQuadric(); gluQuadricDrawStyle(q,GLU_LINE); gluSphere(q,radius,10,10); gluDeleteQuadric(q); glPopMatrix(); }/**/ glPopMatrix(); }
static void DrawProfiler() { font->SetTextColor(1,1,1,1); CVertexArray* va = GetVertexArray(); CVertexArray* va2 = GetVertexArray(); // draw the background of the window if(!profiler.profile.empty()){ va->Initialize(); va->AddVertex0(start_x, end_y, 0); va->AddVertex0(end_x, end_y, 0); va->AddVertex0(start_x, end_y-profiler.profile.size()*0.024f-0.01f, 0); va->AddVertex0(end_x, end_y-profiler.profile.size()*0.024f-0.01f, 0); glColor4f(0.0f, 0.0f, 0.5f, 0.5f); va->DrawArray0(GL_TRIANGLE_STRIP); } std::map<std::string, CTimeProfiler::TimeRecord>::iterator pi; // draw the textual info (total-time, short-time percentual time, timer-name) int y = 0; for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++y) { const float fStartY = start_y - y * 0.024f; float fStartX = start_x + 0.005f + 0.015f + 0.005f; // print total-time running since application start fStartX += 0.04f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2fs", pi->second.total.toSecsf()); // print percent of CPU time used within the last 500ms fStartX += 0.04f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2f%%", pi->second.percent * 100); fStartX += 0.04f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.2f%%", pi->second.newPeak?1:255, pi->second.newPeak?1:255, pi->second.peak * 100); fStartX += 0.04f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.0fms", pi->second.newLagPeak?1:255, pi->second.newLagPeak?1:255, pi->second.maxLag); // print timer name fStartX += 0.01f; font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM, pi->first); } // draw the Timer selection boxes glPushMatrix(); glTranslatef(start_x + 0.005f, start_y, 0); glScalef(0.015f, 0.02f, 0.02f); va->Initialize(); va2->Initialize(); int i = 0; for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++i){ auto& fc = pi->second.color; SColor c(fc[0], fc[1], fc[2]); va->AddVertexC(float3(0, 0 - i * 1.2f, 0), c); va->AddVertexC(float3(1, 0 - i * 1.2f, 0), c); va->AddVertexC(float3(1, 1 - i * 1.2f, 0), c); va->AddVertexC(float3(0, 1 - i * 1.2f, 0), c); if (!pi->second.showGraph) { va2->AddVertex0(0, 0 - i * 1.2f, 0); va2->AddVertex0(1, 1 - i * 1.2f, 0); va2->AddVertex0(1, 0 - i * 1.2f, 0); va2->AddVertex0(0, 1 - i * 1.2f, 0); } } // draw the boxes va->DrawArrayC(GL_QUADS); // draw the 'graph view disabled' cross glColor3f(1,0,0); va2->DrawArray0(GL_LINES); glPopMatrix(); // draw the graph glLineWidth(3.0f); for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi) { if (!pi->second.showGraph) { continue; } va->Initialize(); const float steps_x = (end_x - start_x) / CTimeProfiler::TimeRecord::frames_size; for (size_t a=0; a < CTimeProfiler::TimeRecord::frames_size; ++a) { // profile runtime; eg 0.5f means: uses 50% of a CPU (during that frame) // This may be more then 1.0f, in case an operation // which ran over many frames, ended in this one. const float p = pi->second.frames[a].toSecsf() * GAME_SPEED; const float x = start_x + (a * steps_x); const float y = 0.02f + (p * 0.96f); va->AddVertex0(x, y, 0.0f); } glColorf3((float3)pi->second.color); va->DrawArray0(GL_LINE_STRIP); } glLineWidth(1.0f); }
void ProfileDrawer::Draw() { GML_STDMUTEX_LOCK_NOPROF(time); // Draw glPushMatrix(); glDisable(GL_TEXTURE_2D); glColor4f(0,0,0.5f,0.5f); if(!profiler.profile.empty()){ glBegin(GL_TRIANGLE_STRIP); glVertex3f(0.65f,0.99f,0); glVertex3f(0.99f,0.99f,0); glVertex3f(0.65f,0.99f-profiler.profile.size()*0.024f-0.01f,0); glVertex3f(0.99f,0.99f-profiler.profile.size()*0.024f-0.01f,0); glEnd(); } std::map<std::string, CTimeProfiler::TimeRecord>::iterator pi; int y = 0; font->Begin(); for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++y) { #if GML_MUTEX_PROFILER if(pi->first.size()<5 || pi->first.substr(pi->first.size()-5,5).compare("Mutex")!=0) { --y; continue; } #endif font->glFormat(0.655f, 0.960f - y * 0.024f, 1.0f, FONT_SCALE | FONT_NORM, "%20s %6.2fs %5.2f%%", pi->first.c_str(), ((float)pi->second.total) / 1000.f, pi->second.percent * 100); } font->End(); glTranslatef(0.655f,0.965f,0); glScalef(0.015f,0.02f,0.02f); glDisable(GL_TEXTURE_2D); for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi){ glColorf3((float3)pi->second.color); glBegin(GL_QUADS); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(1,1,0); glVertex3f(0,1,0); glEnd(); if(!pi->second.showGraph){ glColor3f(1,0,0); glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(1,1,0); glVertex3f(1,0,0); glVertex3f(0,1,0); glEnd(); } glTranslatef(0,-1.2f,0); } glPopMatrix(); for(pi=profiler.profile.begin();pi!=profiler.profile.end();++pi){ if(!pi->second.showGraph) continue; CVertexArray* va=GetVertexArray(); va->Initialize(); for(int a=0;a<128;++a){ float p=((float)pi->second.frames[a])/1000.f*30; va->AddVertex0(float3(0.6f+a*0.003f,0.02f+p*0.4f,0.0f)); } glColorf3((float3)pi->second.color); va->DrawArray0(GL_LINE_STRIP); } glEnable(GL_TEXTURE_2D); }
static void DrawProfiler() { font->SetTextColor(1,1,1,1); // draw the background of the window { CVertexArray* va = GetVertexArray(); va->Initialize(); va->AddVertex0(start_x, start_y + lineHeight + 0.005f, 0); va->AddVertex0(end_x, start_y + lineHeight + 0.005f, 0); va->AddVertex0(start_x, start_y - profiler.profile.size() * lineHeight - 0.01f, 0); va->AddVertex0(end_x, start_y - profiler.profile.size() * lineHeight - 0.01f, 0); glColor4f(0.0f, 0.0f, 0.5f, 0.5f); va->DrawArray0(GL_TRIANGLE_STRIP); } const float textSize = 0.5f; // table header { const float fStartY = start_y + 0.005f; float fStartX = start_x + 0.005f + 0.015f + 0.005f; // print total-time running since application start fStartX += 0.04f; font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "totaltime"); // print percent of CPU time used within the last 500ms fStartX += 0.06f; font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "cur-%%usage"); fStartX += 0.04f; font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "max-%%usage"); fStartX += 0.04f; font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "lag"); // print timer name fStartX += 0.01f; font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM, "title"); } // draw the textual info (total-time, short-time percentual time, timer-name) int y = 1; for (auto pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++y) { const auto& profileData = pi->second; const float fStartY = start_y - y * lineHeight; float fStartX = start_x + 0.005f + 0.015f + 0.005f; // print total-time running since application start fStartX += 0.04f; font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2fs", profileData.total.toSecsf()); // print percent of CPU time used within the last 500ms fStartX += 0.06f; font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2f%%", profileData.percent * 100); fStartX += 0.04f; font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.2f%%", profileData.newPeak?1:255, profileData.newPeak?1:255, profileData.peak * 100); fStartX += 0.04f; font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.0fms", profileData.newLagPeak?1:255, profileData.newLagPeak?1:255, profileData.maxLag); // print timer name fStartX += 0.01f; font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM, pi->first); } // draw the Timer selection boxes const float boxSize = lineHeight*0.9; const float selOffset = boxSize*0.2; glPushMatrix(); glTranslatef(start_x + 0.005f, start_y + boxSize, 0); // we are now at upper left of first box CVertexArray* va = GetVertexArray(); CVertexArray* va2 = GetVertexArray(); va->Initialize(); va2->Initialize(); int i = 1; for (auto pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++i){ auto& fc = pi->second.color; SColor c(fc[0], fc[1], fc[2]); va->AddVertexC(float3(0, -i*lineHeight, 0), c); // upper left va->AddVertexC(float3(0, -i*lineHeight-boxSize, 0), c); // lower left va->AddVertexC(float3(boxSize, -i*lineHeight-boxSize, 0), c); // lower right va->AddVertexC(float3(boxSize, -i*lineHeight, 0), c); // upper right if (pi->second.showGraph) { va2->AddVertex0(lineHeight+selOffset, -i*lineHeight-selOffset, 0); // upper left va2->AddVertex0(lineHeight+selOffset, -i*lineHeight-boxSize+selOffset, 0); // lower left va2->AddVertex0(lineHeight+boxSize-selOffset, -i*lineHeight-boxSize+selOffset, 0); // lower right va2->AddVertex0(lineHeight+boxSize-selOffset, -i*lineHeight-selOffset, 0); // upper right } } // draw the boxes va->DrawArrayC(GL_QUADS); // draw the 'graph view disabled' cross glColor3f(1,0,0); va2->DrawArray0(GL_QUADS); glPopMatrix(); // draw the graph glLineWidth(3.0f); for (auto pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi) { if (!pi->second.showGraph) { continue; } CVertexArray* va = GetVertexArray(); va->Initialize(); const float steps_x = (end_x - start_x) / CTimeProfiler::TimeRecord::frames_size; for (size_t a=0; a < CTimeProfiler::TimeRecord::frames_size; ++a) { // profile runtime; eg 0.5f means: uses 50% of a CPU (during that frame) // This may be more then 1.0f, in case an operation // which ran over many frames, ended in this one. const float p = pi->second.frames[a].toSecsf() * GAME_SPEED; const float x = start_x + (a * steps_x); const float y = 0.02f + (p * 0.96f); va->AddVertex0(x, y, 0.0f); } glColorf3((float3)pi->second.color); va->DrawArray0(GL_LINE_STRIP); } glLineWidth(1.0f); }