| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* Further, this software is distributed without any warranty that it is |
| 16 |
* free of the rightful claim of any third person regarding infringement |
| 17 |
* or the like. Any license provided herein, whether implied or |
| 18 |
* otherwise, applies only to this software file. Patent licenses, if |
| 19 |
* any, provided herein do not apply to combinations of this program with |
| 20 |
* other software, or any other product whatsoever. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU Lesser General Public |
| 23 |
* License along with this library; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 |
* Mountain View, CA 94043, or: |
| 28 |
* |
| 29 |
* http://www.sgi.com |
| 30 |
* |
| 31 |
* For further information regarding this notice, see: |
| 32 |
* |
| 33 |
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 |
* |
| 35 |
*/ |
| 36 |
|
| 37 |
/* |
| 38 |
* Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 |
* |
| 40 |
_______________________________________________________________________ |
| 41 |
______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 |
| |
| 43 |
| $Revision: 1.1.1.1 $ |
| 44 |
| |
| 45 |
| Classes: |
| 46 |
| SoTextureQualityElement, SoTextureOverrideElement |
| 47 |
| |
| 48 |
| Author(s) : Gavin Bell |
| 49 |
| |
| 50 |
______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 51 |
_______________________________________________________________________ |
| 52 |
*/ |
| 53 |
|
| 54 |
#include <Inventor/elements/SoTextureQualityElement.h> |
| 55 |
|
| 56 |
SO_ELEMENT_SOURCE(SoTextureQualityElement); |
| 57 |
|
| 58 |
//////////////////////////////////////////////////////////////////////// |
| 59 |
// |
| 60 |
// Description: |
| 61 |
// Destructor. |
| 62 |
// |
| 63 |
// Use: private |
| 64 |
|
| 65 |
SoTextureQualityElement::~SoTextureQualityElement() |
| 66 |
// |
| 67 |
//////////////////////////////////////////////////////////////////////// |
| 68 |
{ |
| 69 |
} |
| 70 |
|
| 71 |
//////////////////////////////////////////////////////////////////////// |
| 72 |
// |
| 73 |
// Description: |
| 74 |
// Initializes element |
| 75 |
// |
| 76 |
// Use: public |
| 77 |
|
| 78 |
void |
| 79 |
SoTextureQualityElement::init(SoState *) |
| 80 |
// |
| 81 |
//////////////////////////////////////////////////////////////////////// |
| 82 |
{ |
| 83 |
data = getDefault(); |
| 84 |
} |
| 85 |
|
| 86 |
SO_ELEMENT_SOURCE(SoTextureOverrideElement); |
| 87 |
|
| 88 |
//////////////////////////////////////////////////////////////////////// |
| 89 |
// |
| 90 |
// Description: |
| 91 |
// Initializes element. All flags are initialized to FALSE (0). |
| 92 |
// |
| 93 |
// Use: public |
| 94 |
|
| 95 |
void |
| 96 |
SoTextureOverrideElement::init(SoState *) |
| 97 |
// |
| 98 |
//////////////////////////////////////////////////////////////////////// |
| 99 |
{ |
| 100 |
flags = 0; |
| 101 |
} |
| 102 |
|
| 103 |
//////////////////////////////////////////////////////////////////////// |
| 104 |
// |
| 105 |
// Description: |
| 106 |
// Pushes element, copying flags from previous top instance. |
| 107 |
// |
| 108 |
// Use: public |
| 109 |
void |
| 110 |
SoTextureOverrideElement::push(SoState *state) |
| 111 |
// |
| 112 |
//////////////////////////////////////////////////////////////////////// |
| 113 |
{ |
| 114 |
SoTextureOverrideElement *elt = |
| 115 |
(SoTextureOverrideElement *)getNextInStack(); |
| 116 |
|
| 117 |
flags = elt->flags; |
| 118 |
elt->capture(state); // Capture previous element |
| 119 |
} |
| 120 |
|
| 121 |
//////////////////////////////////////////////////////////////////////// |
| 122 |
// |
| 123 |
// Description: |
| 124 |
// Set texture quality override flag |
| 125 |
// |
| 126 |
// Use: public, static |
| 127 |
SbBool |
| 128 |
SoTextureOverrideElement::getQualityOverride(SoState *state) |
| 129 |
// |
| 130 |
//////////////////////////////////////////////////////////////////////// |
| 131 |
{ |
| 132 |
const SoTextureOverrideElement *elt; |
| 133 |
elt = (const SoTextureOverrideElement *) |
| 134 |
getConstElement(state, classStackIndex); |
| 135 |
return elt->flags & TEXTURE_QUALITY; |
| 136 |
} |
| 137 |
|
| 138 |
//////////////////////////////////////////////////////////////////////// |
| 139 |
// |
| 140 |
// Description: |
| 141 |
// Set texture image override flag |
| 142 |
// |
| 143 |
// Use: public, static |
| 144 |
SbBool |
| 145 |
SoTextureOverrideElement::getImageOverride(SoState *state) |
| 146 |
// |
| 147 |
//////////////////////////////////////////////////////////////////////// |
| 148 |
{ |
| 149 |
const SoTextureOverrideElement *elt; |
| 150 |
elt = (const SoTextureOverrideElement *) |
| 151 |
getConstElement(state, classStackIndex); |
| 152 |
return elt->flags & TEXTURE_IMAGE; |
| 153 |
} |
| 154 |
|
| 155 |
//////////////////////////////////////////////////////////////////////// |
| 156 |
// |
| 157 |
// Description: |
| 158 |
// Set texture quality override flag |
| 159 |
// |
| 160 |
// Use: public, static |
| 161 |
void |
| 162 |
SoTextureOverrideElement::setQualityOverride(SoState *state, |
| 163 |
SbBool override) |
| 164 |
// |
| 165 |
//////////////////////////////////////////////////////////////////////// |
| 166 |
{ |
| 167 |
SoTextureOverrideElement *elt; |
| 168 |
elt = (SoTextureOverrideElement *)getElement(state, classStackIndex); |
| 169 |
if (override) |
| 170 |
elt->flags |= TEXTURE_QUALITY; |
| 171 |
else |
| 172 |
elt->flags &= ~TEXTURE_QUALITY; |
| 173 |
} |
| 174 |
|
| 175 |
//////////////////////////////////////////////////////////////////////// |
| 176 |
// |
| 177 |
// Description: |
| 178 |
// Set texture image override flag |
| 179 |
// |
| 180 |
// Use: public, static |
| 181 |
void |
| 182 |
SoTextureOverrideElement::setImageOverride(SoState *state, |
| 183 |
SbBool override) |
| 184 |
// |
| 185 |
//////////////////////////////////////////////////////////////////////// |
| 186 |
{ |
| 187 |
SoTextureOverrideElement *elt; |
| 188 |
elt = (SoTextureOverrideElement *)getElement(state, classStackIndex); |
| 189 |
if (override) |
| 190 |
elt->flags |= TEXTURE_IMAGE; |
| 191 |
else |
| 192 |
elt->flags &= ~TEXTURE_IMAGE; |
| 193 |
} |
| 194 |
|
| 195 |
//////////////////////////////////////////////////////////////////////// |
| 196 |
// |
| 197 |
// Description: |
| 198 |
// Create a copy of this instance suitable for calling matches() |
| 199 |
// on. |
| 200 |
// |
| 201 |
// Use: protected |
| 202 |
|
| 203 |
SoElement * |
| 204 |
SoTextureOverrideElement::copyMatchInfo() const |
| 205 |
// |
| 206 |
//////////////////////////////////////////////////////////////////////// |
| 207 |
{ |
| 208 |
SoTextureOverrideElement *result = |
| 209 |
(SoTextureOverrideElement *)getTypeId().createInstance(); |
| 210 |
|
| 211 |
result->flags = flags; |
| 212 |
|
| 213 |
return result; |
| 214 |
} |
| 215 |
|
| 216 |
//////////////////////////////////////////////////////////////////////// |
| 217 |
// |
| 218 |
// Description: |
| 219 |
// Returns TRUE if elements match |
| 220 |
// |
| 221 |
// Use: public |
| 222 |
|
| 223 |
SbBool |
| 224 |
SoTextureOverrideElement::matches(const SoElement *elt) const |
| 225 |
// |
| 226 |
//////////////////////////////////////////////////////////////////////// |
| 227 |
{ |
| 228 |
return (flags == ((const SoTextureOverrideElement *) elt)->flags); |
| 229 |
} |
| 230 |
|
| 231 |
//////////////////////////////////////////////////////////////////////// |
| 232 |
// |
| 233 |
// Description: |
| 234 |
// Prints element for debugging. |
| 235 |
// |
| 236 |
// Use: public |
| 237 |
// |
| 238 |
//////////////////////////////////////////////////////////////////////// |
| 239 |
|
| 240 |
#ifdef DEBUG |
| 241 |
void |
| 242 |
SoTextureOverrideElement::print(FILE *fp) const |
| 243 |
{ |
| 244 |
pFlag(fp, "TEXTURE_QUALITY", TEXTURE_QUALITY); |
| 245 |
pFlag(fp, "TEXTURE_IMAGE", TEXTURE_IMAGE); |
| 246 |
putc('\n', fp); |
| 247 |
} |
| 248 |
#else /* DEBUG */ |
| 249 |
void |
| 250 |
SoTextureOverrideElement::print(FILE *) const |
| 251 |
{ |
| 252 |
} |
| 253 |
#endif /* DEBUG */ |
| 254 |
|
| 255 |
void |
| 256 |
SoTextureOverrideElement::pFlag(FILE *fp, const char *flagName, |
| 257 |
int flagBit) const |
| 258 |
{ |
| 259 |
if (flags & flagBit) |
| 260 |
fprintf(fp, "%s\t", flagName); |
| 261 |
} |