53 #include "ColorStack.hh" 54 #include <ACG/GL/GLState.hh> 134 return Vec4uc (0, 0, 0, 0);
142 currentNode_ = currentNode_->
pushIndex (_idx);
150 currentNode_ = currentNode_->
popIndex ();
157 std::vector<size_t> rv(0);
158 if (initialized_ && !error_)
160 const size_t idx = translator_.
color2index (_rgba);
161 if (idx >= root_->startIndex () && idx < root_->endIndex ())
162 root_->colorToStack (rv, idx);
173 return translator_.
max_index () - currentNode_->endIndex ();
185 return currentNode_->colorIndex ();
201 startIdx_ = endIdx_ = parent_->endIndex ();
203 startIdx_ = endIdx_ = 1;
208 ColorStack::Node::~Node ()
210 for (std::vector<Node *>::iterator it = nodes_.begin (); it != nodes_.end(); ++it)
221 if (colorStartIdx_ == 0 && translator_->
max_index () > endIdx_ + _idx)
223 colorStartIdx_ = endIdx_;
224 endIdx_ = colorEndIdx_ = colorStartIdx_ + _idx;
234 if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
247 if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
249 _rgba = translator_->
index2color(colorStartIdx_ + _idx);
260 nodes_.push_back (n);
268 parent_->endIdx_ = endIdx_;
274 void ColorStack::Node::colorToStack (std::vector<size_t> &_stack,
size_t _index)
276 if (_index >= colorStartIdx_ && _index < colorEndIdx_)
278 _stack.push_back (_index - colorStartIdx_);
282 for (std::vector<Node *>::iterator it = nodes_.begin (); it != nodes_.end(); ++it)
285 if (_index >= n->startIndex () && _index < n->endIndex ())
286 n->colorToStack (_stack, _index);
289 _stack.push_back (index_);
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
void popIndex()
pops the current node from the stack (like glPopName)
bool setIndex(size_t _idx) const
sets the current color the given index (like glLoadName)
void setIndex(size_t _idx)
sets the current color the given index (like glLoadName)
Node * pushIndex(size_t _idx)
creates a new node the stack (like glPushName)
bool setMaximumIndex(size_t _idx)
sets the maximum index number used in current node
size_t color2index(const Vec4uc _rgba) const
color -> index (one buffer)
Namespace providing different geometric functions concerning angles.
Vec4uc getIndexColor(size_t _idx)
gets the color instead of setting it directly
size_t freeIndicies() const
returns maximal available index count
Vec4uc index2color(const size_t _idx) const
index -> color (one buffer)
void initialize(ACG::GLState *)
init (takes current GL context/ like glInitNames (); glPushName (0))
ColorStack()
Default constructor.
std::vector< size_t > colorToStack(Vec4uc _rgba) const
converts the given color to index values on the stack
size_t currentIndex() const
returns the current color index
void pushIndex(size_t _idx)
creates a new node the stack (like glPushName)
bool setMaximumIndex(size_t _idx)
sets the maximum index number used in current node
Node * popIndex()
pops the current node from the stack (like glPopName)
void initialize(ACG::GLState *)
void compatibilityProfile(bool _enableCoreProfile)
Store opengl core profile setting.
size_t max_index() const
returns maximal convertible index
bool getIndexColor(size_t _idx, Vec4uc &_rgba) const
gets the color instead of setting it directly
VectorT< unsigned char, 4 > Vec4uc