H3D API  2.4.1
ColorRGBA.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __COLORRGBA_H__
30 #define __COLORRGBA_H__
31 
32 #include <H3D/X3DColorNode.h>
33 #include <H3D/FieldTemplates.h>
34 #include <GL/glew.h>
35 #include <H3D/MFColorRGBA.h>
36 
37 namespace H3D {
61  class H3DAPI_API ColorRGBA : public X3DColorNode {
62  public:
64  ColorRGBA( Inst< MFColorRGBA> _color = 0,
65  Inst< SFNode > _metadata = 0 );
66 
68  virtual ~ColorRGBA();
69 
71  virtual RGBA getColor( unsigned int i ) {
72  return color->getValueByIndex( i );
73  }
74 
77  virtual void render( int index ) {
78  const RGBA &c = color->getValueByIndex( index );
79  glColor4f( c.r, c.g, c.b, c.a );
80  }
81 
84  virtual void renderArray();
85 
87  virtual void disableArray();
88 
90  virtual void preRender() {
92  glEnable( GL_BLEND );
93  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
94  }
95 
97  virtual void postRender() {
99  glDisable( GL_BLEND );
100  }
101 
103  virtual unsigned int nrAvailableColors() {
104  return color->size();
105  }
106 
108  virtual void setAttributeData ( );
109 
111  virtual void renderVBO ( );
112 
114  virtual void disableVBO ( );
115 
117  virtual bool preRenderCheckFail ( );
118 
124  H3DUniquePtr< MFColorRGBA > color;
125 
128  };
129 }
130 
131 #endif
Contains different templates to modify field behaviour.
Contains the MFColorRGBA field class.
Header file for X3DColorNode, X3D scene-graph node.
This node defines a set of RGBA colours to be used in the fields of another node.
Definition: ColorRGBA.h:61
virtual unsigned int nrAvailableColors()
Returns the number of color this color node can render.
Definition: ColorRGBA.h:103
virtual RGBA getColor(unsigned int i)
Get the color at index i.
Definition: ColorRGBA.h:71
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: ColorRGBA.h:127
virtual void postRender()
Disable state set in preRender() function.
Definition: ColorRGBA.h:97
virtual void render(int index)
Perform the OpenGL commands to render a color given the index of the color.
Definition: ColorRGBA.h:77
H3DUniquePtr< MFColorRGBA > color
A vector of ColorRGBA values.
Definition: ColorRGBA.h:124
virtual void preRender()
Enable state needed before rendering the color.
Definition: ColorRGBA.h:90
This is the base node type for color specifications in X3D.
Definition: X3DColorNode.h:44
virtual void preRender()
Enable state needed before rendering the color.
Definition: X3DColorNode.cpp:47
virtual void postRender()
Disable state set in preRender() function.
Definition: X3DColorNode.cpp:51
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194