37 #ifndef OPENIMAGEIO_TEXTURE_H
38 #define OPENIMAGEIO_TEXTURE_H
44 #include <OpenEXR/ImathVec.h>
52 class TextureSystemImpl;
57 TexFormatUnknown, TexFormatTexture, TexFormatTexture3d,
58 TexFormatShadow, TexFormatCubeFaceShadow, TexFormatVolumeShadow,
59 TexFormatLatLongEnv, TexFormatCubeFaceEnv,
65 LayoutLatLong, LayoutCubeThreeByTwo, LayoutCubeOneBySix, EnvLayoutLast
75 typedef unsigned char Runflag;
127 : nchannels(1), firstchannel(0), subimage(0),
128 swrap(WrapDefault), twrap(WrapDefault),
129 mipmode(MipModeDefault), interpmode(InterpSmartBicubic),
130 anisotropic(32), conservative_filter(true),
131 sblur(0.0f), tblur(0.0f), swidth(1.0f), twidth(1.0f),
132 fill(0.0f), missingcolor(NULL),
133 dresultds(NULL), dresultdt(NULL),
134 time(0.0f), bias(0.0f), samples(1),
135 rwrap(WrapDefault), rblur(0.0f), rwidth(1.0f), dresultdr(NULL),
137 swrap_func(NULL), twrap_func(NULL), rwrap_func(NULL),
173 static Wrap decode_wrapmode (
const char *name);
179 static void parse_wrapmodes (
const char *wrapmodes,
187 typedef bool (*wrap_impl) (
int &coord,
int origin,
int width);
188 wrap_impl swrap_func, twrap_func, rwrap_func;
190 friend class pvt::TextureSystemImpl;
275 static Wrap decode_wrapmode (
ustring name) {
282 static void parse_wrapmodes (
const char *wrapmodes,
294 typedef bool (*wrap_impl) (
int &coord,
int origin,
int width);
295 wrap_impl swrap_func, twrap_func, rwrap_func;
296 friend class pvt::TextureSystemImpl;
326 virtual void clear () = 0;
347 virtual bool attribute (
const std::string &name, TypeDesc type,
const void *val) = 0;
349 virtual bool attribute (
const std::string &name,
int val) = 0;
350 virtual bool attribute (
const std::string &name,
float val) = 0;
351 virtual bool attribute (
const std::string &name,
double val) = 0;
352 virtual bool attribute (
const std::string &name,
const char *val) = 0;
353 virtual bool attribute (
const std::string &name,
const std::string &val) = 0;
356 virtual bool getattribute (
const std::string &name, TypeDesc type,
void *val) = 0;
358 virtual bool getattribute (
const std::string &name,
int &val) = 0;
359 virtual bool getattribute (
const std::string &name,
float &val) = 0;
360 virtual bool getattribute (
const std::string &name,
double &val) = 0;
361 virtual bool getattribute (
const std::string &name,
char **val) = 0;
362 virtual bool getattribute (
const std::string &name, std::string &val) = 0;
371 virtual Perthread * get_perthread_info () = 0;
382 virtual TextureHandle * get_texture_handle (
ustring filename,
383 Perthread *thread_info=NULL) = 0;
397 float s,
float t,
float dsdx,
float dtdx,
398 float dsdy,
float dtdy,
float *result) = 0;
402 virtual bool texture (TextureHandle *texture_handle,
404 float s,
float t,
float dsdx,
float dtdx,
405 float dsdy,
float dtdy,
float *result) = 0;
410 float s,
float t,
float dsdx,
float dtdx,
411 float dsdy,
float dtdy,
float *result) = 0;
425 Runflag *runflags,
int beginactive,
int endactive,
426 VaryingRef<float> s, VaryingRef<float> t,
427 VaryingRef<float> dsdx, VaryingRef<float> dtdx,
428 VaryingRef<float> dsdy, VaryingRef<float> dtdy,
436 const Imath::V3f &P,
const Imath::V3f &dPdx,
437 const Imath::V3f &dPdy,
const Imath::V3f &dPdz,
442 virtual bool texture3d (TextureHandle *texture_handle,
444 const Imath::V3f &P,
const Imath::V3f &dPdx,
445 const Imath::V3f &dPdy,
const Imath::V3f &dPdz,
451 const Imath::V3f &P,
const Imath::V3f &dPdx,
452 const Imath::V3f &dPdy,
const Imath::V3f &dPdz,
455 return texture3d (filename, opt, P, dPdx, dPdy, dPdz, result);
463 Runflag *runflags,
int beginactive,
int endactive,
464 VaryingRef<Imath::V3f> P,
465 VaryingRef<Imath::V3f> dPdx,
466 VaryingRef<Imath::V3f> dPdy,
467 VaryingRef<Imath::V3f> dPdz,
475 const Imath::V3f &P,
const Imath::V3f &dPdx,
476 const Imath::V3f &dPdy,
float *result) = 0;
480 virtual bool shadow (TextureHandle *texture_handle, Perthread *thread_info,
482 const Imath::V3f &P,
const Imath::V3f &dPdx,
483 const Imath::V3f &dPdy,
float *result) = 0;
490 Runflag *runflags,
int beginactive,
int endactive,
491 VaryingRef<Imath::V3f> P,
492 VaryingRef<Imath::V3f> dPdx,
493 VaryingRef<Imath::V3f> dPdy,
501 const Imath::V3f &R,
const Imath::V3f &dRdx,
502 const Imath::V3f &dRdy,
float *result) = 0;
506 virtual bool environment (TextureHandle *texture_handle,
508 const Imath::V3f &R,
const Imath::V3f &dRdx,
509 const Imath::V3f &dRdy,
float *result) = 0;
517 Runflag *runflags,
int beginactive,
int endactive,
518 VaryingRef<Imath::V3f> R,
519 VaryingRef<Imath::V3f> dRdx,
520 VaryingRef<Imath::V3f> dRdy,
525 virtual std::string resolve_filename (
const std::string &filename)
const=0;
531 virtual bool get_texture_info (
ustring filename,
int subimage,
532 ustring dataname, TypeDesc datatype,
void *data) = 0;
540 virtual bool get_imagespec (
ustring filename,
int subimage,
572 int miplevel,
int xbegin,
int xend,
573 int ybegin,
int yend,
int zbegin,
int zend,
574 TypeDesc format,
void *result) = 0;
579 int miplevel,
int xbegin,
int xend,
580 int ybegin,
int yend,
int zbegin,
int zend,
581 TypeDesc format,
void *result) {
583 return get_texels (filename, opt, miplevel, xbegin, xend,
584 ybegin, yend, zbegin, zend, format, result);
591 virtual std::string
geterror ()
const = 0;
595 virtual std::string getstats (
int level=1,
bool icstats=
true)
const = 0;
600 virtual void invalidate (
ustring filename) = 0;
607 virtual void invalidate_all (
bool force=
false) = 0;
614 virtual void reset_stats () = 0;
619 void operator delete (
void * ) { }
627 #endif // OPENIMAGEIO_TEXTURE_H