From 3c0fa11f912836755acff4de0b1ee59de54627c5 Mon Sep 17 00:00:00 2001
From: Mark Watkins <jedimark@users.sourceforge.net>
Date: Thu, 8 May 2014 14:07:23 +1000
Subject: [PATCH] Get rid of extra OpenGL dependencies

---
 sleepyhead/Graphs/GLBuffer.cpp      | 289 --------------------------
 sleepyhead/Graphs/gFlagsLine.h      |   1 +
 sleepyhead/Graphs/gFooBar.cpp       |   5 -
 sleepyhead/Graphs/gFooBar.h         |   2 -
 sleepyhead/Graphs/gGraph.cpp        |  36 +---
 sleepyhead/Graphs/gGraph.h          |  26 +--
 sleepyhead/Graphs/gGraphView.cpp    | 298 +++++++++++++--------------
 sleepyhead/Graphs/gGraphView.h      |   2 -
 sleepyhead/Graphs/gLineOverlay.cpp  |   2 +
 sleepyhead/Graphs/gSummaryChart.cpp |  12 --
 sleepyhead/Graphs/gVertexBuffer.cpp | 304 ----------------------------
 sleepyhead/Graphs/glcommon.cpp      |  76 -------
 sleepyhead/Graphs/glcommon.h        |  21 --
 sleepyhead/Graphs/gspacer.h         |   1 +
 sleepyhead/Graphs/layer.cpp         |  87 ++++----
 sleepyhead/Graphs/layer.h           |  20 +-
 sleepyhead/sleepyhead.pro           |   2 -
 17 files changed, 211 insertions(+), 973 deletions(-)
 delete mode 100644 sleepyhead/Graphs/GLBuffer.cpp
 delete mode 100644 sleepyhead/Graphs/gVertexBuffer.cpp

diff --git a/sleepyhead/Graphs/GLBuffer.cpp b/sleepyhead/Graphs/GLBuffer.cpp
deleted file mode 100644
index c3171d75..00000000
--- a/sleepyhead/Graphs/GLBuffer.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- *
- * Copyright (c) 2011-2014 Mark Watkins <jedimark@users.sourceforge.net>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file COPYING in the main directory of the Linux
- * distribution for more details. */
-
-#include "Graphs/GLBuffer.h"
-
-#include <QDebug>
-
-#include "SleepLib/profiles.h"
-
-extern int lines_drawn_this_frame;
-extern int quads_drawn_this_frame;
-
-GLFloatBuffer::GLFloatBuffer(int max, int type, bool stippled)
-    : GLBuffer(max, type, stippled)
-{
-    buffer = new GLfloat[max + 8];
-    colors = new GLubyte[max * 4 + (8 * 4)];
-}
-
-GLFloatBuffer::~GLFloatBuffer()
-{
-    if (colors) {
-        delete [] colors;
-    }
-
-    if (buffer) {
-        delete [] buffer;
-    }
-}
-
-void GLFloatBuffer::add(GLfloat x, GLfloat y, QColor &color)
-{
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.lock();
-#endif
-    if (m_cnt < m_max + 2) {
-        buffer[m_cnt++] = x;
-        buffer[m_cnt++] = y;
-        colors[m_colcnt++] = color.red();
-        colors[m_colcnt++] = color.green();
-        colors[m_colcnt++] = color.blue();
-        colors[m_colcnt++] = color.alpha();
-
-    } else {
-        qDebug() << "GLBuffer overflow";
-    }
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.unlock();
-#endif
-}
-
-void GLFloatBuffer::add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, QColor &color)
-{
-    if (m_cnt < m_max + 4) {
-        qDebug() << "GLFloatBuffer overflow";
-        return;
-    }
-
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.lock();
-#endif
-    buffer[m_cnt++] = x1;
-    buffer[m_cnt++] = y1;
-    buffer[m_cnt++] = x2;
-    buffer[m_cnt++] = y2;
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.unlock();
-#endif
-}
-
-void GLFloatBuffer::add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3,
-                        GLfloat x4, GLfloat y4, QColor &color) // add with vertex colors
-{
-    if (m_cnt >= m_max + 8) {
-        qDebug() << "GLFloatBuffer overflow";
-        return;
-    }
-
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.lock();
-#endif
-    buffer[m_cnt++] = x1;
-    buffer[m_cnt++] = y1;
-    buffer[m_cnt++] = x2;
-    buffer[m_cnt++] = y2;
-    buffer[m_cnt++] = x3;
-    buffer[m_cnt++] = y3;
-    buffer[m_cnt++] = x4;
-    buffer[m_cnt++] = y4;
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.unlock();
-#endif
-}
-
-void GLFloatBuffer::quadGrLR(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3,
-                             GLfloat y3, GLfloat x4, GLfloat y4, QColor &color, QColor &color2)  // add with vertex colors
-{
-    if (m_cnt >= m_max + 8) {
-        qDebug() << "GLFloatBuffer overflow";
-        return;
-    }
-
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.lock();
-#endif
-    buffer[m_cnt++] = x1;
-    buffer[m_cnt++] = y1;
-    buffer[m_cnt++] = x2;
-    buffer[m_cnt++] = y2;
-    buffer[m_cnt++] = x3;
-    buffer[m_cnt++] = y3;
-    buffer[m_cnt++] = x4;
-    buffer[m_cnt++] = y4;
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-
-    colors[m_colcnt++] = color2.red();
-    colors[m_colcnt++] = color2.green();
-    colors[m_colcnt++] = color2.blue();
-    colors[m_colcnt++] = color2.alpha();
-    colors[m_colcnt++] = color2.red();
-    colors[m_colcnt++] = color2.green();
-    colors[m_colcnt++] = color2.blue();
-    colors[m_colcnt++] = color2.alpha();
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.unlock();
-#endif
-}
-void GLFloatBuffer::quadGrTB(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3,
-                             GLfloat y3, GLfloat x4, GLfloat y4, QColor &color, QColor &color2)
-{
-    if (m_cnt >= m_max + 8) {
-        qDebug() << "GLFloatBuffer overflow";
-        return;
-    }
-
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.lock();
-#endif
-    buffer[m_cnt++] = x1;
-    buffer[m_cnt++] = y1;
-    buffer[m_cnt++] = x3;
-    buffer[m_cnt++] = y3;
-    buffer[m_cnt++] = x2;
-    buffer[m_cnt++] = y2;
-    buffer[m_cnt++] = x4;
-    buffer[m_cnt++] = y4;
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-    colors[m_colcnt++] = color.red();
-    colors[m_colcnt++] = color.green();
-    colors[m_colcnt++] = color.blue();
-    colors[m_colcnt++] = color.alpha();
-
-    colors[m_colcnt++] = color2.red();
-    colors[m_colcnt++] = color2.green();
-    colors[m_colcnt++] = color2.blue();
-    colors[m_colcnt++] = color2.alpha();
-    colors[m_colcnt++] = color2.red();
-    colors[m_colcnt++] = color2.green();
-    colors[m_colcnt++] = color2.blue();
-    colors[m_colcnt++] = color2.alpha();
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.unlock();
-#endif
-}
-
-void GLFloatBuffer::draw()
-{
-    if (m_cnt <= 0) {
-        return;
-    }
-
-    bool antialias = m_forceantialias || (PROFILE.appearance->antiAliasing() && m_antialias);
-    float size = m_size;
-
-    if (antialias) {
-        glEnable(GL_BLEND);
-        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);
-            size += 0.5;
-        } else if (m_type == GL_POLYGON) {
-            glEnable(GL_POLYGON_SMOOTH);
-            glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
-        }
-    }
-
-    if (m_type == GL_LINES || m_type == GL_LINE_LOOP) {
-        glLineWidth(size);
-
-        if (m_stippled) {
-            glLineStipple(1, 0xAAAA);
-            glEnable(GL_LINE_STIPPLE);
-        }
-
-        lines_drawn_this_frame += m_cnt / 2;
-    } else if (m_type == GL_POINTS) {
-        glPointSize(size);
-    } else if (m_type == GL_POLYGON) {
-        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) {
-        glScissor(s1, s2, s3, s4);
-        glEnable(GL_SCISSOR_TEST);
-    }
-
-    glVertexPointer(2, GL_FLOAT, 0, buffer);
-
-    glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
-
-    //glColor4ub(200,128,95,200);
-    glEnableClientState(GL_VERTEX_ARRAY);
-    glEnableClientState(GL_COLOR_ARRAY);
-
-
-    glDrawArrays(m_type, 0, m_cnt >> 1);
-    glDisableClientState(GL_COLOR_ARRAY);
-    glDisableClientState(GL_VERTEX_ARRAY);
-
-    //qDebug() << "I Drew" << m_cnt << "vertices";
-    m_cnt = 0;
-    m_colcnt = 0;
-
-    if (m_scissor) {
-        glDisable(GL_SCISSOR_TEST);
-        m_scissor = false;
-    }
-
-    if (m_type == GL_POLYGON) {
-        glPolygonMode(GL_BACK, GL_FILL);
-    }
-
-    if (antialias) {
-        if (m_type == GL_LINES || m_type == GL_LINE_LOOP) {
-            if (m_stippled) { glDisable(GL_LINE_STIPPLE); }
-
-            glDisable(GL_LINE_SMOOTH);
-        } else if (m_type == GL_POLYGON) {
-            glDisable(GL_POLYGON_SMOOTH);
-        }
-
-        glDisable(GL_BLEND);
-    }
-}
diff --git a/sleepyhead/Graphs/gFlagsLine.h b/sleepyhead/Graphs/gFlagsLine.h
index 4ecb92f6..f3cb469e 100644
--- a/sleepyhead/Graphs/gFlagsLine.h
+++ b/sleepyhead/Graphs/gFlagsLine.h
@@ -26,6 +26,7 @@ class gFlagsLabelArea: public gSpacer
     gFlagsLabelArea(gFlagsGroup *group);
     virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) {
         Q_UNUSED(w)
+        Q_UNUSED(painter)
         Q_UNUSED(left)
         Q_UNUSED(top)
         Q_UNUSED(width)
diff --git a/sleepyhead/Graphs/gFooBar.cpp b/sleepyhead/Graphs/gFooBar.cpp
index 1ed83a3e..32019aa0 100644
--- a/sleepyhead/Graphs/gFooBar.cpp
+++ b/sleepyhead/Graphs/gFooBar.cpp
@@ -20,11 +20,6 @@
 gShadowArea::gShadowArea(QColor shadow_color, QColor line_color)
     : Layer(NoChannel), m_shadow_color(shadow_color), m_line_color(line_color)
 {
-    addVertexBuffer(quads = new gVertexBuffer(20, GL_QUADS));
-    addVertexBuffer(lines = new gVertexBuffer(20, GL_LINES));
-    quads->forceAntiAlias(true);
-    lines->setAntiAlias(true);
-    lines->setSize(2);
 }
 gShadowArea::~gShadowArea()
 {
diff --git a/sleepyhead/Graphs/gFooBar.h b/sleepyhead/Graphs/gFooBar.h
index 6e625cd9..4d55a0bc 100644
--- a/sleepyhead/Graphs/gFooBar.h
+++ b/sleepyhead/Graphs/gFooBar.h
@@ -27,8 +27,6 @@ class gShadowArea: public Layer
   protected:
     QColor m_shadow_color;
     QColor m_line_color;
-    gVertexBuffer *quads;
-    gVertexBuffer *lines;
 };
 
 /*! \class gFooBar
diff --git a/sleepyhead/Graphs/gGraph.cpp b/sleepyhead/Graphs/gGraph.cpp
index 042eeaf5..55ba4059 100644
--- a/sleepyhead/Graphs/gGraph.cpp
+++ b/sleepyhead/Graphs/gGraph.cpp
@@ -233,18 +233,18 @@ float gGraph::printScaleX() { return m_graphview->printScaleX(); }
 float gGraph::printScaleY() { return m_graphview->printScaleY(); }
 
 
-void gGraph::drawGLBuf()
-{
+//void gGraph::drawGLBuf()
+//{
 
-    float linesize = 1;
+//    float linesize = 1;
 
-    if (m_printing) { linesize = 4; } //ceil(m_graphview->printScaleY());
+//    if (m_printing) { linesize = 4; } //ceil(m_graphview->printScaleY());
 
-    for (int i = 0; i < m_layers.size(); i++) {
-        m_layers[i]->drawGLBuf(linesize);
-    }
+//    for (int i = 0; i < m_layers.size(); i++) {
+//        m_layers[i]->drawGLBuf(linesize);
+//    }
 
-}
+//}
 void gGraph::setDay(Day *day)
 {
     m_day = day;
@@ -1294,26 +1294,6 @@ void gGraph::SetMaxY(EventDataType v)
     rmax_y = max_y = v;
 }
 
-gVertexBuffer *gGraph::lines()
-{
-    return m_graphview->lines;
-}
-
-gVertexBuffer *gGraph::backlines()
-{
-    return m_graphview->backlines;
-}
-
-gVertexBuffer *gGraph::quads()
-{
-    return m_graphview->quads;
-}
-
-short gGraph::marginLeft() { return m_marginleft; }//*m_graphview->printScaleX(); }
-short gGraph::marginRight() { return m_marginright; } //*m_graphview->printScaleX(); }
-short gGraph::marginTop() { return m_margintop; } //*m_graphview->printScaleY(); }
-short gGraph::marginBottom() { return m_marginbottom; } //*m_graphview->printScaleY(); }
-
 Layer *gGraph::getLineChart()
 {
     gLineChart *lc;
diff --git a/sleepyhead/Graphs/gGraph.h b/sleepyhead/Graphs/gGraph.h
index fe7b264d..999426d3 100644
--- a/sleepyhead/Graphs/gGraph.h
+++ b/sleepyhead/Graphs/gGraph.h
@@ -124,8 +124,8 @@ class gGraph : public QObject
     //         Applies the Graph Preference min/max settings.
     void roundY(EventDataType &miny, EventDataType &maxy);
 
-    //! \brief Process all Layers GLBuffer (Vertex) objects, drawing the actual OpenGL stuff.
-    void drawGLBuf();
+//    //! \brief Process all Layers GLBuffer (Vertex) objects, drawing the actual OpenGL stuff.
+//    void drawGLBuf();
 
     //! \brief Returns the Graph's (vertical) title
     inline QString & title() { return m_title; }
@@ -255,33 +255,19 @@ class gGraph : public QObject
     }
 
     //! \brief Returns this graphs left margin
-    short marginLeft();
+    inline short marginLeft() { return m_marginleft; }
     //! \brief Returns this graphs right margin
-    short marginRight();
+    inline short marginRight() { return m_marginright; }
     //! \brief Returns this graphs top margin
-    short marginTop();
+    inline short marginTop() { return m_margintop; }
     //! \brief Returns this graphs bottom margin
-    short marginBottom();
-
-    //! \brief Returns the main gGraphView objects gVertexBuffer line list.
-    gVertexBuffer *lines();
-    //! \brief Returns the main gGraphView objects gVertexBuffer background line list.
-    gVertexBuffer *backlines();
-    //! \brief Returns the main gGraphView objects gVertexBuffer front line list.
-    gVertexBuffer *frontlines();
-    //! \brief Returns the main gGraphView objects gVertexBuffer quads list.
-    gVertexBuffer *quads();
+    inline short marginBottom() { return m_marginbottom; }
 
     const inline QRect &rect() const { return m_rect; }
 
     bool isPinned() { return m_pinned; }
     void setPinned(bool b) { m_pinned = b; }
 
-    // //! \brief Returns the main gGraphView objects gVertexBuffer stippled line list.
-    //GLShortBuffer * stippled();
-
-    //gVertexBuffer * vlines(); // testing new vertexbuffer
-
     short left, right, top, bottom; // dirty magin hacks..
 
     Layer *getLineChart();
diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp
index 2690d50a..884a4b4c 100644
--- a/sleepyhead/Graphs/gGraphView.cpp
+++ b/sleepyhead/Graphs/gGraphView.cpp
@@ -243,7 +243,7 @@ gGraph *gGraphView::popGraph()
 }
 
 gGraphView::gGraphView(QWidget *parent, gGraphView *shared)
-  : QGLWidget(QGLFormat(QGL::Rgba | QGL::DoubleBuffer | QGL::NoOverlay), parent, shared),
+  : QGLWidget(QGLFormat(QGL::Rgba | QGL::DoubleBuffer), parent, shared),
     m_offsetY(0), m_offsetX(0), m_scaleY(1.0), m_scrollbar(nullptr)
 {
     m_shared = shared;
@@ -278,12 +278,6 @@ gGraphView::gGraphView(QWidget *parent, gGraphView *shared)
         //gt->start();
     }*/
 
-    lines = new gVertexBuffer(100000, GL_LINES); // big fat shared line list
-    backlines = new gVertexBuffer(10000, GL_LINES); // big fat shared line list
-    quads = new gVertexBuffer(1024, GL_QUADS); // big fat shared line list
-    quads->forceAntiAlias(true);
-    frontlines = new gVertexBuffer(20000, GL_LINES);
-
     //vlines=new gVertexBuffer(20000,GL_LINES);
 
     //stippled->setSize(1.5);
@@ -354,11 +348,6 @@ gGraphView::~gGraphView()
     delete m_tooltip;
     m_graphs.clear();
 
-    delete frontlines;
-    delete lines;
-    delete backlines;
-    delete quads;
-
     if (m_scrollbar) {
         this->disconnect(m_scrollbar, SIGNAL(sliderMoved(int)), 0, 0);
     }
@@ -955,167 +944,167 @@ void gGraphView::renderCube(QPainter &painter, float alpha)
 
     painter.beginNativePainting();
 
-    glViewport(0, 0, w, h);
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-    gluPerspective(45.0f, (GLfloat)w / (GLfloat)h, 0.1f, 100.0f);
-    glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
+//    glViewport(0, 0, w, h);
+//    glMatrixMode(GL_PROJECTION);
+//    glLoadIdentity();
+//    gluPerspective(45.0f, (GLfloat)w / (GLfloat)h, 0.1f, 100.0f);
+//    glMatrixMode(GL_MODELVIEW);
+//    glLoadIdentity();
 
-    /*glShadeModel(GL_SMOOTH);
-    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
-    glClearDepth(1.0f); */
-    glEnable(GL_DEPTH_TEST);
-    glDepthFunc(GL_LEQUAL);
-    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+//    /*glShadeModel(GL_SMOOTH);
+//    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
+//    glClearDepth(1.0f); */
+//    glEnable(GL_DEPTH_TEST);
+//    glDepthFunc(GL_LEQUAL);
+//    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
 
-    // This code has been shamelessly pinched of the interwebs..
-    // When I'm feeling more energetic, I'll change it to a textured sheep or something.
-    static float rotqube = 0;
+//    // This code has been shamelessly pinched of the interwebs..
+//    // When I'm feeling more energetic, I'll change it to a textured sheep or something.
+//    static float rotqube = 0;
 
-    static float xpos = 0, ypos = 7;
+//    static float xpos = 0, ypos = 7;
 
-    glLoadIdentity();
+//    glLoadIdentity();
 
-    glAlphaFunc(GL_GREATER, 0.1F);
-    glEnable(GL_ALPHA_TEST);
-    glEnable(GL_CULL_FACE);
-    glDisable(GL_COLOR_MATERIAL);
+//    glAlphaFunc(GL_GREATER, 0.1F);
+//    glEnable(GL_ALPHA_TEST);
+//    glEnable(GL_CULL_FACE);
+//    glDisable(GL_COLOR_MATERIAL);
 
-    //int imgcount=cubeimg.size();
+//    //int imgcount=cubeimg.size();
 
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+//    glEnable(GL_BLEND);
+//    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-    double xx = 0.0, yy = 0.0;
+//    double xx = 0.0, yy = 0.0;
 
-    // set this to 0 to make the cube stay in the center of the screen
-    if (1) {
-        xx = sin(M_PI / 180.0 * xpos) * 2; // ((4.0/width()) * m_mouse.rx())-2.0;
-        yy = cos(M_PI / 180.0 * ypos) * 2; //2-((4.0/height()) * m_mouse.ry());
-        xpos += 1;
-        ypos += 1.32F;
+//    // set this to 0 to make the cube stay in the center of the screen
+//    if (1) {
+//        xx = sin(M_PI / 180.0 * xpos) * 2; // ((4.0/width()) * m_mouse.rx())-2.0;
+//        yy = cos(M_PI / 180.0 * ypos) * 2; //2-((4.0/height()) * m_mouse.ry());
+//        xpos += 1;
+//        ypos += 1.32F;
 
-        if (xpos > 360) { xpos -= 360.0F; }
+//        if (xpos > 360) { xpos -= 360.0F; }
 
-        if (ypos > 360) { ypos -= 360.0F; }
-    }
+//        if (ypos > 360) { ypos -= 360.0F; }
+//    }
 
 
-    //m_mouse.x();
-    glTranslatef(xx, 0.0f, -7.0f + yy);
-    glRotatef(rotqube, 0.0f, 1.0f, 0.0f);
-    glRotatef(rotqube, 1.0f, 1.0f, 1.0f);
+//    //m_mouse.x();
+//    glTranslatef(xx, 0.0f, -7.0f + yy);
+//    glRotatef(rotqube, 0.0f, 1.0f, 0.0f);
+//    glRotatef(rotqube, 1.0f, 1.0f, 1.0f);
 
 
-    int i = 0;
-    glEnable(GL_TEXTURE_2D);
-    cubetex = bindTexture(*cubeimg[0]);
+//    int i = 0;
+//    glEnable(GL_TEXTURE_2D);
+//    cubetex = bindTexture(*cubeimg[0]);
 
-    //glBindTexture(GL_TEXTURE_2D, cubetex); //texid[i % imgcount]);
-    i++;
-    glColor4f(1, 1, 1, alpha);
+//    //glBindTexture(GL_TEXTURE_2D, cubetex); //texid[i % imgcount]);
+//    i++;
+//    glColor4f(1, 1, 1, alpha);
 
-    glBegin(GL_QUADS);
-    glTexCoord2f(0.0f, 0.0f);
-    glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
-    glTexCoord2f(1.0f, 0.0f);
-    glVertex3f(1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
-    glTexCoord2f(1.0f, 1.0f);
-    glVertex3f(1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
-    glTexCoord2f(0.0f, 1.0f);
-    glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
-    glEnd();
-    // Back Face
-    //bindTexture(*cubeimg[i % imgcount]);
-    //glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
-    i++;
-    glBegin(GL_QUADS);
-    glTexCoord2f(1.0f, 0.0f);
-    glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
-    glTexCoord2f(1.0f, 1.0f);
-    glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
-    glTexCoord2f(0.0f, 1.0f);
-    glVertex3f(1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
-    glTexCoord2f(0.0f, 0.0f);
-    glVertex3f(1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
-    glEnd();
-    // Top Face
-    //bindTexture(*cubeimg[i % imgcount]);
-    //    glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
-    i++;
-    glBegin(GL_QUADS);
-    glTexCoord2f(0.0f, 1.0f);
-    glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
-    glTexCoord2f(0.0f, 0.0f);
-    glVertex3f(-1.0f,  1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
-    glTexCoord2f(1.0f, 0.0f);
-    glVertex3f(1.0f,  1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
-    glTexCoord2f(1.0f, 1.0f);
-    glVertex3f(1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
-    glEnd();
-    // Bottom Face
-    //bindTexture(*cubeimg[i % imgcount]);
-    //glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
-    i++;
-    glBegin(GL_QUADS);
-    glTexCoord2f(1.0f, 1.0f);
-    glVertex3f(-1.0f, -1.0f, -1.0f);	// Top Right Of The Texture and Quad
-    glTexCoord2f(0.0f, 1.0f);
-    glVertex3f(1.0f, -1.0f, -1.0f);	// Top Left Of The Texture and Quad
-    glTexCoord2f(0.0f, 0.0f);
-    glVertex3f(1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
-    glTexCoord2f(1.0f, 0.0f);
-    glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
-    glEnd();
-    // Right face
-    //bindTexture(*cubeimg[i % imgcount]);
-    //    glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
-    i++;
-    glBegin(GL_QUADS);
-    glTexCoord2f(1.0f, 0.0f);
-    glVertex3f(1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
-    glTexCoord2f(1.0f, 1.0f);
-    glVertex3f(1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
-    glTexCoord2f(0.0f, 1.0f);
-    glVertex3f(1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
-    glTexCoord2f(0.0f, 0.0f);
-    glVertex3f(1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
-    glEnd();
-    // Left Face
-    //GLuint tex=bindTexture(*images["mask"]);
-    //glBindTexture(GL_TEXTURE_2D, tex);
-    i++;
-    glBegin(GL_QUADS);
-    glTexCoord2f(0.0f, 0.0f);
-    glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
-    glTexCoord2f(1.0f, 0.0f);
-    glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
-    glTexCoord2f(1.0f, 1.0f);
-    glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
-    glTexCoord2f(0.0f, 1.0f);
-    glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
-    glEnd();
+//    glBegin(GL_QUADS);
+//    glTexCoord2f(0.0f, 0.0f);
+//    glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
+//    glTexCoord2f(1.0f, 0.0f);
+//    glVertex3f(1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
+//    glTexCoord2f(1.0f, 1.0f);
+//    glVertex3f(1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
+//    glTexCoord2f(0.0f, 1.0f);
+//    glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
+//    glEnd();
+//    // Back Face
+//    //bindTexture(*cubeimg[i % imgcount]);
+//    //glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
+//    i++;
+//    glBegin(GL_QUADS);
+//    glTexCoord2f(1.0f, 0.0f);
+//    glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
+//    glTexCoord2f(1.0f, 1.0f);
+//    glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
+//    glTexCoord2f(0.0f, 1.0f);
+//    glVertex3f(1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
+//    glTexCoord2f(0.0f, 0.0f);
+//    glVertex3f(1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
+//    glEnd();
+//    // Top Face
+//    //bindTexture(*cubeimg[i % imgcount]);
+//    //    glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
+//    i++;
+//    glBegin(GL_QUADS);
+//    glTexCoord2f(0.0f, 1.0f);
+//    glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
+//    glTexCoord2f(0.0f, 0.0f);
+//    glVertex3f(-1.0f,  1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
+//    glTexCoord2f(1.0f, 0.0f);
+//    glVertex3f(1.0f,  1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
+//    glTexCoord2f(1.0f, 1.0f);
+//    glVertex3f(1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
+//    glEnd();
+//    // Bottom Face
+//    //bindTexture(*cubeimg[i % imgcount]);
+//    //glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
+//    i++;
+//    glBegin(GL_QUADS);
+//    glTexCoord2f(1.0f, 1.0f);
+//    glVertex3f(-1.0f, -1.0f, -1.0f);	// Top Right Of The Texture and Quad
+//    glTexCoord2f(0.0f, 1.0f);
+//    glVertex3f(1.0f, -1.0f, -1.0f);	// Top Left Of The Texture and Quad
+//    glTexCoord2f(0.0f, 0.0f);
+//    glVertex3f(1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
+//    glTexCoord2f(1.0f, 0.0f);
+//    glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
+//    glEnd();
+//    // Right face
+//    //bindTexture(*cubeimg[i % imgcount]);
+//    //    glBindTexture(GL_TEXTURE_2D, texid[i % imgcount]);
+//    i++;
+//    glBegin(GL_QUADS);
+//    glTexCoord2f(1.0f, 0.0f);
+//    glVertex3f(1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
+//    glTexCoord2f(1.0f, 1.0f);
+//    glVertex3f(1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
+//    glTexCoord2f(0.0f, 1.0f);
+//    glVertex3f(1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
+//    glTexCoord2f(0.0f, 0.0f);
+//    glVertex3f(1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
+//    glEnd();
+//    // Left Face
+//    //GLuint tex=bindTexture(*images["mask"]);
+//    //glBindTexture(GL_TEXTURE_2D, tex);
+//    i++;
+//    glBegin(GL_QUADS);
+//    glTexCoord2f(0.0f, 0.0f);
+//    glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
+//    glTexCoord2f(1.0f, 0.0f);
+//    glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
+//    glTexCoord2f(1.0f, 1.0f);
+//    glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
+//    glTexCoord2f(0.0f, 1.0f);
+//    glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
+//    glEnd();
 
-    glDisable(GL_BLEND);
-    glBindTexture(GL_TEXTURE_2D, 0);
+//    glDisable(GL_BLEND);
+//    glBindTexture(GL_TEXTURE_2D, 0);
 
-    glDisable(GL_ALPHA_TEST);
-    glDisable(GL_TEXTURE_2D);
-    glDisable(GL_CULL_FACE);
+//    glDisable(GL_ALPHA_TEST);
+//    glDisable(GL_TEXTURE_2D);
+//    glDisable(GL_CULL_FACE);
 
-    glDisable(GL_DEPTH_TEST);
+//    glDisable(GL_DEPTH_TEST);
 
-    rotqube += 0.9f;
+//    rotqube += 0.9f;
 
-    // Restore boring 2D reality..
-    glViewport(0, 0, w, h);
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
+//    // Restore boring 2D reality..
+//    glViewport(0, 0, w, h);
+//    glMatrixMode(GL_PROJECTION);
+//    glLoadIdentity();
 
-    glOrtho(0, width(), height(), 0, -1, 1);
-    glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
+//    glOrtho(0, width(), height(), 0, -1, 1);
+//    glMatrixMode(GL_MODELVIEW);
+//    glLoadIdentity();
 
     //  glPopMatrix();
     painter.endNativePainting();
@@ -1214,15 +1203,6 @@ bool gGraphView::renderGraphs(QPainter &painter)
         g->paint(painter, g->m_rect.x(), g->m_rect.y(), g->m_rect.width(), g->m_rect.height());
     }
 
-    backlines->draw();
-
-    for (int i = 0; i < m_graphs.size(); i++) {
-        m_graphs[i]->drawGLBuf();
-    }
-
-    quads->draw();
-    lines->draw();
-
     // can't draw snapshot text using this DrawTextQue function
     // TODO: Find a better solution for detecting when in snapshot mode
     if (m_graphs.size() > 1) {
diff --git a/sleepyhead/Graphs/gGraphView.h b/sleepyhead/Graphs/gGraphView.h
index ac662505..77d2eac9 100644
--- a/sleepyhead/Graphs/gGraphView.h
+++ b/sleepyhead/Graphs/gGraphView.h
@@ -298,8 +298,6 @@ class gGraphView : public QGLWidget
     //! \brief Sends day object to be distributed to all Graphs Layers objects
     void setDay(Day *day);
 
-    gVertexBuffer *lines, *backlines, *quads, *frontlines;
-
     //! \brief pops a graph off the list for multithreaded drawing code
     gGraph *popGraph(); // exposed for multithreaded drawing
 
diff --git a/sleepyhead/Graphs/gLineOverlay.cpp b/sleepyhead/Graphs/gLineOverlay.cpp
index c2e0410b..6abf236b 100644
--- a/sleepyhead/Graphs/gLineOverlay.cpp
+++ b/sleepyhead/Graphs/gLineOverlay.cpp
@@ -216,6 +216,8 @@ gLineOverlaySummary::~gLineOverlaySummary()
 
 void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height)
 {
+    Q_UNUSED(painter)
+
     if (!m_visible) { return; }
 
     if (!m_day) { return; }
diff --git a/sleepyhead/Graphs/gSummaryChart.cpp b/sleepyhead/Graphs/gSummaryChart.cpp
index 3e185c25..2bd7b270 100644
--- a/sleepyhead/Graphs/gSummaryChart.cpp
+++ b/sleepyhead/Graphs/gSummaryChart.cpp
@@ -19,18 +19,6 @@ extern QLabel *qstatus2;
 SummaryChart::SummaryChart(QString label, GraphType type)
     : Layer(NoChannel), m_label(label), m_graphtype(type)
 {
-    //QColor color=Qt::black;
-    addVertexBuffer(quads = new gVertexBuffer(20000, GL_QUADS));
-    addVertexBuffer(lines = new gVertexBuffer(20000, GL_LINES));
-    addVertexBuffer(outlines = new gVertexBuffer(20000, GL_LINES));
-    addVertexBuffer(points = new gVertexBuffer(20000, GL_POINTS));
-    quads->forceAntiAlias(true);
-
-    outlines->setSize(1);
-
-    //lines->setBlendFunc(GL_SRC_COLOR, GL_ZERO);
-    //lines->forceAntiAlias(false);
-
     m_empty = true;
     hl_day = -1;
     m_machinetype = MT_CPAP;
diff --git a/sleepyhead/Graphs/gVertexBuffer.cpp b/sleepyhead/Graphs/gVertexBuffer.cpp
deleted file mode 100644
index a516e1d9..00000000
--- a/sleepyhead/Graphs/gVertexBuffer.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- *
- * Copyright (c) 2011-2014 Mark Watkins <jedimark@users.sourceforge.net>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file COPYING in the main directory of the Linux
- * distribution for more details. */
-
-#include "Graphs/gVertexBuffer.h"
-
-#include "SleepLib/profiles.h"
-
-extern int lines_drawn_this_frame;
-extern int quads_drawn_this_frame;
-
-inline quint32 swaporder(quint32 color)
-{
-    return ((color & 0xFF00FF00) |
-            ((color & 0xFF0000) >> 16) |
-            ((color & 0xFF) << 16));
-}
-
-void gVertexBuffer::setColor(QColor col)
-{
-    m_color = swaporder(col.rgba());
-}
-
-void gVertexBuffer::draw()
-{
-    bool antialias = m_forceantialias || (PROFILE.appearance->antiAliasing() && m_antialias);
-
-    if (m_stippled) { antialias = false; }
-
-    float size = m_size;
-
-    if (antialias) {
-        glEnable(GL_BLEND);
-        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);
-            size += 0.5;
-        } else if (m_type == GL_POLYGON) {
-            glEnable(GL_POLYGON_SMOOTH);
-            glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
-        }
-    }
-
-    if (m_type == GL_LINES || m_type == GL_LINE_LOOP) {
-        if (m_stippled) {
-            glLineStipple(1, m_stipple);
-            //size=1;
-            glEnable(GL_LINE_STIPPLE);
-        } else {
-            //glLineStipple(1, 0xFFFF);
-        }
-
-        glLineWidth(size);
-
-        lines_drawn_this_frame += m_cnt / 2;
-    } else if (m_type == GL_POINTS) {
-        glPointSize(size);
-    } else if (m_type == GL_POLYGON) {
-        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) {
-        glScissor(s_x, s_y, s_width, s_height);
-        glEnable(GL_SCISSOR_TEST);
-    }
-
-    glEnableClientState(GL_VERTEX_ARRAY);
-    glEnableClientState(GL_COLOR_ARRAY);
-    glVertexPointer(2, GL_SHORT, 8, (GLvoid *)buffer);
-    glColorPointer(4, GL_UNSIGNED_BYTE, 8, ((char *)buffer) + 4);
-
-    glDrawArrays(m_type, 0, m_cnt);
-
-    glDisableClientState(GL_COLOR_ARRAY);
-    glDisableClientState(GL_VERTEX_ARRAY);
-    m_cnt = 0;
-
-    if (m_scissor) {
-        glDisable(GL_SCISSOR_TEST);
-        m_scissor = false;
-    }
-
-    if (m_type == GL_POLYGON) {
-        glPolygonMode(GL_BACK, GL_FILL);
-    }
-
-    if (m_type == GL_LINES || m_type == GL_LINE_LOOP) {
-        if (m_stippled) {
-            glDisable(GL_LINE_STIPPLE);
-            glLineStipple(1, 0xFFFF);
-        }
-    }
-
-    if (antialias) {
-        if (m_type == GL_LINES || m_type == GL_LINE_LOOP) {
-            glDisable(GL_LINE_SMOOTH);
-        } else if (m_type == GL_POLYGON) {
-            glDisable(GL_POLYGON_SMOOTH);
-        }
-
-        glDisable(GL_BLEND);
-    }
-}
-void gVertexBuffer::add(GLshort x1, GLshort y1, RGBA color)
-{
-    if (m_cnt < m_max) {
-        gVertex &v = buffer[m_cnt];
-
-        v.color = swaporder(color);
-        v.x = x1;
-        v.y = y1;
-
-        m_cnt++;
-    }
-}
-void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, RGBA color)
-{
-    if (m_cnt < (m_max - 1)) {
-        gVertex *v = &buffer[m_cnt];
-
-        v->x = x1;
-        v->y = y1;
-        v->color = swaporder(color);
-
-        v++;
-        v->x = x2;
-        v->y = y2;
-        v->color = swaporder(color);
-
-        m_cnt += 2;
-    }
-}
-void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3,
-                        GLshort x4, GLshort y4, RGBA color)
-{
-    if (m_cnt < (m_max - 3)) {
-        gVertex *v = &buffer[m_cnt];
-
-        v->color = swaporder(color);
-        v->x = x1;
-        v->y = y1;
-        v++;
-
-        v->color = swaporder(color);
-        v->x = x2;
-        v->y = y2;
-
-        v++;
-        v->color = swaporder(color);
-        v->x = x3;
-        v->y = y3;
-
-        v++;
-        v->color = swaporder(color);
-        v->x = x4;
-        v->y = y4;
-
-        m_cnt += 4;
-    }
-}
-
-void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3,
-                        GLshort x4, GLshort y4, RGBA color1, RGBA color2)
-{
-    if (m_cnt < (m_max - 3)) {
-        gVertex *v = &buffer[m_cnt];
-
-        v->color = swaporder(color1);
-        v->x = x1;
-        v->y = y1;
-        v++;
-
-        v->color = swaporder(color1);
-        v->x = x2;
-        v->y = y2;
-
-        v++;
-        v->color = swaporder(color2);
-        v->x = x3;
-        v->y = y3;
-
-        v++;
-        v->color = swaporder(color2);
-        v->x = x4;
-        v->y = y4;
-
-        m_cnt += 4;
-    }
-}
-void gVertexBuffer::unsafe_add(GLshort x1, GLshort y1)
-{
-    gVertex &v = buffer[m_cnt++];
-
-    v.color = m_color;
-    v.x = x1;
-    v.y = y1;
-}
-void gVertexBuffer::add(GLshort x1, GLshort y1)
-{
-    if (m_cnt < m_max) {
-        gVertex &v = buffer[m_cnt++];
-
-        v.color = m_color;
-        v.x = x1;
-        v.y = y1;
-    }
-}
-void gVertexBuffer::unsafe_add(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
-{
-    gVertex *v = &buffer[m_cnt];
-
-    v->x = x1;
-    v->y = y1;
-    v->color = m_color;
-
-    v++;
-    v->x = x2;
-    v->y = y2;
-    v->color = m_color;
-
-    m_cnt += 2;
-}
-
-void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
-{
-    if (m_cnt < (m_max - 1)) {
-        gVertex *v = &buffer[m_cnt];
-
-        v->x = x1;
-        v->y = y1;
-        v->color = m_color;
-
-        v++;
-        v->x = x2;
-        v->y = y2;
-        v->color = m_color;
-
-        m_cnt += 2;
-    }
-}
-void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3,
-                        GLshort x4, GLshort y4)
-{
-    if (m_cnt < (m_max - 3)) {
-        gVertex *v = &buffer[m_cnt];
-
-        v->color = m_color;
-        v->x = x1;
-        v->y = y1;
-        v++;
-
-        v->color = m_color;
-        v->x = x2;
-        v->y = y2;
-
-        v++;
-        v->color = m_color;
-        v->x = x3;
-        v->y = y3;
-
-        v++;
-        v->color = m_color;
-        v->x = x4;
-        v->y = y4;
-
-        m_cnt += 4;
-    }
-}
-void gVertexBuffer::unsafe_add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3,
-                               GLshort y3, GLshort x4, GLshort y4)
-{
-    gVertex *v = &buffer[m_cnt];
-
-    v->color = m_color;
-    v->x = x1;
-    v->y = y1;
-    v++;
-
-    v->color = m_color;
-    v->x = x2;
-    v->y = y2;
-
-    v++;
-    v->color = m_color;
-    v->x = x3;
-    v->y = y3;
-
-    v++;
-    v->color = m_color;
-    v->x = x4;
-    v->y = y4;
-
-    m_cnt += 4;
-}
diff --git a/sleepyhead/Graphs/glcommon.cpp b/sleepyhead/Graphs/glcommon.cpp
index fd0f3b53..4bdf75f5 100644
--- a/sleepyhead/Graphs/glcommon.cpp
+++ b/sleepyhead/Graphs/glcommon.cpp
@@ -19,79 +19,3 @@ double round(double number)
 }
 #endif
 
-
-void RoundedRectangle(int x, int y, int w, int h, int radius, const QColor color)
-{
-
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glColor4ub(color.red(), color.green(), color.blue(), color.alpha());
-
-    glBegin(GL_POLYGON);
-    glVertex2i(x + radius, y);
-    glVertex2i(x + w - radius, y);
-
-    for (float i = (float)M_PI * 1.5f; i < M_PI * 2; i += 0.1f) {
-        glVertex2f(x + w - radius + cos(i)*radius, y + radius + sin(i)*radius);
-    }
-
-    glVertex2i(x + w, y + radius);
-    glVertex2i(x + w, y + h - radius);
-
-    for (float i = 0; i < (float)M_PI * 0.5f; i += 0.1f) {
-        glVertex2f(x + w - radius + cos(i)*radius, y + h - radius + sin(i)*radius);
-    }
-
-    glVertex2i(x + w - radius, y + h);
-    glVertex2i(x + radius, y + h);
-
-    for (float i = (float)M_PI * 0.5f; i < M_PI; i += 0.1f) {
-        glVertex2f(x + radius + cos(i)*radius, y + h - radius + sin(i)*radius);
-    }
-
-    glVertex2i(x, y + h - radius);
-    glVertex2i(x, y + radius);
-
-    for (float i = (float)M_PI; i < M_PI * 1.5f; i += 0.1f) {
-        glVertex2f(x + radius + cos(i)*radius, y + radius + sin(i)*radius);
-    }
-
-    glEnd();
-
-    glDisable(GL_BLEND);
-}
-
-void LinedRoundedRectangle(int x, int y, int w, int h, int radius, int lw, QColor color)
-{
-    //glDisable(GL_TEXTURE_2D);
-    glShadeModel(GL_SMOOTH);
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glColor4ub(color.red(), color.green(), color.blue(), color.alpha());
-    glLineWidth((GLfloat)lw);
-
-    glBegin(GL_LINE_STRIP);
-
-    for (float i = (float)M_PI; i <= 1.5f * M_PI; i += 0.1f) {
-        glVertex2f(radius * cos(i) + x + radius, radius * sin(i) + y + radius);
-    }
-
-    for (float i = 1.5f * (float)M_PI; i <= 2 * M_PI; i += 0.1f) {
-        glVertex2f(radius * cos(i) + x + w - radius, radius * sin(i) + y + radius);
-    }
-
-    for (float i = 0; i <= 0.5f * M_PI; i += 0.1f) {
-        glVertex2f(radius * cos(i) + x + w - radius, radius * sin(i) + y + h - radius);
-    }
-
-    for (float i = 0.5f * (float)M_PI; i <= M_PI; i += 0.1f) {
-        glVertex2f(radius * cos(i) + x + radius, radius * sin(i) + y + h - radius);
-    }
-
-    glVertex2i(x, y + radius);
-    glEnd();
-
-    //glEnable(GL_TEXTURE_2D);
-    glDisable(GL_BLEND);
-}
-
diff --git a/sleepyhead/Graphs/glcommon.h b/sleepyhead/Graphs/glcommon.h
index d50efac7..8c8d86d8 100644
--- a/sleepyhead/Graphs/glcommon.h
+++ b/sleepyhead/Graphs/glcommon.h
@@ -12,20 +12,12 @@
 #ifndef GLCOMMON_H
 #define GLCOMMON_H
 
-#include <QtOpenGL/qgl.h>
 #include <QColor>
 
 #ifndef nullptr
 #define nullptr NULL
 #endif
 
-#ifdef Q_OS_MAC
-# define USE_RENDERTEXT
-# include "OpenGL/glu.h"
-#else
-# include "GL/glu.h"
-#endif
-
 #define MIN(a,b) (((a)<(b)) ? (a) : (b));
 #define MAX(a,b) (((a)<(b)) ? (b) : (a));
 
@@ -64,19 +56,6 @@ const QColor COLOR_ALT_BG2 =
     COLOR_White;               // Alternating Background Color 2 (Event Flags)
 
 
-/*! \brief Draw an outline of a rounded rectangle
-    \param radius Radius of corner rounding
-    \param lw Line Width
-    \param color Color of drawn lines
-    */
-void LinedRoundedRectangle(int x, int y, int w, int h, int radius, int lw, QColor color);
-
-/*! \brief Draws a filled rounded rectangle
-    \param radius Radius of corner rounding
-    \param color Color of entire rectangle
-    */
-void RoundedRectangle(int x, int y, int w, int h, int radius, const QColor color);
-
 #ifndef M_PI
 const double M_PI = 3.141592653589793;
 #endif
diff --git a/sleepyhead/Graphs/gspacer.h b/sleepyhead/Graphs/gspacer.h
index ecae2a28..a77d862a 100644
--- a/sleepyhead/Graphs/gspacer.h
+++ b/sleepyhead/Graphs/gspacer.h
@@ -24,6 +24,7 @@ class gSpacer: public Layer
     gSpacer(int space = 20); // orientation?
     virtual void paint(QPainter &painter, gGraph &g, int left, int top, int width, int height) {
         Q_UNUSED(g)
+        Q_UNUSED(painter)
         Q_UNUSED(left)
         Q_UNUSED(top)
         Q_UNUSED(width)
diff --git a/sleepyhead/Graphs/layer.cpp b/sleepyhead/Graphs/layer.cpp
index bf52431b..b7b9d88c 100644
--- a/sleepyhead/Graphs/layer.cpp
+++ b/sleepyhead/Graphs/layer.cpp
@@ -11,52 +11,53 @@
 
 Layer::~Layer()
 {
-    for (int i = 0; i < mgl_buffers.size(); i++) {
-        delete mgl_buffers[i];
-    }
+//    for (int i = 0; i < mgl_buffers.size(); i++) {
+//        delete mgl_buffers[i];
+//    }
 
-    for (int i = 0; i < mv_buffers.size(); i++) {
-        delete mv_buffers[i];
-    }
+//    for (int i = 0; i < mv_buffers.size(); i++) {
+//        delete mv_buffers[i];
+//    }
 }
-void Layer::drawGLBuf(float linesize)
-{
-    int type;
-    float size;
 
-    if (!m_visible) { return; }
+//void Layer::drawGLBuf(float linesize)
+//{
+//    int type;
+//    float size;
 
-    GLBuffer *buf;
-    gVertexBuffer *vb;
+//    if (!m_visible) { return; }
 
-    for (int i = 0; i < mv_buffers.size(); i++) {
-        vb = mv_buffers[i];
-        size = vb->size();
-        type = vb->type();
+//    GLBuffer *buf;
+//    gVertexBuffer *vb;
 
-        if ((linesize > size) && ((type == GL_LINES) || (type == GL_LINE_LOOP))) {
-            vb->setSize(linesize);
-        }
+//    for (int i = 0; i < mv_buffers.size(); i++) {
+//        vb = mv_buffers[i];
+//        size = vb->size();
+//        type = vb->type();
 
-        vb->draw();
-        vb->setSize(size);
-    }
+//        if ((linesize > size) && ((type == GL_LINES) || (type == GL_LINE_LOOP))) {
+//            vb->setSize(linesize);
+//        }
 
-    for (int i = 0; i < mgl_buffers.size(); i++) {
-        buf = mgl_buffers[i];
-        size = buf->size();
-        type = buf->type();
+//        vb->draw();
+//        vb->setSize(size);
+//    }
 
-        if ((linesize > size) && ((type == GL_LINES) || (type == GL_LINE_LOOP))) {
-            buf->setSize(linesize);
-        }
+//    for (int i = 0; i < mgl_buffers.size(); i++) {
+//        buf = mgl_buffers[i];
+//        size = buf->size();
+//        type = buf->type();
 
-        buf->draw();
-        //if ((linesize>size) && ((type==GL_LINES) || (type==GL_LINE_LOOP))) {
-        buf->setSize(size);
-        //}
-    }
-}
+//        if ((linesize > size) && ((type == GL_LINES) || (type == GL_LINE_LOOP))) {
+//            buf->setSize(linesize);
+//        }
+
+//        buf->draw();
+//        //if ((linesize>size) && ((type==GL_LINES) || (type==GL_LINE_LOOP))) {
+//        buf->setSize(size);
+//        //}
+//    }
+//}
 
 void Layer::SetDay(Day *d)
 {
@@ -110,14 +111,14 @@ bool LayerGroup::isEmpty()
 
     return empty;
 }
-void LayerGroup::drawGLBuf(float linesize)
-{
-    Layer::drawGLBuf(linesize);
+//void LayerGroup::drawGLBuf(float linesize)
+//{
+//    Layer::drawGLBuf(linesize);
 
-    for (int i = 0; i < layers.size(); i++) {
-        layers[i]->drawGLBuf(linesize);
-    }
-}
+//    for (int i = 0; i < layers.size(); i++) {
+//        layers[i]->drawGLBuf(linesize);
+//    }
+//}
 
 void LayerGroup::SetDay(Day *d)
 {
diff --git a/sleepyhead/Graphs/layer.h b/sleepyhead/Graphs/layer.h
index 6cef346a..14204352 100644
--- a/sleepyhead/Graphs/layer.h
+++ b/sleepyhead/Graphs/layer.h
@@ -134,8 +134,8 @@ class Layer
     //void X() { return m_X; }
     //void Y() { return m_Y; }
 
-    //! \brief Draw all this layers custom GLBuffers (ie. the actual OpenGL Vertices)
-    virtual void drawGLBuf(float linesize);
+//    //! \brief Draw all this layers custom GLBuffers (ie. the actual OpenGL Vertices)
+//    virtual void drawGLBuf(float linesize);
 
     //! \brief not sure why I needed the reference counting stuff.
     short m_refcount;
@@ -146,9 +146,9 @@ class Layer
     }
 
   protected:
-    //! \brief Add a GLBuffer (vertex) object customized to this layer
-    void addGLBuf(GLBuffer *buf) { mgl_buffers.push_back(buf); }
-    void addVertexBuffer(gVertexBuffer *buf) { mv_buffers.push_back(buf); }
+//    //! \brief Add a GLBuffer (vertex) object customized to this layer
+//    void addGLBuf(GLBuffer *buf) { mgl_buffers.push_back(buf); }
+//    void addVertexBuffer(gVertexBuffer *buf) { mv_buffers.push_back(buf); }
 
     //QRect bounds; // bounds, relative to top of individual graph.
     Day *m_day;
@@ -166,9 +166,9 @@ class Layer
     LayerPosition m_position;
     QRect m_rect;
 
-    //! \brief A vector containing all this layers custom drawing buffers
-    QVector<GLBuffer *> mgl_buffers;
-    QVector<gVertexBuffer *> mv_buffers;
+//    //! \brief A vector containing all this layers custom drawing buffers
+//    QVector<GLBuffer *> mgl_buffers;
+//    QVector<gVertexBuffer *> mv_buffers;
 
     //! \brief Mouse wheel moved somewhere over this layer
     virtual bool wheelEvent(QWheelEvent *event, gGraph *graph) {
@@ -241,8 +241,8 @@ class LayerGroup : public Layer
     //! \brief Calls SetDay for all Layers contained in this object
     virtual void SetDay(Day *d);
 
-    //! \brief Calls drawGLBuf for all Layers contained in this object
-    virtual void drawGLBuf(float linesize);
+//    //! \brief Calls drawGLBuf for all Layers contained in this object
+//    virtual void drawGLBuf(float linesize);
 
     //! \brief Return the list of Layers this object holds
     QVector<Layer *> &getLayers() { return layers; }
diff --git a/sleepyhead/sleepyhead.pro b/sleepyhead/sleepyhead.pro
index cb341f03..20ae7b33 100644
--- a/sleepyhead/sleepyhead.pro
+++ b/sleepyhead/sleepyhead.pro
@@ -97,7 +97,6 @@ SOURCES += \
     Graphs/gFooBar.cpp \
     Graphs/gGraph.cpp \
     Graphs/gGraphView.cpp \
-    Graphs/GLBuffer.cpp \
     Graphs/glcommon.cpp \
     Graphs/gLineChart.cpp \
     Graphs/gLineOverlay.cpp \
@@ -105,7 +104,6 @@ SOURCES += \
     Graphs/gspacer.cpp \
     Graphs/gStatsLine.cpp \
     Graphs/gSummaryChart.cpp \
-    Graphs/gVertexBuffer.cpp \
     Graphs/gXAxis.cpp \
     Graphs/gYAxis.cpp \
     Graphs/layer.cpp \