]> git.tdb.fi Git - libs/gl.git/commitdiff
Homogenise binding semantics
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Oct 2013 12:53:16 +0000 (15:53 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Oct 2013 12:53:16 +0000 (15:53 +0300)
Objects that wrap always-on state should restore default states when
unbound.

Enable/disable of otherwise global state should be exposed through
binding, not a flag in an object.

source/material.cpp
source/material.h
source/windingtest.cpp
source/windingtest.h

index 0359ab3f332fd41b90590d229efe0391c7c22c70..12d15010e579a39af819fdb557f8669d2eadd1dc 100644 (file)
@@ -49,11 +49,6 @@ void Material::bind() const
        }
 }
 
-void Material::unbind()
-{
-       set_current(0);
-}
-
 
 Material::Loader::Loader(Material &m):
        DataFile::ObjectLoader<Material>(m)
index 9af86a700b6f5502c12b9b240f307263311a800a..3a65f339344787512f59597c1483a3596ec4376c 100644 (file)
@@ -12,7 +12,7 @@ namespace GL {
 Stores OpenGL material properties.  Since OpenGL does not support material
 objects, application of material is done with several calls to glMaterial.
 */
-class Material: public Bindable<Material>
+class Material: public BindableWithDefault<Material>
 {
 public:
        class Loader: public DataFile::ObjectLoader<Material>
@@ -47,8 +47,6 @@ public:
        const Color &get_emission() const { return emission; }
        float get_shininess() const { return shininess; }
        void bind() const;
-
-       static void unbind();
 };
 
 } // namespace GL
index acbc20fc5ba127688c89c95caa0d5207a7c66f24..0b8218adbf2773971b589c89cccefa134d403788 100644 (file)
@@ -15,12 +15,10 @@ void operator>>(const LexicalConverter &conv, FaceWinding &winding)
 }
 
 WindingTest::WindingTest():
-       test(false),
        winding(COUNTERCLOCKWISE)
 { }
 
 WindingTest::WindingTest(FaceWinding w):
-       test(true),
        winding(w)
 { }
 
@@ -28,13 +26,8 @@ void WindingTest::bind() const
 {
        if(set_current(this))
        {
-               if(test)
-               {
-                       glEnable(GL_CULL_FACE);
-                       glFrontFace(winding);
-               }
-               else
-                       glDisable(GL_CULL_FACE);
+               glEnable(GL_CULL_FACE);
+               glFrontFace(winding);
        }
 }
 
@@ -46,9 +39,7 @@ void WindingTest::unbind()
 
 const WindingTest &WindingTest::get_reverse() const
 {
-       if(!test)
-               return *this;
-       else if(winding==CLOCKWISE)
+       if(winding==CLOCKWISE)
                return counterclockwise();
        else
                return clockwise();
index d8a4c421722ed6997ab5f4162f10a74813e5d5f8..7ef36942e9b5b24c019df3f1a3b92db313f3fa9f 100644 (file)
@@ -23,7 +23,6 @@ match the winding, the polygon is not rendered.
 class WindingTest: public Bindable<WindingTest>
 {
 private:
-       bool test;
        FaceWinding winding;
 
 public: