From 28e0d3968ae72b0df0e7193a417eb30d1097f734 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 11 Oct 2013 15:53:16 +0300 Subject: [PATCH] Homogenise binding semantics 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 | 5 ----- source/material.h | 4 +--- source/windingtest.cpp | 15 +++------------ source/windingtest.h | 1 - 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/source/material.cpp b/source/material.cpp index 0359ab3f..12d15010 100644 --- a/source/material.cpp +++ b/source/material.cpp @@ -49,11 +49,6 @@ void Material::bind() const } } -void Material::unbind() -{ - set_current(0); -} - Material::Loader::Loader(Material &m): DataFile::ObjectLoader(m) diff --git a/source/material.h b/source/material.h index 9af86a70..3a65f339 100644 --- a/source/material.h +++ b/source/material.h @@ -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 +class Material: public BindableWithDefault { public: class Loader: public DataFile::ObjectLoader @@ -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 diff --git a/source/windingtest.cpp b/source/windingtest.cpp index acbc20fc..0b8218ad 100644 --- a/source/windingtest.cpp +++ b/source/windingtest.cpp @@ -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(); diff --git a/source/windingtest.h b/source/windingtest.h index d8a4c421..7ef36942 100644 --- a/source/windingtest.h +++ b/source/windingtest.h @@ -23,7 +23,6 @@ match the winding, the polygon is not rendered. class WindingTest: public Bindable { private: - bool test; FaceWinding winding; public: -- 2.45.2