H3D API
2.4.1
|
This abstract node type is the base type for all node types which specify sources for texture images. More...
#include <H3D/X3DTextureNode.h>
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 Image * | renderToImage (H3DInt32 _width, H3DInt32 _height, bool output_float_texture=false) |
Create a new Image object which contains the result of rendering this texture. More... | |
![]() | |
X3DAppearanceChildNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (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. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
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 Field * | getField (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... | |
![]() | |
H3DDisplayListObject (Inst< DisplayList > _displayList=0) | |
Constructor. | |
Static Public Member Functions | |
static X3DTextureNode * | getActiveTexture () |
Gets the currently active texture, i.e. More... | |
static void | setActiveTexture (X3DTextureNode *t) |
Set the active texture. More... | |
![]() | |
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< UpdateSaveToURL > | saveToUrl |
When a new value is specified for saveToUrl the current texture is rendered to a buffer and saved to the specified filename. More... | |
H3DUniquePtr< SFBool > | saveSuccess |
Contains the result of the last save operation. More... | |
H3DUniquePtr< SFInt32 > | saveHeight |
The height of the image to write to file when the saveToUrl field is used. More... | |
H3DUniquePtr< SFInt32 > | saveWidth |
The width of the image to write to file when the saveToUrl field is used. More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< DisplayList > | displayList |
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 H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Protected Member Functions | |
virtual std::pair< H3DInt32, H3DInt32 > | getDefaultSaveDimensions () |
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... | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
Additional Inherited Members | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
This abstract node type is the base type for all node types which specify sources for texture images.
|
inlinevirtual |
Returns the default xml containerField attribute value.
For this node it is "texture".
Reimplemented from H3D::Node.
|
inlinestatic |
Gets the currently active texture, i.e.
the texture that is currently bound in OpenGL. NULL us returned if no X3DTextureNode is bound.
Referenced by H3D::X3DTextureCoordinateNode::disableArrayForActiveTexture(), H3D::X3DTextureCoordinateNode::disableVBOForActiveTexture(), H3D::X3DTextureCoordinateNode::disableVertexBufferObjectForActiveTexture(), H3D::X3DTextureTransformNode::postRender(), H3D::X3DTextureTransformNode::preRender(), H3D::Appearance::render(), H3D::IndexedLineSet::render(), H3D::LineSet::render(), H3D::PointSet::render(), H3D::TriangleSet2D::render(), H3D::X3DTextureCoordinateNode::renderArrayForActiveTexture(), H3D::X3DTextureCoordinateNode::renderForActiveTexture(), H3D::X3DTextureCoordinateNode::renderTexCoordForActiveTexture(), H3D::X3DTextureCoordinateNode::renderVertexBufferObjectForActiveTexture(), H3D::SuperShape::startTexGen(), H3D::ElevationGrid::startTexGen(), H3D::X3DComposedGeometryNode::startTexGen(), H3D::X3DTextureCoordinateNode::startTexGenForActiveTexture(), H3D::SuperShape::stopTexGen(), H3D::ElevationGrid::stopTexGen(), H3D::X3DComposedGeometryNode::stopTexGen(), and H3D::X3DTextureCoordinateNode::stopTexGenForActiveTexture().
|
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().
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().
|
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.
|
virtual |
Returns the internal OpenGL format to use given an Image, e.g.
GL_LUMINANCE, GL_RGB, GL_RGB8, etc
Reimplemented in H3D::ImageTexture, H3D::X3DTexture3DNode, and H3D::X3DTexture2DNode.
References H3DUtil::Image::bitsPerPixel(), H3DUtil::Image::compressionType(), H3DUtil::Image::pixelComponentType(), and H3DUtil::Image::pixelType().
Referenced by H3D::X3DTexture2DNode::glInternalFormat(), H3D::X3DTexture3DNode::glInternalFormat(), and H3D::ImageTexture::glInternalFormat().
|
virtual |
Returns the OpenGL pixel compnent type to use given an Image, e.g.
GL_BYTE, GL_UNSIGNED_INT, etc
References H3DUtil::Image::bitsPerPixel(), H3D_FULL_LOCATION, H3DUtil::Image::pixelComponentType(), and H3DUtil::Image::pixelType().
Referenced by H3D::X3DTexture2DNode::glTexImage(), H3D::X3DTexture3DNode::glTexImage(), H3D::H3DVideoTextureNode::render(), H3D::X3DTexture2DNode::renderSubImage(), H3D::X3DTexture3DNode::renderSubImage(), and H3D::X3DTexture2DNode::renderToImage().
|
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().
|
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().
|
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.
image | The image to use as texture. |
texture_target | The OpenGL texture target to use for the GL texture. E.g. GL_TEXTURE_2D. |
scale_to_power_of_two | Scale the image data to the closest higher power of two if dimensions are not a power of two. |
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().
|
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.
_width | The width of the Image to create |
_height | The height of the Image to create |
output_float_texture | Flag to define if use floating point format for texture |
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().
|
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().
|
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.
|
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().
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().
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().
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: ""
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().