H3D API  2.4.1
H3DSingleTextureNode.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 __H3DSINGLETEXTURENODE_H__
30 #define __H3DSINGLETEXTURENODE_H__
31 
32 #include <H3D/X3DTextureNode.h>
33 #include <H3D/H3DImageObject.h>
34 #include <H3D/TextureProperties.h>
36 
37 namespace H3D {
44  class H3DAPI_API H3DSingleTextureNode :
45  public X3DTextureNode {
46  public:
47 
49  H3DSingleTextureNode( Inst< DisplayList > _displayList = 0,
50  Inst< SFNode > _metadata = 0,
51  Inst< UpdateSaveToURL > _saveToUrl = 0,
52  Inst< SFBool > _saveSuccess = 0,
53  Inst< SFInt32 > _saveHeight = 0,
54  Inst< SFInt32 > _saveWidth = 0 );
55 
57  virtual ~H3DSingleTextureNode ();
58 
60  virtual GLuint getTextureId() { return texture_id; }
61 
63  virtual GLuint getTextureUnit() {return texture_unit;}
64 
66  virtual GLenum getTextureTarget() {return texture_target;}
67 
69  virtual int getTextureWidth() { return texture_width; }
70 
72  virtual int getTextureHeight() { return texture_height; }
73 
75  virtual int getTextureDepth() { return texture_depth; }
76 
78  virtual void setTextureWidth( int _width ) { texture_width = _width; }
79 
81  virtual void setTextureHeight( int _height ) { texture_height = _height; }
82 
84  virtual void setTextureDepth( int _depth ) { texture_depth = _depth; }
85 
87  virtual void setTextureId( GLuint _id ) { texture_id=_id; }
88 
90  virtual void setTextureUnit( GLint unit ) {texture_unit=unit;}
91 
93  virtual void setTextureTarget( GLenum target ) { texture_target = target; }
94 
97 
101  virtual bool makeResident ();
102 
104  virtual void makeNonResident ();
105 
107  virtual bool isResident () { return is_resident; }
108 
114  virtual GLuint64 getTextureHandle() { return texture_handle; }
115 
120  virtual void invalidateTextureHandle ();
121 
130  void addShaderField ( Field& _field );
131 
135  void removeShaderField ( Field& _field );
136 
141  virtual void inUse ();
142 
148  static void makeUnusedTexturesNonResident ( H3DTime _unusedTime );
149 
151 
152  protected:
153  typedef std::vector < H3DSingleTextureNode* > TextureVector;
154 
156  GLuint64 texture_handle;
157 
159  GLuint texture_id;
165  GLenum texture_target;
166 
169 
172 
175 
177  Field::FieldVector shader_fields;
178 
181 
184 
187  };
188 }
189 
190 #endif
Contains the DependentSFNode and DependentMFNode template classes.
Header file for H3DImageObject, X3D abstract texture scene-graph node.
Header file for TextureProperties, X3D scene-graph node.
Header file for X3DTextureNode, X3D abstract texture scene-graph node.
The Field class.
Definition: Field.h:46
This abstract node type is the base type for all texture nodes that is defined by a single texture.
Definition: H3DSingleTextureNode.h:45
H3DTime last_used
Time-stamp at which this texture was last used.
Definition: H3DSingleTextureNode.h:180
std::vector< H3DSingleTextureNode * > TextureVector
}
Definition: H3DSingleTextureNode.h:153
virtual int getTextureWidth()
Get the texture width.
Definition: H3DSingleTextureNode.h:69
virtual int getTextureDepth()
Get the texture depth.
Definition: H3DSingleTextureNode.h:75
virtual void setTextureId(GLuint _id)
Set the OpenGL texture id that is used for this texture.
Definition: H3DSingleTextureNode.h:87
GLint texture_unit
The OpenGL texture unit that is used to render this texture.
Definition: H3DSingleTextureNode.h:163
Field::FieldVector shader_fields
Shader fields which contain this texture.
Definition: H3DSingleTextureNode.h:177
virtual void setTextureHeight(int _height)
Set the texture height.
Definition: H3DSingleTextureNode.h:81
virtual void setTextureUnit(GLint unit)
Set the OpenGL texture unit that is used for this texture.
Definition: H3DSingleTextureNode.h:90
virtual GLuint getTextureId()
Get the OpenGL texture id that is used for this texture.
Definition: H3DSingleTextureNode.h:60
int texture_depth
texture depth
Definition: H3DSingleTextureNode.h:174
virtual GLuint getTextureUnit()
Get the OpenGL texture unit that is used for this texture.
Definition: H3DSingleTextureNode.h:63
GLuint texture_id
The OpenGL texture id of the installed texture, 0 if not installed.
Definition: H3DSingleTextureNode.h:159
virtual GLenum getTextureTarget()
Get the OpenGL texture target that is used for this texture.
Definition: H3DSingleTextureNode.h:66
virtual void setTextureWidth(int _width)
Set the texture width.
Definition: H3DSingleTextureNode.h:78
int texture_width
texture width
Definition: H3DSingleTextureNode.h:168
int texture_height
texture height
Definition: H3DSingleTextureNode.h:171
virtual void setTextureTarget(GLenum target)
Set the OpenGL texture target that is used for this texture.
Definition: H3DSingleTextureNode.h:93
GLenum texture_target
The OpenGL texture target that is used to render this texture.
Definition: H3DSingleTextureNode.h:165
virtual GLuint64 getTextureHandle()
Get the bindless texture handle, or 0 the texture has never been resident.
Definition: H3DSingleTextureNode.h:114
virtual int getTextureHeight()
Get the texture height.
Definition: H3DSingleTextureNode.h:72
static TextureVector resident_textures
List of all currently resident textures.
Definition: H3DSingleTextureNode.h:186
virtual bool isResident()
Returns true if the texture is resident in GPU memory or false otherwise.
Definition: H3DSingleTextureNode.h:107
bool is_resident
True if this texture is currently resident.
Definition: H3DSingleTextureNode.h:183
virtual void setTextureDepth(int _depth)
Set the texture depth.
Definition: H3DSingleTextureNode.h:84
GLuint64 texture_handle
The texture handle (GPU)
Definition: H3DSingleTextureNode.h:156
This abstract node type is the base type for all node types which specify sources for texture images.
Definition: X3DTextureNode.h:47
double H3DTime
H3D API namespace.
Definition: Anchor.h:38