Make GLBlend functions adjustable. Set SummaryChart to use DST alhpa blending

This commit is contained in:
Mark Watkins 2011-12-28 14:42:02 +10:00
parent 0b4717c2b3
commit f16929dafd
4 changed files with 12 additions and 3 deletions

View File

@ -147,6 +147,8 @@ GLBuffer::GLBuffer(int max,int type, bool stippled)
m_cnt=0;
m_colcnt=0;
m_size=1;
m_blendfunc1=GL_SRC_ALPHA;
m_blendfunc2=GL_ONE_MINUS_SRC_ALPHA;
}
GLBuffer::~GLBuffer()
{
@ -308,7 +310,9 @@ void GLShortBuffer::draw()
float size=m_size;
if (antialias) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(m_blendfunc1, m_blendfunc2);
//glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
@ -563,7 +567,7 @@ void GLFloatBuffer::draw()
float size=m_size;
if (antialias) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(m_blendfunc1, m_blendfunc2);
if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

View File

@ -73,6 +73,7 @@ public:
void setAntiAlias(bool b) { m_antialias=b; }
void forceAntiAlias(bool b) { m_forceantialias=b; }
void setColor(QColor col) { m_color=col; }
void setBlendFunc(GLuint b1, GLuint b2) { m_blendfunc1=b1; m_blendfunc2=b2; }
protected:
int m_max;
int m_type; // type (GL_LINES, GL_QUADS, etc)
@ -86,6 +87,7 @@ protected:
bool m_forceantialias;
QMutex mutex;
bool m_stippled;
GLuint m_blendfunc1, m_blendfunc2;
};
/*! \class GLShortBuffer

View File

@ -21,6 +21,7 @@ gLineChart::gLineChart(ChannelID code,QColor col,bool square_plot, bool disable_
addGLBuf(lines=new GLShortBuffer(100000,GL_LINES));
lines->setColor(col);
lines->setAntiAlias(true);
lines->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC1_ALPHA);
}
gLineChart::~gLineChart()
{

View File

@ -18,8 +18,10 @@ SummaryChart::SummaryChart(QString label,GraphType type)
addGLBuf(quads=new GLShortBuffer(20000,GL_QUADS));
addGLBuf(lines=new GLShortBuffer(20000,GL_LINES));
quads->forceAntiAlias(true);
lines->setSize(2.5);
lines->setSize(1.5);
lines->setBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
lines->forceAntiAlias(false);
m_empty=true;
hl_day=-1;
m_machinetype=MT_CPAP;