From b8014fdaca6f9ed46b0cd1e666f2082a96358a87 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 26 Aug 2011 02:20:33 +1000 Subject: [PATCH] Hopefully solve some rare font black box issues --- Graphs/gFlagsLine.cpp | 7 ++++--- Graphs/gFooBar.cpp | 10 ++++------ Graphs/gGraphView.cpp | 15 +++++++++++---- Graphs/gLineOverlay.cpp | 5 ++--- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Graphs/gFlagsLine.cpp b/Graphs/gFlagsLine.cpp index 4c912cc8..1bba67a6 100644 --- a/Graphs/gFlagsLine.cpp +++ b/Graphs/gFlagsLine.cpp @@ -76,8 +76,8 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height) } // Draw the outer rectangle outline - glLineWidth(1); glBegin(GL_LINE_LOOP); + glLineWidth(1); w.qglColor(Qt::black); glVertex2f(left-1, top); glVertex2f(left-1, top+height); @@ -176,6 +176,8 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height) // glScissor(left,top,width,height); //glEnable(GL_SCISSOR_TEST); + glEnableClientState(GL_VERTEX_ARRAY); + bool antialias=pref["UseAntiAliasing"].toBool(); if (antialias) { glEnable(GL_BLEND); @@ -185,7 +187,6 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height) glLineWidth (1.5); } else glLineWidth (1); - glEnableClientState(GL_VERTEX_ARRAY); w.qglColor(m_flag_color); if (quadcnt>0) { glVertexPointer(2, GL_SHORT, 0, quadarray); @@ -195,11 +196,11 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height) glVertexPointer(2, GL_SHORT, 0, vertarray); glDrawArrays(GL_LINES, 0, vertcnt>>1); } - glDisableClientState(GL_VERTEX_ARRAY); if (antialias) { glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } + glDisableClientState(GL_VERTEX_ARRAY); //glDisable(GL_SCISSOR_TEST); } diff --git a/Graphs/gFooBar.cpp b/Graphs/gFooBar.cpp index b22199a1..d47e69ac 100644 --- a/Graphs/gFooBar.cpp +++ b/Graphs/gFooBar.cpp @@ -24,7 +24,6 @@ void gShadowArea::paint(gGraph & w,int left, int top, int width, int height) int start_px=left; int end_px=left+width; - glDisable(GL_DEPTH_TEST); float h=top; double rmx=w.rmax_x-w.rmin_x; @@ -33,8 +32,8 @@ void gShadowArea::paint(gGraph & w,int left, int top, int width, int height) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glBegin(GL_QUADS); glEnable(GL_BLEND); + glBegin(GL_QUADS); w.qglColor(m_shadow_color); glVertex2f(start_px, top); @@ -46,8 +45,8 @@ void gShadowArea::paint(gGraph & w,int left, int top, int width, int height) glVertex2f(start_px+py, top+height); glVertex2f(end_px, top+height); glVertex2f(end_px, top); - glDisable(GL_BLEND); glEnd(); + glDisable(GL_BLEND); //glFlush(); } @@ -71,11 +70,10 @@ void gFooBar::paint(gGraph & w,int left, int top, int width, int height) int start_px=left; int end_px=left+width; - glDisable(GL_DEPTH_TEST); float h=top; - glLineWidth(1); glBegin(GL_LINES); + glLineWidth(1); w.qglColor(m_line_color); glVertex2f(start_px, h); glVertex2f(start_px+width, h); @@ -85,8 +83,8 @@ void gFooBar::paint(gGraph & w,int left, int top, int width, int height) double px=((1/rmx)*(w.min_x-w.rmin_x))*width; double py=((1/rmx)*(w.max_x-w.rmin_x))*width; - glLineWidth(4); glBegin(GL_LINES); + glLineWidth(4); w.qglColor(m_handle_color); glVertex2f(start_px+px-4,h); glVertex2f(start_px+py+4,h); diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index a5a6e0c6..eb63e734 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -221,6 +221,11 @@ void gGraph::renderText(QString text, int x,int y, float angle, QColor color, QF // I tried queuing this but got crappy memory leaks.. for now I don't give a crap if this is slow. QPainter *painter=m_graphview->painter; + + glPushAttrib(GL_COLOR_BUFFER_BIT); + glEnable(GL_BLEND); + //glEnable(GL_TEXTURE_2D); + //glEnable(GL_DEPTH_BUFFER); painter->endNativePainting(); QBrush b(color); painter->setBrush(b); @@ -238,8 +243,10 @@ void gGraph::renderText(QString text, int x,int y, float angle, QColor color, QF painter->translate(-x,-y); } painter->beginNativePainting(); - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_BUFFER); + glDisable(GL_BLEND); + //glDisable(GL_TEXTURE_2D); + glPopAttrib(); + //glEnable(GL_DEPTH_BUFFER); } @@ -310,16 +317,16 @@ void gGraph::paint(int originX, int originY, int width, int height) if (m_selection.width()>0 && m_selecting_area) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBegin(GL_QUADS); glEnable(GL_BLEND); + glBegin(GL_QUADS); glColor4ub(128,128,128,128); glVertex2i(originX+m_selection.x(),originY+top); glVertex2i(originX+m_selection.x()+m_selection.width(),originY+top); glColor4ub(128,128,255,128); glVertex2i(originX+m_selection.x()+m_selection.width(),originY+height-top-bottom); glVertex2i(originX+m_selection.x(),originY+height-top-bottom); - glDisable(GL_BLEND); glEnd(); + glDisable(GL_BLEND); } } diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp index 19e297a6..36f0e13c 100644 --- a/Graphs/gLineOverlay.cpp +++ b/Graphs/gLineOverlay.cpp @@ -93,7 +93,6 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh quadarray[quadcnt++]=start_py+height; quadarray[quadcnt++]=x1; quadarray[quadcnt++]=start_py+height; - qDebug()<< x1 << x2 << start_py << height; if (quadcnt>=maxverts) { verts_exceeded=true; break; } } else if (m_flt==FT_Dot) { //if (pref["AlwaysShowOverlayBars"].toBool()) { @@ -147,7 +146,6 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh } bool antialias=pref["UseAntiAliasing"].toBool(); - glEnableClientState(GL_VERTEX_ARRAY); if (antialias) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //_MINUS_SRC_ALPHA); @@ -155,6 +153,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glLineWidth (1.5); } else glLineWidth (1); + glEnableClientState(GL_VERTEX_ARRAY); w.qglColor(m_flag_color); if (quadcnt>0) { @@ -170,12 +169,12 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh glVertexPointer(2, GL_SHORT, 0, pointarray); glDrawArrays(GL_POINTS, 0, pointcnt>>1); } + glDisableClientState(GL_VERTEX_ARRAY); if (antialias) { glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - glDisableClientState(GL_VERTEX_ARRAY); //glDisable(GL_SCISSOR_TEST); }