1 // BEGIN_COPYRIGHT -*- glean -*-
3 // Copyright (C) 1999 Allen Akin All Rights Reserved.
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
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the
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.
29 // tgetstr.cpp: implementation of OpenGL glGetString() tests
38 ///////////////////////////////////////////////////////////////////////////////
39 // runOne: Run a single test case
40 ///////////////////////////////////////////////////////////////////////////////
42 GetStringTest::runOne(GetStringResult
& r
, Window
&) {
43 r
.vendor
= reinterpret_cast<const char*>(glGetString(GL_VENDOR
));
44 r
.renderer
= reinterpret_cast<const char*>(glGetString(GL_RENDERER
));
45 r
.version
= reinterpret_cast<const char*>(glGetString(GL_VERSION
));
46 r
.extensions
= reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS
));
48 } // GetStringTest::runOne
50 ///////////////////////////////////////////////////////////////////////////////
51 // logOne: Log a single test case
52 ///////////////////////////////////////////////////////////////////////////////
54 GetStringTest::logOne(GetStringResult
& r
) {
57 if (env
->options
.verbosity
) {
58 env
->log
<< "\tvendor: " << r
.vendor
<< '\n';
59 env
->log
<< "\trenderer: " << r
.renderer
<< '\n';
60 env
->log
<< "\tversion: " << r
.version
<< '\n';
61 env
->log
<< "\textensions: " << r
.extensions
<< '\n';
63 } // GetStringTest::logOne
65 ///////////////////////////////////////////////////////////////////////////////
66 // compareOne: Compare results for a single test case
67 ///////////////////////////////////////////////////////////////////////////////
69 GetStringTest::compareOne(GetStringResult
& oldR
, GetStringResult
& newR
) {
70 if (oldR
.vendor
== newR
.vendor
&& oldR
.renderer
== newR
.renderer
71 && oldR
.version
== newR
.version
&& oldR
.extensions
== newR
.extensions
){
72 if (env
->options
.verbosity
)
73 env
->log
<< name
<< ": SAME " <<
74 newR
.config
->conciseDescription() << '\n';
76 env
->log
<< name
<< ": DIFF "
77 << newR
.config
->conciseDescription() << '\n';
78 if (oldR
.vendor
!= newR
.vendor
) {
79 env
->log
<< '\t' << env
->options
.db1Name
80 << " vendor: " << oldR
.vendor
;
81 env
->log
<< '\t' << env
->options
.db2Name
82 << " vendor: " << newR
.vendor
;
84 if (oldR
.renderer
!= newR
.renderer
) {
85 env
->log
<< '\t' << env
->options
.db1Name
86 << " renderer: " << oldR
.renderer
;
87 env
->log
<< '\t' << env
->options
.db2Name
88 << " renderer: " << newR
.renderer
;
90 if (oldR
.version
!= newR
.version
) {
91 env
->log
<< '\t' << env
->options
.db1Name
92 << " version: " << oldR
.version
;
93 env
->log
<< '\t' << env
->options
.db2Name
94 << " version: " << newR
.version
;
96 if (oldR
.extensions
!= newR
.extensions
) {
97 vector
<string
> oldExts
;
98 Lex
oldLex(oldR
.extensions
.c_str());
101 if (oldLex
.token
== Lex::ID
)
102 oldExts
.push_back(oldLex
.id
);
106 sort(oldExts
.begin(), oldExts
.end());
108 vector
<string
> newExts
;
109 Lex
newLex(newR
.extensions
.c_str());
112 if (newLex
.token
== Lex::ID
)
113 newExts
.push_back(newLex
.id
);
117 sort(newExts
.begin(), newExts
.end());
119 vector
<string
> d(max(oldExts
.size(), newExts
.size()));
120 vector
<string
>::iterator dEnd
;
122 dEnd
= set_difference(oldExts
.begin(), oldExts
.end(),
123 newExts
.begin(), newExts
.end(), d
.begin());
124 if (dEnd
!= d
.begin()) {
125 env
->log
<< "\tExtensions in " <<
126 env
->options
.db1Name
<< " but not in "
127 << env
->options
.db2Name
<< ":\n";
128 for (vector
<string
>::iterator p
= d
.begin();
130 env
->log
<< "\t\t" << *p
<< '\n';
133 dEnd
= set_difference(newExts
.begin(), newExts
.end(),
134 oldExts
.begin(), oldExts
.end(), d
.begin());
135 if (dEnd
!= d
.begin()) {
136 env
->log
<< "\tExtensions in " <<
137 env
->options
.db2Name
<< " but not in "
138 << env
->options
.db1Name
<< ":\n";
139 for (vector
<string
>::iterator p
= d
.begin();
141 env
->log
<< "\t\t" << *p
<< '\n';
144 dEnd
= set_intersection(newExts
.begin(), newExts
.end(),
145 oldExts
.begin(), oldExts
.end(), d
.begin());
146 if (dEnd
!= d
.begin()) {
147 env
->log
<< "\tExtensions in both " <<
148 env
->options
.db2Name
<< " and in "
149 << env
->options
.db1Name
<< ":\n";
150 for (vector
<string
>::iterator p
= d
.begin();
152 env
->log
<< "\t\t" << *p
<< '\n';
156 } // GetStringTest::compareOne
158 ///////////////////////////////////////////////////////////////////////////////
159 // The test object itself:
160 ///////////////////////////////////////////////////////////////////////////////
161 GetStringTest
getStringTest("getString", "window",
162 "This test checks the contents of the strings returned by\n"
163 "glGetString(): the vendor name, renderer name, version, and\n"
164 "extensions. It is run on every OpenGL-capable drawing surface\n"
165 "configuration that supports creation of a window.\n");