32 #ifndef Texture_INCUDE_DEFINE 33 #define Texture_INCUDE_DEFINE 91 void setAnisotropy(
float anisotropy) { mDirty =
true; mAnisotropy = anisotropy; }
92 void setGenerateMipmap(
bool generate_mipmap) { mDirty =
true; mGenerateMipmap = generate_mipmap; }
97 void setDirty(
bool dirty)
const { mDirty = dirty; }
99 bool dirty()
const {
return mDirty; }
163 mWidth = mHeight = mDepth = 0;
165 mFixedSamplesLocation =
true;
191 int width()
const {
return mWidth; }
197 int depth()
const {
return mDepth; }
262 void destroyTexture();
267 bool createTexture();
280 bool setMipLevel(
int mip_level,
const Image* img,
bool gen_mipmaps);
285 prepareTexture1D(
NULL, format,
false, border);
286 mSetupParams->setWidth(width);
292 prepareTexture1D(width, format, border);
293 return createTexture();
299 prepareTexture1D(
NULL, format, mipmaps, border);
300 mSetupParams->setImagePath(image_path);
306 prepareTexture1D(image_path, format, mipmaps, border);
307 return createTexture();
316 mSetupParams->setFormat(format);
317 mSetupParams->setGenMipmaps(mipmaps);
318 mSetupParams->setBorder(border);
324 prepareTexture1D(image, format, mipmaps, border);
325 return createTexture();
331 prepareTexture2D(
NULL, format,
false, border);
332 mSetupParams->setWidth(width);
333 mSetupParams->setHeight(height);
339 prepareTexture2D(width, height, format, border);
340 return createTexture();
346 prepareTexture2D(
NULL, format, mipmaps, border);
347 mSetupParams->setImagePath(image_path);
353 prepareTexture2D(image_path, format, mipmaps, border);
354 return createTexture();
363 mSetupParams->setFormat(format);
364 mSetupParams->setGenMipmaps(mipmaps);
365 mSetupParams->setBorder(border);
371 prepareTexture2D(image, format, mipmaps, border);
372 return createTexture();
378 prepareTexture3D(
NULL, format,
false, border);
379 mSetupParams->setWidth(width);
380 mSetupParams->setHeight(height);
381 mSetupParams->setDepth(depth);
387 prepareTexture3D(width, height, depth, format, border);
388 return createTexture();
394 prepareTexture3D(
NULL, format, mipmaps, border);
395 mSetupParams->setImagePath(image_path);
401 prepareTexture3D(image_path, format, mipmaps, border);
402 return createTexture();
411 mSetupParams->setFormat(format);
412 mSetupParams->setGenMipmaps(mipmaps);
413 mSetupParams->setBorder(border);
419 prepareTexture3D(image, format, mipmaps, border);
420 return createTexture();
426 prepareTextureCubemap(
NULL, format,
false, border);
427 mSetupParams->setWidth(width);
428 mSetupParams->setHeight(height);
434 prepareTextureCubemap(width, height, format, border);
435 return createTexture();
441 prepareTextureCubemap(
NULL, format, mipmaps, border);
442 mSetupParams->setImagePath(image_path);
448 prepareTextureCubemap(image_path, format, mipmaps, border);
449 return createTexture();
458 mSetupParams->setFormat(format);
459 mSetupParams->setGenMipmaps(mipmaps);
460 mSetupParams->setBorder(border);
466 prepareTextureCubemap(image, format, mipmaps, border);
467 return createTexture();
473 prepareTexture1DArray(
NULL, format,
false);
474 mSetupParams->setWidth(width);
475 mSetupParams->setHeight(count);
481 prepareTexture1DArray(width, count, format);
482 return createTexture();
488 prepareTexture1DArray(
NULL, format, mipmaps);
489 mSetupParams->setImagePath(image_path);
495 prepareTexture1DArray(image_path, format, mipmaps);
496 return createTexture();
505 mSetupParams->setFormat(format);
506 mSetupParams->setGenMipmaps(mipmaps);
507 mSetupParams->setBorder(
false);
513 prepareTexture1DArray(image, format, mipmaps);
514 return createTexture();
520 prepareTexture2DArray(
NULL, format,
false);
521 mSetupParams->setWidth(width);
522 mSetupParams->setHeight(height);
523 mSetupParams->setDepth(count);
529 prepareTexture2DArray(width, height, count, format);
530 return createTexture();
536 prepareTexture2DArray(
NULL, format, mipmaps);
537 mSetupParams->setImagePath(image_path);
543 prepareTexture2DArray(image_path, format, mipmaps);
544 return createTexture();
553 mSetupParams->setFormat(format);
554 mSetupParams->setGenMipmaps(mipmaps);
555 mSetupParams->setBorder(
false);
561 prepareTexture2DArray(image, format, mipmaps);
562 return createTexture();
568 prepareTextureRectangle(
NULL, format);
569 mSetupParams->setWidth(width);
570 mSetupParams->setHeight(height);
576 prepareTextureRectangle(width, height, format);
577 return createTexture();
583 prepareTextureRectangle(
NULL, format);
584 mSetupParams->setImagePath(image_path);
590 prepareTextureRectangle(image_path, format);
591 return createTexture();
600 mSetupParams->setFormat(format);
601 mSetupParams->setGenMipmaps(
false);
602 mSetupParams->setBorder(
false);
608 prepareTextureRectangle(image, format);
609 return createTexture();
617 mSetupParams->setFormat(format);
618 mSetupParams->setBufferObject(bo);
619 mSetupParams->setGenMipmaps(
false);
620 mSetupParams->setBorder(
false);
626 prepareTextureBuffer(format, bo);
627 return createTexture();
635 mSetupParams->setWidth(width);
636 mSetupParams->setHeight(height);
637 mSetupParams->setFormat(format);
638 mSetupParams->setSamples(samples);
639 mSetupParams->setFixedSamplesLocations(fixedsamplelocations);
640 mSetupParams->setGenMipmaps(
false);
641 mSetupParams->setBorder(
false);
647 prepareTexture2DMultisample(width, height, format, samples, fixedsamplelocations);
648 return createTexture();
656 mSetupParams->setWidth(width);
657 mSetupParams->setHeight(height);
658 mSetupParams->setDepth(depth);
659 mSetupParams->setFormat(format);
660 mSetupParams->setSamples(samples);
661 mSetupParams->setFixedSamplesLocations(fixedsamplelocations);
662 mSetupParams->setGenMipmaps(
false);
663 mSetupParams->setBorder(
false);
669 prepareTexture2DMultisampleArray(width, height, depth, format, samples, fixedsamplelocations);
670 return createTexture();
676 void setHandle(
unsigned int id,
bool managed =
true ) { mHandle = id; mManaged = managed; }
678 unsigned int handle()
const {
return mHandle; }
700 int width()
const {
return mWidth; }
710 int depth()
const {
return mDepth; }
737 bool isValid()
const;
740 bool isDepthTexture()
const;
744 void clone(
const Texture& other);
747 static bool supports(
ETextureDimension tex_dimension,
ETextureFormat tex_format,
int mip_level,
EImageDimension img_dimension,
int w,
int h,
int d,
bool border,
int samples,
bool fixedsamplelocations,
bool verbose);
750 static bool isCompressedFormat(
int format);
754 void operator=(
const Texture&) {}
int height() const
The vertical dimension of the texture in texels.
ETextureFormat format() const
TexParameter * getTexParameter()
The TexParameter object associated to a Texture.
void prepareTexture2D(int width, int height, ETextureFormat format, bool border=false)
Prepares for creation an empty 2D texture.
bool mFixedSamplesLocation
void prepareTexture2DArray(int width, int height, int count, ETextureFormat format)
Prepares for creation an empty 2D array texture.
ref< BufferObject > mBufferObject
unsigned int handle() const
OpenGL texture handle as returned by glGenTextures().
Wraps the OpenGL function glTexParameter(), see also http://www.opengl.org/sdk/docs/man/xhtml/glTexPa...
bool createTexture1DArray(int width, int count, ETextureFormat format)
Creates an empty 1D array texture.
void prepareTextureRectangle(const Image *image, ETextureFormat format)
Prepares for creation a texture rectangle from the specified image.
ETexCompareFunc compareFunc() const
void prepareTexture1D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 1D texture from the specified file.
void prepareTexture3D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 3D texture from the specified file.
void prepareTexture1DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 1d texture array from the specified image.
void setSetupParams(SetupParams *setup_params)
See SetupParams.
void setFixedSamplesLocation(bool fixed)
Whether the samples location is fixed for a a multisample texture.
void prepareTexture3D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 3D texture from the specified image.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
const String & imagePath() const
bool createTexture3D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 3D texture from the specified image.
void setImage(const Image *image)
ref< TexParameter > mTexParameter
bool createTexture2D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 2D texture from the specified image.
const SetupParams * setupParams() const
See SetupParams.
void setBorder(bool border)
Whether the texture has a 1 pixel texture border or not.
bool createTexture1DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Creates a 1d texture array from the specified file.
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
void prepareTexture2DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 2d texture array from the specified image.
bool createTextureCubemap(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a cubemap texture from the specified image.
void setWrap(ETexParamWrap wrap)
bool createTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Creates a 3D multisample texture.
void setWrapT(ETexParamWrap texturewrap)
bool createTextureBuffer(vl::ETextureFormat format, BufferObject *bo)
Creates a texture buffer texture.
ETexCompareFunc mCompareFunc
ETextureDimension mDimension
Wraps an OpenGL texture object representing and managing all the supported texture types...
void setWrapS(ETexParamWrap texturewrap)
bool createTextureRectangle(const String &image_path, ETextureFormat format)
Creates a texture rectangle from the specified file.
ETexParamFilter mMinFilter
bool createTextureRectangle(const Image *image, ETextureFormat format)
Creates a texture rectangle from the specified image.
SetupParams * setupParams()
See SetupParams.
void prepareTexture2D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 2D texture from the specified file.
bool createTexture1D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 1D texture from the specified file.
void setFormat(ETextureFormat format)
void setDepth(int z)
The z dimension of the texture in texels.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
void prepareTextureCubemap(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a cubemap texture from the specified image.
bool border() const
Whether the texture has a 1 pixel texture border or not.
ETexParamFilter mMagfilter
void setSamples(int samples)
The number of samples of a multisample texture.
void setInternalFormat(ETextureFormat format)
The texture internal format as pecified by the internalFormat parameter of glTexImage*().
Visualization Library main namespace.
void prepareTexture1D(int width, ETextureFormat format, bool border=false)
Prepares for creation an empty 1D texture.
void setCompareFunc(ETexCompareFunc func)
void setGenerateMipmap(bool generate_mipmap)
bool generateMipmap() const
bool createTexture3D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 3D texture from the specified file.
void setFixedSamplesLocations(bool fixed)
void setMinFilter(ETexParamFilter minfilter)
BufferObject * bufferObject()
The buffer object bound to a buffer object texture.
void setDepthTextureMode(EDepthTextureMode mode)
void setImagePath(const String &path)
void setHeight(int y)
The vertical dimension of the texture in texels.
void prepareTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
Prepares for creation an empty 3D texture.
int samples() const
The number of samples of a multisample texture.
BufferObject * bufferObject()
ref< TexParameter > mTexParameterOverride
void prepareTextureBuffer(vl::ETextureFormat format, BufferObject *bo)
Prepares a texture buffer texture.
void setHandle(unsigned int id, bool managed=true)
OpenGL texture handle as returned by glGenTextures().
void prepareTexture1DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 1d texture array from the specified file.
void setDimension(ETextureDimension dimension)
The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
void prepareTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Prepares a 2D multisample texture.
void setSamples(int samples)
bool createTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
Creates an empty 3D texture.
void prepareTexture1DArray(int width, int count, ETextureFormat format)
Prepares for creation an empty 1D array texture.
void prepareTexture1D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 1D texture from the specified image.
The base class for all the reference counted objects.
ref< BufferObject > mBufferObject
void setBorderColor(fvec4 bordercolor)
bool createTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
Creates an empty cubemap texture.
void prepareTexture2D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 2D texture from the specified image.
bool createTexture2DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Creates a 2d texture array from the specified image.
The TextureSampler class associates a Texture object to an OpenGL texture unit.
ETexParamWrap wrapR() const
const TexParameter * getTexParameterOverride() const
The TexParameter belonging to a TextureSampler that is currently overriding the Texture's own TexPara...
bool createTexture1DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Creates a 1d texture array from the specified image.
bool createTexture2D(int width, int height, ETextureFormat format, bool border=false)
Creates an empty 2D texture.
ETexParamWrap wrapS() const
fvec4 borderColor() const
const BufferObject * bufferObject() const
void prepareTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Prepares a 3D multisample texture.
const BufferObject * bufferObject() const
The buffer object bound to a buffer object texture.
void setDimension(ETextureDimension dimension)
bool fixedSamplesLocation() const
Whether the samples location is fixed for a a multisample texture.
ETextureDimension dimension() const
ETextureFormat internalFormat() const
The texture internal format as pecified by the internalFormat parameter of glTexImage*().
bool createTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Creates a 2D multisample texture.
void setDirty(bool dirty) const
#define VLGRAPHICS_EXPORT
bool mFixedSamplesLocation
bool createTexture2D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 2D texture from the specified file.
ETextureDimension dimension() const
The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
The BufferObject class is a Buffer that can upload its data on the GPU memory.
bool createTexture1D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 1D texture from the specified image.
bool createTextureRectangle(int width, int height, ETextureFormat format)
Creates an empty texture rectangle.
ETexParamFilter magFilter() const
bool createTexture1D(int width, ETextureFormat format, bool border=false)
Creates an empty 1D texture.
SetupParams wraps all the parameters needed to crate a Texture.
void prepareTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
Prepares for creation an empty cubemap texture.
void prepareTextureRectangle(int width, int height, ETextureFormat format)
Prepares for creation an empty texture rectangle.
bool createTextureCubemap(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates creation a cubemap texture from the specified file.
EDepthTextureMode mDepthTextureMode
void prepareTextureRectangle(const String &image_path, ETextureFormat format)
Prepares for creation a texture rectangle from the specified file.
void prepareTexture2DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 2d texture array from the specified file.
const TexParameter * getTexParameter() const
The TexParameter object associated to a Texture.
void setWrapR(ETexParamWrap texturewrap)
ETexParamWrap wrapT() const
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
The ref<> class is used to reference-count an Object.
ETexCompareMode compareMode() const
void setAnisotropy(float anisotropy)
EDepthTextureMode depthTextureMode() const
int depth() const
The z dimension of the texture in texels.
ETexCompareMode mCompareMode
void setGenMipmaps(bool on)
ref< SetupParams > mSetupParams
void setWidth(int x)
The horizontal dimension of the texture in texels.
void setBufferObject(BufferObject *bo)
bool fixedSamplesLocations() const
ETextureDimension mDimension
void setManaged(bool managed)
If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or d...
const Image * image() const
void setCompareMode(ETexCompareMode mode)
void prepareTextureCubemap(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a cubemap texture from the specified file.
bool managed() const
If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or d...
bool createTexture2DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Creates a 2d texture array from the specified file.
bool createTexture2DArray(int width, int height, int count, ETextureFormat format)
Creates an empty 2D array texture.
int width() const
The horizontal dimension of the texture in texels.