Added line/quad count to debug info

This commit is contained in:
Mark Watkins 2013-01-16 07:02:03 +10:00
parent 59d217d7c7
commit 5446992899

View File

@ -35,6 +35,10 @@ extern MainWindow *mainwin;
#endif #endif
// for profiling purposes, a count of lines drawn in a single frame
int lines_drawn_this_frame=0;
int quads_drawn_this_frame=0;
bool _graph_init=false; bool _graph_init=false;
QFont * defaultfont=NULL; QFont * defaultfont=NULL;
@ -196,10 +200,14 @@ void gVertexBuffer::draw()
} }
glLineWidth(size); glLineWidth(size);
lines_drawn_this_frame+=m_cnt/2;
} else if (m_type==GL_POINTS) { } else if (m_type==GL_POINTS) {
glPointSize(size); glPointSize(size);
} else if (m_type==GL_POLYGON) { } else if (m_type==GL_POLYGON) {
glPolygonMode(GL_BACK,GL_FILL); glPolygonMode(GL_BACK,GL_FILL);
lines_drawn_this_frame+=m_cnt/2;
} else if (m_type==GL_QUADS) {
quads_drawn_this_frame+=m_cnt/4;
} }
if (m_scissor) { if (m_scissor) {
glScissor(s_x,s_y,s_width,s_height); glScissor(s_x,s_y,s_width,s_height);
@ -643,11 +651,16 @@ void GLFloatBuffer::draw()
glLineStipple(1, 0xAAAA); glLineStipple(1, 0xAAAA);
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
} }
lines_drawn_this_frame+=m_cnt/2;
} else if (m_type==GL_POINTS) { } else if (m_type==GL_POINTS) {
glPointSize(size); glPointSize(size);
} else if (m_type==GL_POLYGON) { } else if (m_type==GL_POLYGON) {
glPolygonMode(GL_BACK,GL_FILL); glPolygonMode(GL_BACK,GL_FILL);
lines_drawn_this_frame+=m_cnt/2;
} else if (m_type==GL_QUADS) {
quads_drawn_this_frame+=m_cnt/4;
} }
if (m_scissor) { if (m_scissor) {
glScissor(s1,s2,s3,s4); glScissor(s1,s2,s3,s4);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
@ -661,6 +674,7 @@ void GLFloatBuffer::draw()
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(m_type, 0, m_cnt >> 1); glDrawArrays(m_type, 0, m_cnt >> 1);
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
@ -786,13 +800,14 @@ void gToolTip::paint() //actually paints it.
rect.setHeight(h); rect.setHeight(h);
} }
lines_drawn_this_frame+=4;
quads_drawn_this_frame+=1;
painter.drawRoundedRect(rect,5,5); painter.drawRoundedRect(rect,5,5);
painter.drawText(rect,Qt::AlignCenter,m_text); painter.drawText(rect,Qt::AlignCenter,m_text);
painter.end(); painter.end();
} }
void gToolTip::timerDone() void gToolTip::timerDone()
{ {
@ -2713,6 +2728,9 @@ bool gGraphView::renderGraphs()
//int elapsed=time.elapsed(); //int elapsed=time.elapsed();
//QColor col=Qt::black; //QColor col=Qt::black;
lines_drawn_this_frame=0;
quads_drawn_this_frame=0;
backlines->draw(); backlines->draw();
for (int i=0;i<m_graphs.size();i++) { for (int i=0;i<m_graphs.size();i++) {
m_graphs[i]->drawGLBuf(); m_graphs[i]->drawGLBuf();
@ -2940,7 +2958,7 @@ void gGraphView::paintGL()
v+=ring[i]; v+=ring[i];
} }
double fps=v/double(rs); double fps=v/double(rs);
ss="Debug Mode "+QString::number(ms,'f',1)+"ms ("+QString::number(fps,'f',1)+"fps)"; ss="Debug Mode "+QString::number(ms,'f',1)+"ms ("+QString::number(fps,'f',1)+"fps) "+QString::number(lines_drawn_this_frame,'f',0)+" lines "+QString::number(quads_drawn_this_frame,'f',0)+" quads";
int w,h; int w,h;
GetTextExtent(ss,w,h); GetTextExtent(ss,w,h);
QColor col=Qt::white; QColor col=Qt::white;