H3D API  2.4.1
X3DTextureCoordinateNode.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 __X3DTEXTURECOORDINATENODE_H__
30 #define __X3DTEXTURECOORDINATENODE_H__
31 
33 #include <GL/glew.h>
35 
36 namespace H3D {
37  class X3DTextureNode;
38 
53  class H3DAPI_API X3DTextureCoordinateNode :
56  public:
57 
59  X3DTextureCoordinateNode( Inst< SFNode> _metadata = 0 );
60 
63  static void renderTexCoordForActiveTexture( const Vec3f &tc );
64 
67  static void renderTexCoordForTexture( const Vec3f &tc, X3DTextureNode *t );
68 
75  static void renderVertexBufferObjectForActiveTexture(
76  GLint size, GLenum type, GLsizei stride, const GLvoid *pointer );
77 
84  static void renderVertexBufferObjectForTexture(
85  GLint size, GLenum type, GLsizei stride, const GLvoid *pointer,
86  X3DTextureNode *t );
87 
91  static void disableVBOForActiveTexture();
92 
95  static void disableVBOForTexture( X3DTextureNode *t );
96 
98  // Functions for rendering texture coordinates explicitly
99 
102  virtual bool supportsExplicitTexCoords() {
103  return false;
104  }
105 
108  virtual void render( int /*index*/ ) {}
109 
111  virtual void renderForTextureUnit( int /*index*/,
112  unsigned int /*texture_unit*/ ) {}
113 
116  void renderForTextureUnits( int index,
117  unsigned int start_unit,
118  unsigned int end_unit );
119 
122  void renderForActiveTexture( int index );
123 
126  void renderForTexture( int index, X3DTextureNode *t );
127 
131  virtual unsigned int nrAvailableTexCoords() { return static_cast< unsigned int >(-1); }
132 
135  virtual void renderArray() {}
136 
139  void renderArrayForTexture( X3DTextureNode *t );
140 
143  void renderArrayForActiveTexture();
144 
147  virtual void renderArrayForTextureUnit( unsigned int texture_unit );
148 
152  void renderArrayForTextureUnits( unsigned int start_unit,
153  unsigned int end_unit );
154 
156  virtual void disableArray() {}
157 
159  void disableArrayForTexture( X3DTextureNode *t );
160 
162  void disableArrayForActiveTexture();
163 
165  virtual void disableArrayForTextureUnit( unsigned int texture_unit );
166 
168  void disableArrayForTextureUnits( unsigned int start_unit,
169  unsigned int end_unit );
170 
171 
174  void renderVertexBufferObjectForTexture( X3DTextureNode *t );
175 
178  void renderVertexBufferObjectForActiveTexture();
179 
182  virtual void renderVertexBufferObjectForTextureUnit( unsigned int texture_unit );
183 
187  void renderVertexBufferObjectForTextureUnits( unsigned int start_unit,
188  unsigned int end_unit );
189 
191  virtual void setAttributeData ( ){};
192 
194  virtual void renderVBO ( ){};
195 
197  virtual void disableVBO ( ){};
198 
201  void disableVertexBufferObjectForTexture( X3DTextureNode *t );
202 
205  void disableVertexBufferObjectForActiveTexture();
206 
209  virtual void disableVertexBufferObjectForTextureUnit( unsigned int texture_unit );
210 
213  void disableVertexBufferObjectForTextureUnits( unsigned int start_unit,
214  unsigned int end_unit );
215 
217  // Functions for nodes supporting texture coordinate generation
218 
221  virtual bool supportsTexGen() {
222  return false;
223  }
224 
227  virtual void startTexGen() {}
228 
230  virtual void stopTexGen() {}
231 
235  inline virtual bool supportsGetTexCoord( unsigned int /*texture_unit*/ ) {
236  return false;
237  }
238 
242  inline virtual Vec4f getTexCoord( int /*index*/, unsigned int /*texture_unit*/ ) {
243  return Vec4f( 0, 0, 0, 1 );
244  }
245 
248  virtual void startTexGenForTexture( X3DTextureNode *t );
249 
252  void startTexGenForActiveTexture();
253 
256  virtual void stopTexGenForTexture( X3DTextureNode *t );
257 
260  void stopTexGenForActiveTexture();
261 
265  void startTexGenForTextureUnits( unsigned int start_unit,
266  unsigned int end_unit );
267 
270  virtual void startTexGenForTextureUnit( unsigned int texture_unit );
271 
274  void stopTexGenForTextureUnits( unsigned int start_unit,
275  unsigned int end_unit );
276 
279  virtual void stopTexGenForTextureUnit( unsigned int texture_unit );
280 
283  virtual string defaultXMLContainerField() {
284  return "texCoord";
285  }
286 
287  protected:
289  unsigned int texture_index;
290  };
291 }
292 
293 #endif
Contains the GLVertexAttributeObject class.
Header file for X3DGeometricPropertyNode, X3D scene-graph node.
This abstract interface is inherited by all nodes that could be used as vertex attributes in a glsl s...
Definition: GLVertexAttributeObject.h:54
This is the base node type for all geometric property node types defined in X3D.
Definition: X3DGeometricPropertyNode.h:43
This abstract node type is the base type for all node types which specify texture coordinates.
Definition: X3DTextureCoordinateNode.h:55
virtual void renderVBO()
VBO rendering implementation.
Definition: X3DTextureCoordinateNode.h:194
virtual void disableVBO()
VBO disabling implementation.
Definition: X3DTextureCoordinateNode.h:197
virtual void renderForTextureUnit(int, unsigned int)
Render the texture coordinate for given texture unit.
Definition: X3DTextureCoordinateNode.h:111
virtual void disableArray()
Disable the array state enabled in renderArray().
Definition: X3DTextureCoordinateNode.h:156
virtual void startTexGen()
Start hardware texture coordinate generation.
Definition: X3DTextureCoordinateNode.h:227
virtual void setAttributeData()
Implement the method to specify data and releated information.
Definition: X3DTextureCoordinateNode.h:191
virtual bool supportsExplicitTexCoords()
Returns true if the node supports rendering of explicit texture coordinates.
Definition: X3DTextureCoordinateNode.h:102
unsigned int texture_index
the current texture index
Definition: X3DTextureCoordinateNode.h:289
virtual void render(int)
Perform the OpenGL commands to render a texture coordinate given the index of the texture coordinate.
Definition: X3DTextureCoordinateNode.h:108
virtual void renderArray()
Perform the OpenGL commands to render all texture coordinates as an arary.
Definition: X3DTextureCoordinateNode.h:135
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: X3DTextureCoordinateNode.h:283
virtual void stopTexGen()
Stop the texture coordinate generation started with startTexGen().
Definition: X3DTextureCoordinateNode.h:230
virtual bool supportsTexGen()
Returns true if the node supports rendering of explicit texture coordinates.
Definition: X3DTextureCoordinateNode.h:221
virtual unsigned int nrAvailableTexCoords()
Returns the number of texture coordinates this node can render.
Definition: X3DTextureCoordinateNode.h:131
virtual bool supportsGetTexCoord(unsigned int)
Returns true if the getTexCoord function is available for use.
Definition: X3DTextureCoordinateNode.h:235
virtual Vec4f getTexCoord(int, unsigned int)
Gets texture coordinate of the given index and texture unit.
Definition: X3DTextureCoordinateNode.h:242
This abstract node type is the base type for all node types which specify sources for texture images.
Definition: X3DTextureNode.h:47
Vec4f()
H3D API namespace.
Definition: Anchor.h:38