Add more structure constructor tests.
[piglit/hramrach.git] / tests / glean / ttexcombine.h
blobfd840e183c2075313efc6d797a6bd7f1d68cc0e9
1 // BEGIN_COPYRIGHT -*- glean -*-
2 //
3 // Copyright (C) 1999 Allen Akin All Rights Reserved.
4 //
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
12 // conditions:
13 //
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the
16 // Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 // KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 // DEALINGS IN THE SOFTWARE.
26 //
27 // END_COPYRIGHT
30 // ttexcombing.h: Test the GL_EXT_texture_env_combine extension
31 // Author: Brian Paul (brianp@valinux.com) September 2000
34 #ifndef __ttexcombine_h__
35 #define __ttexcombine_h__
37 #include "tbasic.h"
39 namespace GLEAN {
41 #define MAX_TEX_UNITS 8
43 class TexCombineTest: public BasicTest {
44 public:
45 TexCombineTest(const char* testName, const char* filter,
46 const char* description):
47 #if (__AGL__)
48 BasicTest(testName, filter, "GL_ARB_texture_env_combine",
49 description) {
50 #else
51 BasicTest(testName, filter, "GL_EXT_texture_env_combine",
52 description) {
53 #endif
54 fWidth = 2;
55 fHeight = 2;
58 virtual void runOne(BasicResult& r, Window& w);
59 virtual void logOne(BasicResult& r);
61 private:
62 // Our model of GL machine state
63 struct glmachine {
64 GLenum COMBINE_RGB[MAX_TEX_UNITS];
65 GLenum COMBINE_ALPHA[MAX_TEX_UNITS];
66 GLenum SOURCE0_RGB[MAX_TEX_UNITS];
67 GLenum SOURCE1_RGB[MAX_TEX_UNITS];
68 GLenum SOURCE2_RGB[MAX_TEX_UNITS];
69 GLenum SOURCE0_ALPHA[MAX_TEX_UNITS];
70 GLenum SOURCE1_ALPHA[MAX_TEX_UNITS];
71 GLenum SOURCE2_ALPHA[MAX_TEX_UNITS];
72 GLenum OPERAND0_RGB[MAX_TEX_UNITS];
73 GLenum OPERAND1_RGB[MAX_TEX_UNITS];
74 GLenum OPERAND2_RGB[MAX_TEX_UNITS];
75 GLenum OPERAND0_ALPHA[MAX_TEX_UNITS];
76 GLenum OPERAND1_ALPHA[MAX_TEX_UNITS];
77 GLenum OPERAND2_ALPHA[MAX_TEX_UNITS];
78 GLfloat RGB_SCALE[MAX_TEX_UNITS];
79 GLfloat ALPHA_SCALE[MAX_TEX_UNITS];
80 GLfloat FragColor[4]; // fragment color
81 GLfloat EnvColor[MAX_TEX_UNITS][4]; // texture env color
82 GLfloat TexColor[MAX_TEX_UNITS][4]; // texture image color
83 GLenum TexFormat[MAX_TEX_UNITS]; // texture base format
84 int NumTexUnits;
87 // describes possible state combinations
88 struct test_param {
89 GLenum target;
90 GLenum validValues[6];
93 glmachine Machine;
94 static test_param ReplaceParams[];
95 static test_param ModulateParams[];
96 static test_param AddParams[];
97 static test_param AddSignedParams[];
98 static test_param InterpolateParams[];
99 static test_param Dot3RGBParams[];
100 static test_param Dot3RGBAParams[];
101 static test_param MultitexParams[];
102 static test_param CrossbarParams[];
103 bool haveDot3;
104 bool haveCrossbar;
105 GLfloat mTolerance[4];
106 GLuint mTextures[MAX_TEX_UNITS];
107 int testStride;
109 void ResetMachine(glmachine &machine);
110 void ComputeTexCombine(const glmachine &machine, int texUnit,
111 const GLfloat prevColor[4], GLfloat result[4]) const;
112 void PrintMachineState(const glmachine &machine) const;
113 bool VerifyMachineState(const glmachine &machine) const;
114 void ReportFailure(const glmachine &machine, const GLfloat expected[4],
115 const GLfloat rendered[4], BasicResult &r, const char *where);
116 void TexEnv(glmachine &machine, int texUnit, GLenum target,
117 GLenum value);
118 void SetupTestEnv(glmachine &machine, int texUnit, int testNum,
119 const test_param testParams[]);
120 void SetupColors(struct glmachine &machine);
121 int CountTestCombinations(const test_param testParams[]) const;
122 bool RunSingleTextureTest(glmachine &machine,
123 const test_param testParams[], BasicResult &r, Window &w);
124 int CountMultiTextureTestCombinations(const glmachine &machine) const;
125 bool RunMultiTextureTest(glmachine &machine, BasicResult &r, Window &w);
126 int CountCrossbarCombinations() const;
127 bool RunCrossbarTest(glmachine &machine, BasicResult &r, Window &w);
129 PFNGLACTIVETEXTUREARBPROC p_glActiveTextureARB;
130 PFNGLMULTITEXCOORD2FARBPROC p_glMultiTexCoord2fARB;
132 }; // class TexCombineTest
134 } // namespace GLEAN
136 #endif // __ttexcombine_h__