H3D API  2.4.1
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
H3D::X3DTextureNode Class Referenceabstract

This abstract node type is the base type for all node types which specify sources for texture images. More...

#include <H3D/X3DTextureNode.h>

Inheritance diagram for H3D::X3DTextureNode:
Inheritance graph

Classes

class  glTexImageFunctionNotDefined
 Thrown when a subclass to X3DTextureNode calls renderImage without defining the glTexImage () function. More...
 
class  InvalidTextureDimensions
 Thrown by renderImage () if the dimensions of an image are invalid, e.g. More...
 
class  OpenGLTextureError
 Thrown when an OpenGL error occurs while setting up the texture. More...
 
class  UpdateSaveToURL
 A field used to execute the save to URL operation when the URL is set. More...
 

Public Member Functions

 X3DTextureNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< UpdateSaveToURL > _saveToUrl=0, Inst< SFBool > _saveSuccess=0, Inst< SFInt32 > _saveHeight=0, Inst< SFInt32 > _saveWidth=0)
 Constructor.
 
virtual void enableTexturing ()=0
 Virtual function for making all OpenGL calls that are needed to enable texturing for the texture.
 
virtual void disableTexturing ()=0
 Virtual function for making all OpenGL calls that are needed to disable texturing for the texture.
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual void preRender ()
 This function will be called by the X3DShapeNode before any rendering of geometry and before the call to the render function.
 
virtual void postRender ()
 This function will be called by the X3DShapeNode after the geometry has been rendered to restore the states to what it was before the call to preRender().
 
virtual GLbitfield getAffectedGLAttribs ()
 Returns a bitmask of the OpenGL attrib bits that will be affected by this node. More...
 
virtual Vec3f textureSize ()
 Sometimes the texture represents a volume in space, e.g. More...
 
virtual GLuint renderImage (Image *image, GLenum texture_target, bool scale_to_power_of_two)
 Installs the image as a OpenGL texture. More...
 
virtual GLint glInternalFormat (Image *image)
 Returns the internal OpenGL format to use given an Image, e.g. More...
 
virtual GLenum glPixelFormat (Image *image)
 Returns the OpenGL pixel format to use given an Image, e.g. More...
 
virtual GLenum glPixelComponentType (Image *image)
 Returns the OpenGL pixel compnent type to use given an Image, e.g. More...
 
virtual void glTexImage (Image *, GLenum, bool)
 Install the given image as a OpenGL texture with a call to a glTexImage function. More...
 
virtual ImagerenderToImage (H3DInt32 _width, H3DInt32 _height, bool output_float_texture=false)
 Create a new Image object which contains the result of rendering this texture. More...
 
- Public Member Functions inherited from H3D::X3DAppearanceChildNode
 X3DAppearanceChildNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DNode
 X3DNode (Inst< SFNode > _metadata=0)
 Constructor.
 
X3DMetadataObjectgetMetadataByName (const string &_name)
 Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More...
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL)
 Returns a new instance of this node type with the same state as this one. More...
 
virtual ~Node ()
 Destructor.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More...
 
void setProtoInstanceParent (X3DPrototypeInstance *p)
 Set the X3DPrototypeInstance this node is the the root node if applicaple.
 
virtual void render ()
 the render() function is used for the depth-first rendering traversal of the scene-graph. More...
 
virtual void traverseSG (TraverseInfo &ti)
 traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More...
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and the Node. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on Node to p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the Node. More...
 
virtual FieldgetField (const string &_name) const
 return a pointer to the field specified by name within this instance
 
int addDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
int removeDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
- Public Member Functions inherited from H3D::H3DDisplayListObject
 H3DDisplayListObject (Inst< DisplayList > _displayList=0)
 Constructor.
 

Static Public Member Functions

static X3DTextureNodegetActiveTexture ()
 Gets the currently active texture, i.e. More...
 
static void setActiveTexture (X3DTextureNode *t)
 Set the active texture. More...
 
- Static Public Member Functions inherited from H3D::Node
static unsigned int nrNodesAlive ()
 Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
 
static int nrNodesCreated ()
 Returns the number of nodes created in total since the start of the program.
 

Public Attributes

H3DUniquePtr< UpdateSaveToURLsaveToUrl
 When a new value is specified for saveToUrl the current texture is rendered to a buffer and saved to the specified filename. More...
 
H3DUniquePtr< SFBoolsaveSuccess
 Contains the result of the last save operation. More...
 
H3DUniquePtr< SFInt32saveHeight
 The height of the image to write to file when the saveToUrl field is used. More...
 
H3DUniquePtr< SFInt32saveWidth
 The width of the image to write to file when the saveToUrl field is used. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about the node. More...
 
- Public Attributes inherited from H3D::H3DDisplayListObject
H3DUniquePtr< DisplayListdisplayList
 The DisplayList instance handling the OpenGL caching of this object.
 

Static Public Attributes

static bool load_images_in_separate_thread = true
 This is the default value for the GlobalSettings::loadTexturesInThread field. More...
 
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Protected Member Functions

virtual std::pair< H3DInt32, H3DInt32getDefaultSaveDimensions ()
 Returns the default dimensions to use when this texture is saved to file. More...
 
GLint glCompressedInternalFormat (GLint _format, const std::string &_compression)
 Given a non-compressed internal format, return an equivelent compressed format based on the compression settings. More...
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 

Additional Inherited Members

- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 

Detailed Description

This abstract node type is the base type for all node types which specify sources for texture images.

Member Function Documentation

◆ defaultXMLContainerField()

virtual string H3D::X3DTextureNode::defaultXMLContainerField ( )
inlinevirtual

Returns the default xml containerField attribute value.

For this node it is "texture".

Reimplemented from H3D::Node.

◆ getActiveTexture()

static X3DTextureNode* H3D::X3DTextureNode::getActiveTexture ( )
inlinestatic

◆ getAffectedGLAttribs()

virtual GLbitfield H3D::X3DTextureNode::getAffectedGLAttribs ( )
inlinevirtual

Returns a bitmask of the OpenGL attrib bits that will be affected by this node.

The value can be used in glPushAttrib in order to save the current state.

Reimplemented from H3D::X3DAppearanceChildNode.

Reimplemented in H3D::GeneratedCubeMapTexture.

Referenced by H3D::Appearance::getAffectedGLAttribs(), H3D::GeneratedCubeMapTexture::getAffectedGLAttribs(), and H3D::TextureBackground::render().

◆ getDefaultSaveDimensions()

std::pair< H3DInt32, H3DInt32 > X3DTextureNode::getDefaultSaveDimensions ( )
protectedvirtual

Returns the default dimensions to use when this texture is saved to file.

Texture nodes that have dimensions should use those dimensions as the default. The default implementation returns (512, 512).

Reimplemented in H3D::X3DTexture3DNode, H3D::X3DTexture2DNode, H3D::RenderTargetTexture, H3D::ImageTexture, and H3D::GeneratedTexture.

Referenced by H3D::GeneratedTexture::getDefaultSaveDimensions(), H3D::RenderTargetTexture::getDefaultSaveDimensions(), H3D::X3DTexture2DNode::getDefaultSaveDimensions(), H3D::X3DTexture3DNode::getDefaultSaveDimensions(), and renderToImage().

◆ glCompressedInternalFormat()

GLint X3DTextureNode::glCompressedInternalFormat ( GLint  _format,
const std::string &  _compression 
)
protected

Given a non-compressed internal format, return an equivelent compressed format based on the compression settings.

Or return the original format if none is available or requested.

◆ glInternalFormat()

GLint X3DTextureNode::glInternalFormat ( Image image)
virtual

◆ glPixelComponentType()

GLenum X3DTextureNode::glPixelComponentType ( Image image)
virtual

◆ glPixelFormat()

GLenum X3DTextureNode::glPixelFormat ( Image image)
virtual

Returns the OpenGL pixel format to use given an Image, e.g.

GL_RGB, GL_LUMINANCE, etc

Reimplemented in H3D::X3DTexture3DNode, and H3D::X3DTexture2DNode.

References H3DUtil::Image::pixelType().

Referenced by H3D::X3DTexture2DNode::glPixelFormat(), and H3D::X3DTexture3DNode::glPixelFormat().

◆ glTexImage()

virtual void H3D::X3DTextureNode::glTexImage ( Image ,
GLenum  ,
bool   
)
inlinevirtual

Install the given image as a OpenGL texture with a call to a glTexImage function.

Subclasses that use the renderImage () function must define this function. By default an glTexImageFunctionNotDefined exception is thrown. if scale_to_power_of_two is true then the image data will be scaled to the closest higher power of two if dimensions are not a power of two.

Reimplemented in H3D::X3DTexture3DNode, and H3D::X3DTexture2DNode.

References H3D_FULL_LOCATION.

Referenced by renderImage().

◆ renderImage()

GLuint X3DTextureNode::renderImage ( Image image,
GLenum  texture_target,
bool  scale_to_power_of_two 
)
virtual

Installs the image as a OpenGL texture.

Uses the glTexImage function for the glTexImage call, so it has to be defined for subclasses that use this function.

Parameters
imageThe image to use as texture.
texture_targetThe OpenGL texture target to use for the GL texture. E.g. GL_TEXTURE_2D.
scale_to_power_of_twoScale the image data to the closest higher power of two if dimensions are not a power of two.
Returns
The texture id of the OpenGL texture that got installed.

References H3DUtil::Image::depth(), glTexImage(), H3D_FULL_LOCATION, H3DUtil::Image::height(), isPowerOfTwo(), H3DUtil::RefCountedClass::name, and H3DUtil::Image::width().

Referenced by H3D::X3DTexture2DNode::render(), and H3D::X3DTexture3DNode::render().

◆ renderToImage()

Image * X3DTextureNode::renderToImage ( H3DInt32  _width,
H3DInt32  _height,
bool  output_float_texture = false 
)
virtual

Create a new Image object which contains the result of rendering this texture.

The image is obtained by rendering the texture to a FBO and reading it into the image using glReadPixels.

Parameters
_widthThe width of the Image to create
_heightThe height of the Image to create
output_float_textureFlag to define if use floating point format for texture
Returns
A new Image instance, or NULL on failure.

Reimplemented in H3D::X3DTexture2DNode, and H3D::ImageTexture.

References H3D::X3D::createX3DNodeFromString(), getDefaultSaveDimensions(), H3D::Node::getField(), H3DUtil::Image::getImageData(), H3D::X3D::DEFNodes::getNode(), and H3DUtil::AutoRef< class >::reset().

Referenced by H3D::ImageTexture::renderToImage(), and H3D::X3DTexture2DNode::renderToImage().

◆ setActiveTexture()

static void H3D::X3DTextureNode::setActiveTexture ( X3DTextureNode t)
inlinestatic

Set the active texture.

The active texture is the texture that is currently in bound in OpenGL, so as soon a call to glBindTexture is made this function should be called also a pointer to the texture being bound.

Referenced by H3D::MultiTexture::render().

◆ textureSize()

virtual Vec3f H3D::X3DTextureNode::textureSize ( )
inlinevirtual

Sometimes the texture represents a volume in space, e.g.

when it contains volume data to be rendered. This function returns the size of the space the volume occupies in metres.

Reimplemented in H3D::X3DTexture3DNode.

Member Data Documentation

◆ load_images_in_separate_thread

bool X3DTextureNode::load_images_in_separate_thread = true
static

This is the default value for the GlobalSettings::loadTexturesInThread field.

If set to true the default behaviour is that all images that are read from an url will be downloaded in a separate thread allowing the program to continue execution while waiting for the textures to download. The textures will then be applied as soon as they are downloaded.

By default it is set to true.

Referenced by H3D::GlobalSettings::GlobalSettings(), H3D::Image3DTexture::SFImage::update(), and H3D::ImageTexture::SFImage::update().

◆ saveHeight

H3DUniquePtr< SFInt32 > H3D::X3DTextureNode::saveHeight

The height of the image to write to file when the saveToUrl field is used.

If -1 then a default is chosen. If this type of texture node has dimensions then these will be used as the default.

Access type: inputOutput
Default value: -1

Referenced by X3DTextureNode().

◆ saveSuccess

H3DUniquePtr< SFBool > H3D::X3DTextureNode::saveSuccess

Contains the result of the last save operation.

True if the last save operation was successful.

Access type: outputOnly
Default value: false

Referenced by X3DTextureNode().

◆ saveToUrl

H3DUniquePtr< UpdateSaveToURL > H3D::X3DTextureNode::saveToUrl

When a new value is specified for saveToUrl the current texture is rendered to a buffer and saved to the specified filename.

The URL must be a local filename.

The texture is written immediately and the success of failure of the save operation can be checked using the saveSuccess field.

Access type: inputOutput
Default value: ""

◆ saveWidth

H3DUniquePtr< SFInt32 > H3D::X3DTextureNode::saveWidth

The width of the image to write to file when the saveToUrl field is used.

If -1 then a default is chosen. If this type of texture node has dimensions then these will be used as the default.

Access type: inputOutput
Default value: -1

Referenced by X3DTextureNode().


The documentation for this class was generated from the following files: