/[libvob]/libvob/include/vob/vobs/GLState.hxx
ViewVC logotype

Diff of /libvob/include/vob/vobs/GLState.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by tjl, Tue Apr 29 11:22:41 2003 UTC revision 1.2 by tjl, Tue May 13 11:48:21 2003 UTC
# Line 11  Line 11 
11  #include <vob/Vec23.hxx>  #include <vob/Vec23.hxx>
12  #include <vob/VecGL.hxx>  #include <vob/VecGL.hxx>
13    
14    #include <sstream>
15    
16    
17  #ifndef VOB_DEFINED  #ifndef VOB_DEFINED
18  #define VOB_DEFINED(t)  #define VOB_DEFINED(t)
# Line 21  namespace Vobs { Line 23  namespace Vobs {
23    
24  using namespace Vob::VecGL;  using namespace Vob::VecGL;
25    
26    /** Transform the given GL matrix with the given transformation.
27     * Assumes that the transformation is linear in homogeneous coords.
28     */
29  struct TransMatrix {  struct TransMatrix {
30      enum { NTrans = 1 };      enum { NTrans = 1 };
31      Token matrix;      Token matrix;
# Line 38  struct TransMatrix { Line 43  struct TransMatrix {
43    
44  VOB_DEFINED(TransMatrix);  VOB_DEFINED(TransMatrix);
45    
46    extern std::string testStateRetainCorrect;
47    
48    /** Test that a given set of Vobs pushes and pops the OpenGL state appropriately.
49     * This Vob sets up the test.
50     */
51    struct TestStateRetainSetup {
52        enum { NTrans = 0 };
53        template<class F> void params(F &f) {
54            f();
55        }
56        void render() const {
57            glPushAttrib(GL_CURRENT_BIT);
58            glColor4d(.25, .50, .75, .125);
59        }
60    
61    };
62    
63    VOB_DEFINED(TestStateRetainSetup);
64    
65    /** Test that a given set of Vobs pushes and pops the OpenGL state appropriately.
66     * This Vob performs the test and sets the test result.
67     */
68    struct TestStateRetainTest {
69        enum { NTrans = 0 };
70        template<class F> void params(F &f) {
71            f();
72        }
73        void render() const {
74            glBegin(GL_TRIANGLES);
75            glVertex3f(-100,-100,100);
76            glVertex3f(-99,-100,100);
77            glVertex3f(-100,-99,100);
78            glEnd();
79            GLdouble color[4];
80            glGetDoublev(GL_CURRENT_COLOR, color);
81    #define TC(a, b) if(a != b) fail(#a, a, b);
82            TC(color[0], .25);
83            TC(color[1], .50);
84            TC(color[2], .75);
85            TC(color[3], .125);
86    
87            glPopAttrib();
88        }
89    private:
90        void fail(char *s, double v0, double v1) const {
91            std::ostringstream o;
92            o << s << ": "<<v0<<" "<<v1<<"\n";
93            testStateRetainCorrect += o.str();
94        }
95    
96    };
97    
98    VOB_DEFINED(TestStateRetainTest);
99    
100    
101  }  }
102  }  }
103    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26