OpenImageIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
TextureSystem Class Referenceabstract

#include <texture.h>

Public Member Functions

virtual void clear ()=0
 
virtual bool attribute (const std::string &name, TypeDesc type, const void *val)=0
 
virtual bool attribute (const std::string &name, int val)=0
 
virtual bool attribute (const std::string &name, float val)=0
 
virtual bool attribute (const std::string &name, double val)=0
 
virtual bool attribute (const std::string &name, const char *val)=0
 
virtual bool attribute (const std::string &name, const std::string &val)=0
 
virtual bool getattribute (const std::string &name, TypeDesc type, void *val)=0
 Get the named attribute, store it in value.
 
virtual bool getattribute (const std::string &name, int &val)=0
 
virtual bool getattribute (const std::string &name, float &val)=0
 
virtual bool getattribute (const std::string &name, double &val)=0
 
virtual bool getattribute (const std::string &name, char **val)=0
 
virtual bool getattribute (const std::string &name, std::string &val)=0
 
virtual Perthread * get_perthread_info ()=0
 
virtual TextureHandle * get_texture_handle (ustring filename, Perthread *thread_info=NULL)=0
 
virtual bool texture (ustring filename, TextureOpt &options, float s, float t, float dsdx, float dtdx, float dsdy, float dtdy, float *result)=0
 
virtual bool texture (TextureHandle *texture_handle, Perthread *thread_info, TextureOpt &options, float s, float t, float dsdx, float dtdx, float dsdy, float dtdy, float *result)=0
 
virtual bool texture (ustring filename, TextureOptions &options, float s, float t, float dsdx, float dtdx, float dsdy, float dtdy, float *result)=0
 
virtual bool texture (ustring filename, TextureOptions &options, Runflag *runflags, int beginactive, int endactive, VaryingRef< float > s, VaryingRef< float > t, VaryingRef< float > dsdx, VaryingRef< float > dtdx, VaryingRef< float > dsdy, VaryingRef< float > dtdy, float *result)=0
 
virtual bool texture3d (ustring filename, TextureOpt &options, const Imath::V3f &P, const Imath::V3f &dPdx, const Imath::V3f &dPdy, const Imath::V3f &dPdz, float *result)=0
 
virtual bool texture3d (TextureHandle *texture_handle, Perthread *thread_info, TextureOpt &options, const Imath::V3f &P, const Imath::V3f &dPdx, const Imath::V3f &dPdy, const Imath::V3f &dPdz, float *result)=0
 
virtual bool texture3d (ustring filename, TextureOptions &options, const Imath::V3f &P, const Imath::V3f &dPdx, const Imath::V3f &dPdy, const Imath::V3f &dPdz, float *result)
 
virtual bool texture3d (ustring filename, TextureOptions &options, Runflag *runflags, int beginactive, int endactive, VaryingRef< Imath::V3f > P, VaryingRef< Imath::V3f > dPdx, VaryingRef< Imath::V3f > dPdy, VaryingRef< Imath::V3f > dPdz, float *result)=0
 
virtual bool shadow (ustring filename, TextureOpt &options, const Imath::V3f &P, const Imath::V3f &dPdx, const Imath::V3f &dPdy, float *result)=0
 
virtual bool shadow (TextureHandle *texture_handle, Perthread *thread_info, TextureOpt &options, const Imath::V3f &P, const Imath::V3f &dPdx, const Imath::V3f &dPdy, float *result)=0
 
virtual bool shadow (ustring filename, TextureOptions &options, Runflag *runflags, int beginactive, int endactive, VaryingRef< Imath::V3f > P, VaryingRef< Imath::V3f > dPdx, VaryingRef< Imath::V3f > dPdy, float *result)=0
 
virtual bool environment (ustring filename, TextureOpt &options, const Imath::V3f &R, const Imath::V3f &dRdx, const Imath::V3f &dRdy, float *result)=0
 
virtual bool environment (TextureHandle *texture_handle, Perthread *thread_info, TextureOpt &options, const Imath::V3f &R, const Imath::V3f &dRdx, const Imath::V3f &dRdy, float *result)=0
 
virtual bool environment (ustring filename, TextureOptions &options, Runflag *runflags, int beginactive, int endactive, VaryingRef< Imath::V3f > R, VaryingRef< Imath::V3f > dRdx, VaryingRef< Imath::V3f > dRdy, float *result)=0
 
virtual std::string resolve_filename (const std::string &filename) const =0
 
virtual bool get_texture_info (ustring filename, int subimage, ustring dataname, TypeDesc datatype, void *data)=0
 
virtual bool get_imagespec (ustring filename, int subimage, ImageSpec &spec)=0
 
virtual const ImageSpecimagespec (ustring filename, int subimage=0)=0
 
virtual bool get_texels (ustring filename, TextureOpt &options, int miplevel, int xbegin, int xend, int ybegin, int yend, int zbegin, int zend, TypeDesc format, void *result)=0
 
virtual bool get_texels (ustring filename, TextureOptions &options, int miplevel, int xbegin, int xend, int ybegin, int yend, int zbegin, int zend, TypeDesc format, void *result)
 
virtual std::string geterror () const =0
 
virtual std::string getstats (int level=1, bool icstats=true) const =0
 
virtual void invalidate (ustring filename)=0
 
virtual void invalidate_all (bool force=false)=0
 
virtual void reset_stats ()=0
 

Static Public Member Functions

static TextureSystemcreate (bool shared=true)
 
static void destroy (TextureSystem *x)
 

Detailed Description

Define an API to an abstract class that that manages texture files, caches of open file handles as well as tiles of texels so that truly huge amounts of texture may be accessed by an application with low memory footprint, and ways to perform antialiased texture, shadow map, and environment map lookups.

Member Function Documentation

virtual bool TextureSystem::attribute ( const std::string &  name,
TypeDesc  type,
const void *  val 
)
pure virtual

Set an attribute controlling the texture system. Return true if the name and type were recognized and the attrib was set. Documented attributes: int max_open_files : maximum number of file handles held open float max_memory_MB : maximum tile cache size, in MB string searchpath : colon-separated search path for texture files string plugin_searchpath : colon-separated search path for plugins matrix44 worldtocommon : the world-to-common transformation matrix44 commontoworld : the common-to-world transformation int autotile : if >0, tile size to emulate for non-tiled images int autoscanline : autotile using full width tiles int automip : if nonzero, emulate mipmap on the fly int accept_untiled : if nonzero, accept untiled images int accept_unmipped : if nonzero, accept unmipped images int failure_retries : how many times to retry a read failure int deduplicate : if nonzero, detect duplicate textures (default=1) int gray_to_rgb : make 1-channel images fill RGB lookups string latlong_up : default "up" direction for latlong ("y")

virtual void TextureSystem::clear ( )
pure virtual

Close everything, free resources, start from scratch.

static TextureSystem* TextureSystem::create ( bool  shared = true)
static

Create a TextureSystem and return a pointer. This should only be freed by passing it to TextureSystem::destroy()!

If shared==true, it's intended to be shared with other like-minded owners in the same process who also ask for a shared cache. If false, a private image cache will be created.

static void TextureSystem::destroy ( TextureSystem x)
static

Destroy a TextureSystem that was created using TextureSystem::create().

virtual bool TextureSystem::environment ( ustring  filename,
TextureOpt options,
const Imath::V3f &  R,
const Imath::V3f &  dRdx,
const Imath::V3f &  dRdy,
float *  result 
)
pure virtual

Retrieve an environment map lookup for direction R.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::environment ( TextureHandle *  texture_handle,
Perthread *  thread_info,
TextureOpt options,
const Imath::V3f &  R,
const Imath::V3f &  dRdx,
const Imath::V3f &  dRdy,
float *  result 
)
pure virtual

Slightly faster version of environment() lookup if the app already has a texture handle and per-thread info.

virtual bool TextureSystem::environment ( ustring  filename,
TextureOptions options,
Runflag *  runflags,
int  beginactive,
int  endactive,
VaryingRef< Imath::V3f >  R,
VaryingRef< Imath::V3f >  dRdx,
VaryingRef< Imath::V3f >  dRdy,
float *  result 
)
pure virtual

Retrieve an environment map lookup for direction R, for many points at once.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::get_imagespec ( ustring  filename,
int  subimage,
ImageSpec spec 
)
pure virtual

Get the ImageSpec associated with the named texture (specifically, the first MIP-map level). If the file is found and is an image format that can be read, store a copy of its specification in spec and return true. Return false if the file was not found or could not be opened as an image file by any available ImageIO plugin.

virtual Perthread* TextureSystem::get_perthread_info ( )
pure virtual

Retrieve an opaque handle for per-thread info, to be used for get_texture_handle and the texture routines that take handles directly.

virtual bool TextureSystem::get_texels ( ustring  filename,
TextureOpt options,
int  miplevel,
int  xbegin,
int  xend,
int  ybegin,
int  yend,
int  zbegin,
int  zend,
TypeDesc  format,
void *  result 
)
pure virtual

Retrieve the rectangle of raw unfiltered texels spanning [xbegin..xend) X [ybegin..yend) X [zbegin..zend), with "exclusive end" a la STL, specified as integer pixel coordinates in the designated MIP-map level, storing the texel values beginning at the address specified by result. The texel values will be converted to the type specified by format. It is up to the caller to ensure that result points to an area of memory big enough to accommodate the requested rectangle (taking into consideration its dimensions, number of channels, and data format). Requested pixels outside the valid pixel data region will be filled in with 0 values.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::get_texels ( ustring  filename,
TextureOptions options,
int  miplevel,
int  xbegin,
int  xend,
int  ybegin,
int  yend,
int  zbegin,
int  zend,
TypeDesc  format,
void *  result 
)
inlinevirtual

Deprecated

virtual TextureHandle* TextureSystem::get_texture_handle ( ustring  filename,
Perthread *  thread_info = NULL 
)
pure virtual

Retrieve an opaque handle for fast texture lookups. The opaque point thread_info is thread-specific information returned by get_perthread_info(). Return NULL if something has gone horribly wrong.

virtual bool TextureSystem::get_texture_info ( ustring  filename,
int  subimage,
ustring  dataname,
TypeDesc  datatype,
void *  data 
)
pure virtual

Get information about the given texture. Return true if found and the data has been put in *data. Return false if the texture doesn't exist, doesn't have the requested data, if the data doesn't match the type requested. or some other failure.

virtual bool TextureSystem::getattribute ( const std::string &  name,
TypeDesc  type,
void *  val 
)
pure virtual

Get the named attribute, store it in value.

virtual std::string TextureSystem::geterror ( ) const
pure virtual

If any of the API routines returned false indicating an error, this routine will return the error string (and clear any error flags). If no error has occurred since the last time geterror() was called, it will return an empty string.

virtual std::string TextureSystem::getstats ( int  level = 1,
bool  icstats = true 
) const
pure virtual

Return the statistics output as a huge string.

virtual const ImageSpec* TextureSystem::imagespec ( ustring  filename,
int  subimage = 0 
)
pure virtual

Return a pointer to an ImageSpec associated with the named texture (specifically, the first MIP-map level) if the file is found and is an image format that can be read, otherwise return NULL.

This method is much more efficient than get_imagespec(), since it just returns a pointer to the spec held internally by the underlying ImageCache (rather than copying the spec to the user's memory). However, the caller must beware that the pointer is only valid as long as nobody (even other threads) calls invalidate() on the file, or invalidate_all(), or destroys the TextureSystem.

virtual void TextureSystem::invalidate ( ustring  filename)
pure virtual

Invalidate any cached information about the named file. A client might do this if, for example, they are aware that an image being held in the cache has been updated on disk.

virtual void TextureSystem::invalidate_all ( bool  force = false)
pure virtual

Invalidate all cached data for all textures. If force is true, everything will be invalidated, no matter how wasteful it is, but if force is false, in actuality files will only be invalidated if their modification times have been changed since they were first opened.

virtual void TextureSystem::reset_stats ( )
pure virtual

Reset most statistics to be as they were with a fresh TextureSystem. Caveat emptor: this does not flush the cache itelf, so the resulting statistics from the next set of texture requests will not match the number of tile reads, etc., that would have resulted from a new TextureSystem.

virtual std::string TextureSystem::resolve_filename ( const std::string &  filename) const
pure virtual

Given possibly-relative 'filename', resolve it using the search path rules and return the full resolved filename.

virtual bool TextureSystem::shadow ( ustring  filename,
TextureOpt options,
const Imath::V3f &  P,
const Imath::V3f &  dPdx,
const Imath::V3f &  dPdy,
float *  result 
)
pure virtual

Retrieve a shadow lookup for a single position P.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::shadow ( TextureHandle *  texture_handle,
Perthread *  thread_info,
TextureOpt options,
const Imath::V3f &  P,
const Imath::V3f &  dPdx,
const Imath::V3f &  dPdy,
float *  result 
)
pure virtual

Slightly faster version of shadow() lookup if the app already has a texture handle and per-thread info.

virtual bool TextureSystem::shadow ( ustring  filename,
TextureOptions options,
Runflag *  runflags,
int  beginactive,
int  endactive,
VaryingRef< Imath::V3f >  P,
VaryingRef< Imath::V3f >  dPdx,
VaryingRef< Imath::V3f >  dPdy,
float *  result 
)
pure virtual

Retrieve a shadow lookup for position P at many points at once.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::texture ( ustring  filename,
TextureOpt options,
float  s,
float  t,
float  dsdx,
float  dtdx,
float  dsdy,
float  dtdy,
float *  result 
)
pure virtual

Filtered 2D texture lookup for a single point.

s,t are the texture coordinates; dsdx, dtdx, dsdy, and dtdy are the differentials of s and t change in some canonical directions x and y. The choice of x and y are not important to the implementation; it can be any imposed 2D coordinates, such as pixels in screen space, adjacent samples in parameter space on a surface, etc.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::texture ( TextureHandle *  texture_handle,
Perthread *  thread_info,
TextureOpt options,
float  s,
float  t,
float  dsdx,
float  dtdx,
float  dsdy,
float  dtdy,
float *  result 
)
pure virtual

Slightly faster version of 2D texture() lookup if the app already has a texture handle and per-thread info.

virtual bool TextureSystem::texture ( ustring  filename,
TextureOptions options,
float  s,
float  t,
float  dsdx,
float  dtdx,
float  dsdy,
float  dtdy,
float *  result 
)
pure virtual

Deprecated version that uses old TextureOptions for a single-point lookup.

virtual bool TextureSystem::texture ( ustring  filename,
TextureOptions options,
Runflag *  runflags,
int  beginactive,
int  endactive,
VaryingRef< float >  s,
VaryingRef< float >  t,
VaryingRef< float >  dsdx,
VaryingRef< float >  dtdx,
VaryingRef< float >  dsdy,
VaryingRef< float >  dtdy,
float *  result 
)
pure virtual

Retrieve filtered (possibly anisotropic) texture lookups for several points at once.

All of the VaryingRef parameters (and fields in options) describe texture lookup parameters at an array of positions. But this routine only computes them from indices i where beginactive <= i < endactive, and ONLY when runflags[i] is nonzero.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::texture3d ( ustring  filename,
TextureOpt options,
const Imath::V3f &  P,
const Imath::V3f &  dPdx,
const Imath::V3f &  dPdy,
const Imath::V3f &  dPdz,
float *  result 
)
pure virtual

Retrieve a 3D texture lookup at a single point.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.

virtual bool TextureSystem::texture3d ( TextureHandle *  texture_handle,
Perthread *  thread_info,
TextureOpt options,
const Imath::V3f &  P,
const Imath::V3f &  dPdx,
const Imath::V3f &  dPdy,
const Imath::V3f &  dPdz,
float *  result 
)
pure virtual

Slightly faster version of texture3d() lookup if the app already has a texture handle and per-thread info.

virtual bool TextureSystem::texture3d ( ustring  filename,
TextureOptions options,
const Imath::V3f &  P,
const Imath::V3f &  dPdx,
const Imath::V3f &  dPdy,
const Imath::V3f &  dPdz,
float *  result 
)
inlinevirtual

Deprecated

virtual bool TextureSystem::texture3d ( ustring  filename,
TextureOptions options,
Runflag *  runflags,
int  beginactive,
int  endactive,
VaryingRef< Imath::V3f >  P,
VaryingRef< Imath::V3f >  dPdx,
VaryingRef< Imath::V3f >  dPdy,
VaryingRef< Imath::V3f >  dPdz,
float *  result 
)
pure virtual

Retrieve a 3D texture lookup at many points at once.

Return true if the file is found and could be opened by an available ImageIO plugin, otherwise return false.


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