H3D API
2.4.1
|
The ImageTexture node defines a texture map by specifying an image file and general parameters for mapping to geometry. More...
#include <H3D/ImageTexture.h>
Classes | |
class | CouldNotLoadImage |
CouldNotLoadImage is thrown when not any of the urls could be read with any of the image loaders in a ImageTexture. More... | |
class | SFImage |
SFImage is overridden to update the value from the url and imageLoader fields of the ImageTexture. More... | |
struct | SharedImage |
A shared texture. More... | |
Public Types | |
typedef TypedMFNode< H3DImageLoaderNode > | MFImageLoader |
A MFNode containing ImageLoader. | |
![]() | |
typedef DependentSFNode< FieldRef< TextureProperties, Field, &TextureProperties::propertyChanged > > | SFTextureProperties |
The SFTextureProperties is dependent on the propertyChanged field of the contained TextureProperties. | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
enum | LoadStatus { INIT , LOADED , LOADING , FAILED } |
The load status of the given url. More... | |
Public Member Functions | |
ImageTexture (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< MFString > _url=0, Inst< SFBool > _repeatS=0, Inst< SFBool > _repeatT=0, Inst< SFBool > _scaleToP2=0, Inst< SFImage > _image=0, Inst< MFImageLoader > _imageLoader=0, Inst< SFTextureProperties > _textureProperties=0, Inst< SFString > _loadInThread=0, Inst< SFBool > _canShare=0) | |
Constructor. | |
virtual void | render () |
render() is overridden to include the url in error messages. | |
virtual void | postRender () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | preRender () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | enableTexturing () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | disableTexturing () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual GLuint | getTextureId () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual GLuint | getTextureUnit () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual GLenum | getTextureTarget () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual int | getTextureWidth () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual int | getTextureHeight () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual int | getTextureDepth () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | setTextureId (GLuint id) |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | setTextureUnit (GLint unit) |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | setTextureTarget (GLenum target) |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | setTextureWidth (int _width) |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | setTextureHeight (int _height) |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | setTextureDepth (int _depth) |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual bool | makeResident () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | makeNonResident () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual bool | isResident () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual GLuint64 | getTextureHandle () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | invalidateTextureHandle () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual void | inUse () |
Overridden virtual function to perform the same function on the correct shared texture from the database. | |
virtual Image * | renderToImage (H3DInt32 _width, H3DInt32 _height, bool output_float_texture=false) |
override the render to image function, to download the texture_id directly from graphic card | |
virtual std::pair< H3DInt32, H3DInt32 > | getDefaultSaveDimensions () |
Returns the default dimensions to use when this texture is saved to file. More... | |
virtual GLint | glInternalFormat (Image *i) |
Returns the internal OpenGL format to use given an Image, e.g. More... | |
![]() | |
X3DTexture2DNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=0, Inst< SFBool > _repeatS=0, Inst< SFBool > _repeatT=0, Inst< SFBool > _scaleToP2=0, Inst< SFImage > _image=0, Inst< SFTextureProperties > _textureProperties=0) | |
Constructor. | |
virtual void | renderTextureProperties () |
Render all OpenGL texture properties. | |
virtual void | glTexImage (Image *_image, GLenum _texture_target, bool scale_to_power_of_two) |
Installs the given image as a OpenGL texture with a call to the glTexImage2D function. More... | |
virtual void | renderSubImage (Image *_image, GLenum _texture_target, int xoffset, int yoffset, int width, int height) |
Replaces part of the current texture from an image. | |
virtual GLenum | glPixelFormat (Image *_image) |
Returns the OpenGL pixel format to use given an Image, e.g. | |
![]() | |
H3DSingleTextureNode (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 | ~H3DSingleTextureNode () |
Destructor. | |
void | addShaderField (Field &_field) |
Add a shader field which contains this texture node. More... | |
void | removeShaderField (Field &_field) |
Remove a shader field which contains this texture node. More... | |
![]() | |
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 string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
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 GLenum | glPixelComponentType (Image *image) |
Returns the OpenGL pixel compnent type to use given an Image, e.g. 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 | 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. | |
![]() | |
H3DImageObject (Inst< SFImage > _image=0) | |
Constructor. | |
![]() | |
X3DUrlObject (Inst< MFString > _url=0) | |
Constructor. | |
virtual LoadStatus | loadStatus () |
The loadStatus function returns the status of the loading of the current urls in order to be used with the LoadSensor node. | |
virtual H3DFloat | loadProgress () |
The loadProgress() functions returns a value between 0 and 1 indicating how much of the current url has been loaded. More... | |
void | setURLUsed (const string &_url_used) |
Set the url that is currently loaded. | |
const string & | getURLUsed () |
Get the url that is currently loaded. | |
void | setURLBase (const string &_url_base) |
Set the url base address. | |
const string & | getURLBase () |
Get the current url base address. | |
string | resolveURLAsFile (const string &url, bool *is_tmp_file=NULL) |
Get the url as a local file. | |
string | resolveURLAsString (const string &url) |
Get the content of the URL as a string. | |
bool | removeTmpFile (const string &file) |
Remove a tmpfile with the given name. More... | |
Public Attributes | |
H3DUniquePtr< MFImageLoader > | imageLoader |
The ImageLoader nodes to use to read the image files. More... | |
H3DUniquePtr< SFString > | loadInThread |
Specifies the thread to use to load the image texture. More... | |
H3DUniquePtr< SFBool > | canShare |
Share image data for URLs that are the same. More... | |
![]() | |
H3DUniquePtr< SFBool > | repeatS |
If true the texture will repeat itself when the s texture coordinate is outside the range [0,1]. More... | |
H3DUniquePtr< SFBool > | repeatT |
If true the texture will repeat itself when the t texture coordinate is outside the range [0,1]. More... | |
H3DUniquePtr< SFBool > | scaleToPowerOfTwo |
If true the image used will be scaled so that the dimensions are a power of two if they are not. More... | |
H3DUniquePtr< SFTextureProperties > | textureProperties |
The textureProperties field contains a TextureProperties node which allows fine control over a texture's application. More... | |
H3DUniquePtr< UpdateTextureProperties > | updateTextureProperties |
Field that will make sure that the texture properties changes are transferred to the texture when changed. More... | |
![]() | |
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. | |
![]() | |
H3DUniquePtr< SFImage > | image |
Field containing the Image to use as a texture. | |
![]() | |
H3DUniquePtr< MFString > | url |
The urls in decreasing order of preference. | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
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 | |
bool | useSharing () |
Returns true if texture sharing should be enabled. | |
void | removeSharedImage () |
If this image is currently referencing some shared texture, remove this reference If there are no other references, the texture is deleted. | |
bool | addSharedImage (std::vector< std::string > _urls) |
Add a reference to, or create as needed, a shared texture with this url. | |
bool | texturePropertiesMatching (const ImageTexture *wrapped_image) |
Check if all the texture properties are matching those in the wrapped_image. | |
![]() | |
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... | |
![]() | |
string | resolveURL (const string &_url, bool return_contents, bool *is_tmp_file=NULL) |
Helper function for resolveURLAs*() functions. | |
void | addInlinePrefix (const string &s) |
Add a inline prefix that this node supports. | |
int | getInlinedContentOffset (const std::string &url) |
If the URL contains any inline prefix, return the index of the start of the inlined content. More... | |
Protected Attributes | |
H3DUniquePtr< H3DUtil::SimpleThread > | load_thread |
The thread used for downloading images when load_images_in_separate_thread is true. | |
ImageTexture * | wrapped_image |
Pointer to the shared texture currently in use, or NULL. | |
![]() | |
H3DUniquePtr< Field > | imageUpdated |
Field to indicate image is modified C++ only field. | |
H3DUniquePtr< Field > | textureUpdated |
Field which is used to trigger an update of the texture when it has been modified through some functions. More... | |
![]() | |
GLuint64 | texture_handle |
The texture handle (GPU) | |
GLuint | texture_id |
The OpenGL texture id of the installed texture, 0 if not installed. | |
GLint | texture_unit |
The OpenGL texture unit that is used to render this texture. More... | |
GLenum | texture_target |
The OpenGL texture target that is used to render this texture. | |
int | texture_width |
texture width | |
int | texture_height |
texture height | |
int | texture_depth |
texture depth | |
Field::FieldVector | shader_fields |
Shader fields which contain this texture. | |
H3DTime | last_used |
Time-stamp at which this texture was last used. | |
bool | is_resident |
True if this texture is currently resident. | |
![]() | |
string | url_used |
If loadStatus() returns LOADED this string should contain the url that is loaded. More... | |
string | url_base |
The base URL for urls in this url object. More... | |
list< string > | supported_inline_prefixes |
A list of inline prefixes that are supported by this url object. More... | |
Static Protected Attributes | |
static ImageDatabase | image_database |
The shared texture database. | |
![]() | |
static TextureVector | resident_textures |
List of all currently resident textures. | |
Additional Inherited Members | |
![]() | |
static void | makeUnusedTexturesNonResident (H3DTime _unusedTime) |
Look at all resident textures and make those that have not been used recently non-resident. More... | |
![]() | |
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. | |
![]() | |
typedef std::vector< H3DSingleTextureNode * > | TextureVector |
} | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
The ImageTexture node defines a texture map by specifying an image file and general parameters for mapping to geometry.
The texture is read from the URL specified by the url field using the ImageLoader nodes from the imageLoader field. The texture used will be the first texture that is successfully loaded. Each file in the url field be tried with the first ImageLoader, if none of those succeed the next ImageLoader will be tried on all the urls and so on.
Examples:
Returns the default dimensions to use when this texture is saved to file.
Returns the dimensions of the Image object
Reimplemented from H3D::X3DTexture2DNode.
References getDefaultSaveDimensions(), H3D::X3DTexture2DNode::getDefaultSaveDimensions(), and wrapped_image.
Referenced by getDefaultSaveDimensions().
|
virtual |
Returns the internal OpenGL format to use given an Image, e.g.
GL_LUMINANCE, GL_RGB, GL_RGB8, etc
Reimplemented from H3D::X3DTexture2DNode.
References H3D::X3DTextureNode::glInternalFormat(), H3D::TextureProperties::glInternalFormat(), and H3D::X3DTexture2DNode::textureProperties.
H3DUniquePtr< SFBool > H3D::ImageTexture::canShare |
Share image data for URLs that are the same.
Also requires global GraphicsOption to enable.
Note: Images with the same URL and different properties are not handled and therefore you should use this option to disable sharing of such textures.
Default value: true
Access type: inputOutput
Referenced by addSharedImage(), ImageTexture(), and useSharing().
H3DUniquePtr< MFImageLoader > H3D::ImageTexture::imageLoader |
The ImageLoader nodes to use to read the image files.
Access type: inputOutput
Default value: FreeImageLoader
Referenced by addSharedImage(), and ImageTexture().
H3DUniquePtr< SFString > H3D::ImageTexture::loadInThread |
Specifies the thread to use to load the image texture.
If "DEFAULT" then the setting in GlobalSettings will be used. If "MAIN" then the main thread is used to load the texture. If "SEPARATE" then a new thread is created and used to load the texture.
Access type: inputOutput
Default value: "DEFAULT"
Valid values: "DEFAULT", "MAIN", "SEPARATE"
Referenced by addSharedImage(), ImageTexture(), and H3D::ImageTexture::SFImage::update().