H3D::X3DTextureNode Class Reference
[Abstract nodes.]

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

List of all members.

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...

Public Member Functions

 X3DTextureNode (Inst< DisplayList > _displayList=0, Inst< SFNode > _metadata=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.
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 Vec3f textureSize ()
 Sometimes the texture represents a volume in space, e.g.
virtual GLuint renderImage (Image *image, GLenum texture_target, bool scale_to_power_of_two)
 Installs the image as a OpenGL texture.
virtual GLint glInternalFormat (Image *image)
 Returns the internal OpenGL format to use given an Image, e.g.
virtual GLenum glPixelFormat (Image *image)
 Returns the OpenGL pixel format to use given an Image, e.g.
virtual GLenum glPixelComponentType (Image *image)
 Returns the OpenGL pixel compnent type to use given an Image, e.g.
virtual void glTexImage (Image *image, GLenum texture_target, bool scale_to_power_of_two)
 Install the given image as a OpenGL texture with a call to a glTexImage function.

Static Public Member Functions

static X3DTextureNodegetActiveTexture ()
 Gets the currently active texture, i.e.

Static Public Attributes

static bool load_images_in_separate_thread = true
 If set to true 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.

Static Protected Member Functions

static void setActiveTexture (X3DTextureNode *t)
 Set the active texture.


Detailed Description

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

Member Function Documentation

virtual string H3D::X3DTextureNode::defaultXMLContainerField (  )  [inline, virtual]

Returns the default xml containerField attribute value.

For this node it is "texture".

Reimplemented from H3D::Node.

static X3DTextureNode* H3D::X3DTextureNode::getActiveTexture (  )  [inline, static]

GLint X3DTextureNode::glInternalFormat ( Image image  )  [virtual]

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

GL_LUMINANCE, GL_RGB, GL_RGB8, etc

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

References H3DUtil::Image::bitsPerPixel(), and H3DUtil::Image::pixelType().

GLenum X3DTextureNode::glPixelComponentType ( Image image  )  [virtual]

GLenum X3DTextureNode::glPixelFormat ( Image image  )  [virtual]

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

GL_RGB, GL_LUMINANCE, etc

References H3DUtil::Image::pixelType().

Referenced by H3D::X3DTexture3DNode::glTexImage(), H3D::X3DTexture2DNode::glTexImage(), H3D::X3DTexture3DNode::renderSubImage(), and H3D::X3DTexture2DNode::renderSubImage().

virtual void H3D::X3DTextureNode::glTexImage ( Image image,
GLenum  texture_target,
bool  scale_to_power_of_two 
) [inline, virtual]

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::X3DTexture2DNode, and H3D::X3DTexture3DNode.

References H3D_FULL_LOCATION.

Referenced by renderImage().

virtual void H3D::X3DTextureNode::postRender (  )  [inline, virtual]

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().

Reimplemented from H3D::X3DAppearanceChildNode.

Reimplemented in H3D::GeneratedCubeMapTexture.

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

virtual void H3D::X3DTextureNode::preRender (  )  [inline, virtual]

This function will be called by the X3DShapeNode before any rendering of geometry and before the call to the render function.

So this is the place to save the states that are going to be changed in render() in order to restore it in postRender().

Reimplemented from H3D::X3DAppearanceChildNode.

Reimplemented in H3D::GeneratedCubeMapTexture.

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

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:
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.
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::X3DTexture3DNode::render(), and H3D::X3DTexture2DNode::render().

static void H3D::X3DTextureNode::setActiveTexture ( X3DTextureNode t  )  [inline, static, protected]

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().

virtual Vec3f H3D::X3DTextureNode::textureSize (  )  [inline, virtual]

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

If set to true 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::ImageTexture::SFImage::update(), and H3D::Image3DTexture::SFImage::update().


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

Generated on Fri Nov 7 10:31:33 2008 for H3D API by  doxygen 1.5.7