]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/graphic.cpp
Make sure classes follow the rule of 0/3/5
[libs/gltk.git] / source / graphic.cpp
index 5fc27ef3d153e5c2061ff5e891bab10a2eea5f0c..095e19441be082aed682be2f4b6a928229cbe7fb 100644 (file)
@@ -6,11 +6,6 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-Graphic::Graphic():
-       texture(0),
-       repeat(false)
-{ }
-
 void Graphic::build(unsigned wd, unsigned ht, GL::PrimitiveBuilder &bld) const
 {
        vector<float> x, y;
@@ -27,24 +22,29 @@ void Graphic::build(unsigned wd, unsigned ht, GL::PrimitiveBuilder &bld) const
        unsigned ymax = y.size()-(border.top ? 2 : 3);
 
        bld.color(1.0f, 1.0f, 1.0f);
-       bld.begin(GL::QUADS);
        for(unsigned i=ymin; i<=ymax; ++i)
        {
                unsigned i2 = (i==0 ? 0 : i==y.size()-2 ? 2 : 1);
                for(unsigned j=xmin; j<=xmax; ++j)
                {
                        unsigned j2 = (j==0 ? 0 : j==x.size()-2 ? 2 : 1);
-                       bld.texcoord(u[j2], v[i2]);
-                       bld.vertex(x[j], y[i]);
-                       bld.texcoord(u[j2+1], v[i2]);
-                       bld.vertex(x[j+1], y[i]);
+                       if(j==xmin || (j>1 && j<x.size()-2))
+                       {
+                               if(j>xmin)
+                                       bld.end();
+                               bld.begin(GL::TRIANGLE_STRIP);
+                               bld.texcoord(u[j2], v[i2+1]);
+                               bld.vertex(x[j], y[i+1]);
+                               bld.texcoord(u[j2], v[i2]);
+                               bld.vertex(x[j], y[i]);
+                       }
                        bld.texcoord(u[j2+1], v[i2+1]);
                        bld.vertex(x[j+1], y[i+1]);
-                       bld.texcoord(u[j2], v[i2+1]);
-                       bld.vertex(x[j], y[i+1]);
+                       bld.texcoord(u[j2+1], v[i2]);
+                       bld.vertex(x[j+1], y[i]);
                }
+               bld.end();
        }
-       bld.end();
 }
 
 void Graphic::create_coords(float low, float high, float brd1, float brd2, float block, vector<float> &coords) const