SoExtTexture2 Class Reference

VSG extension Extended texture mapping node. More...

#include <Inventor/nodes/SoExtTexture2.h>

Inheritance diagram for SoExtTexture2:
SoTexture SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject

List of all members.

Public Types

enum  Sync {
enum  Loading {
  AUTO = 0,
typedef void SoExtTexture2CB (void *userData, SoExtTexture2 *tex)

Public Member Functions

virtual SoType getTypeId () const
 SoExtTexture2 ()
void allowPrequalifyFile (SbBool)
void getImageSize (SbVec2s &size, int &nc)
void addOnLoadStartCB (SoExtTexture2CB *cb, void *userData)
void addOnLoadFinishCB (SoExtTexture2CB *cb, void *userData)
void addOnUnloadCB (SoExtTexture2CB *cb, void *userData)
void loadTexture ()

Static Public Member Functions

static SoType getClassTypeId ()
static void setPrequalifyFileCallBack (ExtPrequalifyFileCallback *p_cb, void *u_data)
static void setMemorySpace (double megaBytes)
static double getMemorySpace ()
static double getGlobalMemoryUsed ()
static void useTexturePalette (SbBool value)

Public Attributes

SoSFFilePathString filename
SoSFEnum wrapT
SoSFBool loadingStatus
SoSFEnum syncMode
SoSFEnum loadingMode
SoSFInt32 loadingThreadPriority

Detailed Description

VSG extension Extended texture mapping node.

This property node defines a texture map and parameters for that map. This map is used to apply texture to subsequent shapes as they are rendered.

The node is similar to SoTexture2, but differs in the following significant ways:

1. It has no image field.

2. It doesn't load the texture image into system memory until the node is traversed. Depending on the scene graph, this may significantly reduce the use of system memory, e.g., if the scene has lots of LODs containing textures. On the other hand, when the scene graph is first traversed there may be a small delay while the textures are being loaded.

3. It has additional features (e.g., support for OpenGL paletted textures) for reducing the use of texture memory.

The texture is read from the file specified by the filename field. There is no image field created. Data is sent directly to OpenGL.

The maximum system memory allowed for all SoExtTexture2 nodes (in total) can be set using setMemorySpace().

If the memory allowed for texture images (setMemorySpace()) would be exceeded by loading a new image, one or more existing images will be deleted from system memory. In most cases OpenGL texture objects will already have been created for the deleted images (i.e. OpenGL has a copy of the images), so this does not affect rendering.

If it is necessary to recreate an OpenGL texture object and the required texture image has been deleted from system memory, the node will automatically re-read the image file. For this reason, applications should be careful not to remove image files that might be needed during program execution.

To reduce the use of texture memory (by approximately a factor of 4), use the useTexturePalette() method to request the image be converted to a 256-color paletted image. This feature is available only if the driver supports the GL_EXT_paletted_texture or GL_EXT_texture_color_table extension.

If the texture image's width or height is not a power of 2, and the Non Power Of Two (NPOT) extension is available on your graphics board, by default Open Inventor will send the image to OpenGL without modification. However, if the texture image's width or height is not a power of 2 (and the Non Power Of Two (NPOT) extension is not available on your graphics board), or the image's width or height is greater than the maximum supported by OpenGL, then the image will be automatically scaled up or down to the nearest power of 2 or the maximum texture size. For maximum speed, point-sampling is used to do the scaling. If you want higher quality scaling, pre-filter your images to a power of 2 smaller than the maximum texture size. Use the OpenGL glGetIntegerv(GL_MAX_TEXTURE_SIZE...) call to determine the maximum texture dimension for a specific OpenGL implementation. Setting the environment variable OIV_USE_NPOT to 0 will force the image to be rescaled (when necessary) even if the NPOT extension is available.

The quality of the texturing is affected by the textureQuality field of the SoComplexity node. The textureQuality field affects what kind of filtering is done to the texture when it must be minified or magnified. The mapping of a particular texture quality value to a particular OpenGL filtering technique is platform dependent, and varies based on the texturing performance. If mipmap filtering is required, mipmaps are automatically created using a simple box filter.

Performance Note: Automatic scaling of texture images to a power of 2 is a very convenient feature for prototyping, but it does take additional time the first time the texture node is traversed for rendering. For large images, or a large number of images, this can make the application seem slow while starting up or loading a new data file. Avoid this effect by either pre-scaling the image or by storing it as a sub-image in a "power of 2" image (then provide explicit texture coordinates such that only the sub-image is used).




SoTexture2, SoComplexity, SoMaterial, SoTexture2Transform, SoTextureCoordinate2, SoTextureCoordinateBinding, SoTextureCoordinateFunction

See related examples:

ExtTexture2, TicTacToe

Member Typedef Documentation

typedef void SoExtTexture2::SoExtTexture2CB(void *userData, SoExtTexture2 *tex)

Member Enumeration Documentation

Loading mode.


The texture is loaded at the node's traversal.


The texture is loaded by the user using the loadTexture method.

Synchrone/asynchrone loading mode.


The loading is blocking (no thread launched).


The loading is non blocking (the loading is done within a thread).

Constructor & Destructor Documentation

SoExtTexture2::SoExtTexture2 (  ) 

Creates a texture node with default settings.

Member Function Documentation

void SoExtTexture2::addOnLoadFinishCB ( SoExtTexture2CB cb,
void *  userData 

Callback invoked when the texture is loaded and ready to use.

void SoExtTexture2::addOnLoadStartCB ( SoExtTexture2CB cb,
void *  userData 

Callback invoked when starting loading the texture.

void SoExtTexture2::addOnUnloadCB ( SoExtTexture2CB cb,
void *  userData 

Callback invoked when the texture is unloaded.

void SoExtTexture2::allowPrequalifyFile ( SbBool   ) 

If TRUE, allows the PrequalifyFile callback to be called.

static SoType SoExtTexture2::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoTexture.

static double SoExtTexture2::getGlobalMemoryUsed (  )  [static]

Return the current system memory used by all texture images.

void SoExtTexture2::getImageSize ( SbVec2s size,
int &  nc 

Returns the size and the number of components in the image.

static double SoExtTexture2::getMemorySpace (  )  [static]

Gets the system memory space allowed for the texture images.

This value is specified in megabytes (MB).

virtual SoType SoExtTexture2::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoTexture.

void SoExtTexture2::loadTexture (  ) 

Loads the texture if the loading mode is set to MANUAL.

static void SoExtTexture2::setMemorySpace ( double  megaBytes  )  [static]

Sets the system memory space allowed for the texture images.

This value is specified in megabytes (MB). The default is 16 MB.

static void SoExtTexture2::setPrequalifyFileCallBack ( ExtPrequalifyFileCallback p_cb,
void *  u_data 
) [static]

This callback is called by SoExtTexture2 nodes just before opening a file with the proposed path.

It allows you to modify the path and/or indicate that the texture has already been handled.

You could use the callback, for example, to load an image in a file format that Open Inventor doesn't natively support. The callback could

  • detect (by examining the path) that the file is of a particular format,
  • call application-supplied code to read the texture file
  • set the image into the image field of the texture node
  • set the flag indicating that the texture has been handled.
static void SoExtTexture2::useTexturePalette ( SbBool  value  )  [static]

If TRUE, uses a 256-color-indexed palette.

You must call this method before the textures are loaded. Default is FALSE.
NOTE: If the field enableCompressedTexture is set TRUE, its value takes precedence over this request to use a paletted texture. Compressed textures will be used.

Member Data Documentation

Names file from which to read texture image.

The standard image file formats are supported. See SoRasterImageRW for the list. If the filename is not an absolute path name, the list of directories maintained by SoInput is searched. If the texture is not found in any of those directories, then the file is searched for relative to the directory from which the SoTexture2 node was read. For example, if an SoTexture2 node with a filename of "../tofu.rgb" is read from /usr/people/bob/models/food.iv, then /usr/people/bob/tofu.rgb will be read (assuming tofu.rgb isn't found in the directories maintained by SoInput).

Specifies the loading mode.

Use enum Loading. Default is AUTO.

Tells if the texture is loaded or not (not necessarily displayed).

Specifies the priority of the texture loading thread when activated (syncMode = ASYNCHRONOUS).

This part uses the SbThread class.

Specifies the synchronous/asynchronous mode.

Use enum Sync. Default is SYNCHRONOUS.

Indicates what to do when texture coordinates in the T (vertical) direction lie outside the range 0-1.

Use enum SoTexture::Wrap. Default is REPEAT.

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

Open Inventor Toolkit reference manual, generated on 15 Mar 2023
Copyright © Thermo Fisher Scientific All rights reserved.