00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00035
00036
00037 #ifndef OPENIMAGEIO_TEXTURE_H
00038 #define OPENIMAGEIO_TEXTURE_H
00039
00040 #include "varyingref.h"
00041 #include "ustring.h"
00042 #include "imageio.h"
00043
00044 #ifndef INCLUDED_IMATHVEC_H
00045 namespace Imath {
00046 class V3f;
00047 };
00048 #endif
00049 #ifndef INCLUDED_IMATHMATRIX_H
00050 namespace Imath {
00051 class M44f;
00052 };
00053 #endif
00054
00055
00056 #ifdef OPENIMAGEIO_NAMESPACE
00057 namespace OPENIMAGEIO_NAMESPACE {
00058 #endif
00059
00060 namespace OpenImageIO {
00061
00062
00063 namespace pvt {
00064
00065 class TextureSystemImpl;
00066
00067
00068
00069 enum TexFormat {
00070 TexFormatUnknown, TexFormatTexture, TexFormatTexture3d,
00071 TexFormatShadow, TexFormatCubeFaceShadow, TexFormatVolumeShadow,
00072 TexFormatLatLongEnv, TexFormatCubeFaceEnv,
00073 TexFormatLast
00074 };
00075
00076 enum CubeLayout {
00077 CubeUnknown, CubeThreeByTwo, CubeOneBySix, CubeLast
00078 };
00079
00080 };
00081
00082
00083
00084
00087 typedef unsigned char Runflag;
00088
00091 enum RunFlagVal { RunFlagOff = 0, RunFlagOn = 255 };
00092
00093
00094
00101 class DLLPUBLIC TextureOptions {
00102 public:
00105 enum Wrap {
00106 WrapDefault,
00107 WrapBlack,
00108 WrapClamp,
00109 WrapPeriodic,
00110 WrapMirror,
00111 WrapLast
00112 };
00113
00116 enum MipMode {
00117 MipModeDefault,
00118 MipModeNoMIP,
00119 MipModeOneLevel,
00120 MipModeTrilinear,
00121 MipModeAniso
00122 };
00123
00126 enum InterpMode {
00127 InterpClosest,
00128 InterpBilinear,
00129 InterpBicubic,
00130 InterpSmartBicubic
00131 };
00132
00135 TextureOptions ();
00136
00137
00138 int firstchannel;
00139 int nchannels;
00140 Wrap swrap;
00141 Wrap twrap;
00142 MipMode mipmode;
00143 InterpMode interpmode;
00144 int anisotropic;
00145 bool conservative_filter;
00146
00147
00148 VaryingRef<float> sblur, tblur;
00149 VaryingRef<float> swidth, twidth;
00150 VaryingRef<float> bias;
00151 VaryingRef<float> fill;
00152 VaryingRef<int> samples;
00153 float *dresultds;
00154 float *dresultdt;
00155
00156
00157 Wrap zwrap;
00158 VaryingRef<float> zblur;
00159 VaryingRef<float> zwidth;
00160
00163 static Wrap decode_wrapmode (const char *name);
00164
00168 static void parse_wrapmodes (const char *wrapmodes,
00169 TextureOptions::Wrap &swrapcode,
00170 TextureOptions::Wrap &twrapcode);
00171
00172
00177 TextureOptions (bool);
00178
00179 private:
00180
00181
00182 int actualchannels;
00183 typedef bool (*wrap_impl) (int &coord, int width);
00184 wrap_impl swrap_func, twrap_func;
00185 friend class OpenImageIO::pvt::TextureSystemImpl;
00186 };
00187
00188
00189
00195 class DLLPUBLIC TextureSystem {
00196 public:
00203 static TextureSystem *create (bool shared=true);
00204
00207 static void destroy (TextureSystem *x);
00208
00209 TextureSystem (void) { }
00210 virtual ~TextureSystem () { }
00211
00214 virtual void clear () = 0;
00215
00227 virtual bool attribute (const std::string &name, TypeDesc type, const void *val) = 0;
00228
00229 virtual bool attribute (const std::string &name, int val) = 0;
00230 virtual bool attribute (const std::string &name, float val) = 0;
00231 virtual bool attribute (const std::string &name, double val) = 0;
00232 virtual bool attribute (const std::string &name, const char *val) = 0;
00233 virtual bool attribute (const std::string &name, const std::string &val) = 0;
00234
00236 virtual bool getattribute (const std::string &name, TypeDesc type, void *val) = 0;
00237
00238 virtual bool getattribute (const std::string &name, int &val) = 0;
00239 virtual bool getattribute (const std::string &name, float &val) = 0;
00240 virtual bool getattribute (const std::string &name, double &val) = 0;
00241 virtual bool getattribute (const std::string &name, char **val) = 0;
00242 virtual bool getattribute (const std::string &name, std::string &val) = 0;
00243
00255 virtual bool texture (ustring filename, TextureOptions &options,
00256 float s, float t, float dsdx, float dtdx,
00257 float dsdy, float dtdy, float *result) = 0;
00258
00270 virtual bool texture (ustring filename, TextureOptions &options,
00271 Runflag *runflags, int beginactive, int endactive,
00272 VaryingRef<float> s, VaryingRef<float> t,
00273 VaryingRef<float> dsdx, VaryingRef<float> dtdx,
00274 VaryingRef<float> dsdy, VaryingRef<float> dtdy,
00275 float *result) = 0;
00276
00281 virtual bool texture (ustring filename, TextureOptions &options,
00282 const Imath::V3f &P,
00283 const Imath::V3f &dPdx, const Imath::V3f &dPdy,
00284 float *result) = 0;
00285
00290 virtual bool texture (ustring filename, TextureOptions &options,
00291 Runflag *runflags, int beginactive, int endactive,
00292 VaryingRef<Imath::V3f> P,
00293 VaryingRef<Imath::V3f> dPdx,
00294 VaryingRef<Imath::V3f> dPdy,
00295 float *result) = 0;
00296
00301 virtual bool shadow (ustring filename, TextureOptions &options,
00302 const Imath::V3f &P, const Imath::V3f &dPdx,
00303 const Imath::V3f &dPdy, float *result) = 0;
00304
00309 virtual bool shadow (ustring filename, TextureOptions &options,
00310 Runflag *runflags, int beginactive, int endactive,
00311 VaryingRef<Imath::V3f> P,
00312 VaryingRef<Imath::V3f> dPdx,
00313 VaryingRef<Imath::V3f> dPdy,
00314 float *result) = 0;
00315
00320 virtual bool environment (ustring filename, TextureOptions &options,
00321 const Imath::V3f &R, const Imath::V3f &dRdx,
00322 const Imath::V3f &dRdy, float *result) = 0;
00323
00329 virtual bool environment (ustring filename, TextureOptions &options,
00330 Runflag *runflags, int beginactive, int endactive,
00331 VaryingRef<Imath::V3f> R,
00332 VaryingRef<Imath::V3f> dRdx,
00333 VaryingRef<Imath::V3f> dRdy,
00334 float *result) = 0;
00335
00338 virtual std::string resolve_filename (const std::string &filename) const=0;
00339
00344 virtual bool get_texture_info (ustring filename, ustring dataname,
00345 TypeDesc datatype, void *data) = 0;
00346
00353 virtual bool get_imagespec (ustring filename, ImageSpec &spec) = 0;
00354
00367 virtual const ImageSpec *imagespec (ustring filename) = 0;
00368
00382 virtual bool get_texels (ustring filename, TextureOptions &options,
00383 int level, int xbegin, int xend,
00384 int ybegin, int yend, int zbegin, int zend,
00385 TypeDesc format, void *result) = 0;
00386
00391 virtual std::string geterror () const = 0;
00392
00395 virtual std::string getstats (int level=1, bool icstats=true) const = 0;
00396
00400 virtual void invalidate (ustring filename) = 0;
00401
00407 virtual void invalidate_all (bool force=false) = 0;
00408
00409 private:
00410
00411
00412 void operator delete (void *todel) { }
00413
00414 };
00415
00416
00417 };
00418
00419
00420 #ifdef OPENIMAGEIO_NAMESPACE
00421 };
00422 using namespace OPENIMAGEIO_NAMESPACE;
00423 #endif
00424
00425 #endif // OPENIMAGEIO_TEXTURE_H