32 #ifndef Texture_INCUDE_DEFINE 33 #define Texture_INCUDE_DEFINE 107 void setAnisotropy(
float anisotropy) { mDirty =
true; mAnisotropy = anisotropy; }
108 void setGenerateMipmap(
bool generate_mipmap) { mDirty =
true; mGenerateMipmap = generate_mipmap; }
113 void setDirty(
bool dirty)
const { mDirty = dirty; }
115 bool dirty()
const {
return mDirty; }
198 mWidth = mHeight = mDepth = 0;
200 mFixedSamplesLocation =
true;
226 int width()
const {
return mWidth; }
232 int depth()
const {
return mDepth; }
294 void destroyTexture();
299 bool createTexture();
312 bool setMipLevel(
int mip_level,
const Image* img,
bool gen_mipmaps);
317 prepareTexture1D(
NULL, format,
false, border);
318 mSetupParams->setWidth(width);
324 prepareTexture1D(width, format, border);
325 return createTexture();
331 prepareTexture1D(
NULL, format, mipmaps, border);
332 mSetupParams->setImagePath(image_path);
338 prepareTexture1D(image_path, format, mipmaps, border);
339 return createTexture();
348 mSetupParams->setFormat(format);
349 mSetupParams->setGenMipmaps(mipmaps);
350 mSetupParams->setBorder(border);
356 prepareTexture1D(image, format, mipmaps, border);
357 return createTexture();
363 prepareTexture2D(
NULL, format,
false, border);
364 mSetupParams->setWidth(width);
365 mSetupParams->setHeight(height);
371 prepareTexture2D(width, height, format, border);
372 return createTexture();
378 prepareTexture2D(
NULL, format, mipmaps, border);
379 mSetupParams->setImagePath(image_path);
385 prepareTexture2D(image_path, format, mipmaps, border);
386 return createTexture();
395 mSetupParams->setFormat(format);
396 mSetupParams->setGenMipmaps(mipmaps);
397 mSetupParams->setBorder(border);
403 prepareTexture2D(image, format, mipmaps, border);
404 return createTexture();
410 prepareTexture3D(
NULL, format,
false, border);
411 mSetupParams->setWidth(width);
412 mSetupParams->setHeight(height);
413 mSetupParams->setDepth(depth);
419 prepareTexture3D(width, height, depth, format, border);
420 return createTexture();
426 prepareTexture3D(
NULL, format, mipmaps, border);
427 mSetupParams->setImagePath(image_path);
433 prepareTexture3D(image_path, format, mipmaps, border);
434 return createTexture();
443 mSetupParams->setFormat(format);
444 mSetupParams->setGenMipmaps(mipmaps);
445 mSetupParams->setBorder(border);
451 prepareTexture3D(image, format, mipmaps, border);
452 return createTexture();
458 prepareTextureCubemap(
NULL, format,
false, border);
459 mSetupParams->setWidth(width);
460 mSetupParams->setHeight(height);
466 prepareTextureCubemap(width, height, format, border);
467 return createTexture();
473 prepareTextureCubemap(
NULL, format, mipmaps, border);
474 mSetupParams->setImagePath(image_path);
480 prepareTextureCubemap(image_path, format, mipmaps, border);
481 return createTexture();
490 mSetupParams->setFormat(format);
491 mSetupParams->setGenMipmaps(mipmaps);
492 mSetupParams->setBorder(border);
498 prepareTextureCubemap(image, format, mipmaps, border);
499 return createTexture();
505 prepareTexture1DArray(
NULL, format,
false);
506 mSetupParams->setWidth(width);
507 mSetupParams->setHeight(count);
513 prepareTexture1DArray(width, count, format);
514 return createTexture();
520 prepareTexture1DArray(
NULL, format, mipmaps);
521 mSetupParams->setImagePath(image_path);
527 prepareTexture1DArray(image_path, format, mipmaps);
528 return createTexture();
537 mSetupParams->setFormat(format);
538 mSetupParams->setGenMipmaps(mipmaps);
539 mSetupParams->setBorder(
false);
545 prepareTexture1DArray(image, format, mipmaps);
546 return createTexture();
552 prepareTexture2DArray(
NULL, format,
false);
553 mSetupParams->setWidth(width);
554 mSetupParams->setHeight(height);
555 mSetupParams->setDepth(count);
561 prepareTexture2DArray(width, height, count, format);
562 return createTexture();
568 prepareTexture2DArray(
NULL, format, mipmaps);
569 mSetupParams->setImagePath(image_path);
575 prepareTexture2DArray(image_path, format, mipmaps);
576 return createTexture();
585 mSetupParams->setFormat(format);
586 mSetupParams->setGenMipmaps(mipmaps);
587 mSetupParams->setBorder(
false);
593 prepareTexture2DArray(image, format, mipmaps);
594 return createTexture();
600 prepareTextureRectangle(
NULL, format);
601 mSetupParams->setWidth(width);
602 mSetupParams->setHeight(height);
608 prepareTextureRectangle(width, height, format);
609 return createTexture();
615 prepareTextureRectangle(
NULL, format);
616 mSetupParams->setImagePath(image_path);
622 prepareTextureRectangle(image_path, format);
623 return createTexture();
632 mSetupParams->setFormat(format);
633 mSetupParams->setGenMipmaps(
false);
634 mSetupParams->setBorder(
false);
640 prepareTextureRectangle(image, format);
641 return createTexture();
649 mSetupParams->setFormat(format);
650 mSetupParams->setBufferObject(bo);
651 mSetupParams->setGenMipmaps(
false);
652 mSetupParams->setBorder(
false);
658 prepareTextureBuffer(format, bo);
659 return createTexture();
667 mSetupParams->setWidth(width);
668 mSetupParams->setHeight(height);
669 mSetupParams->setFormat(format);
670 mSetupParams->setSamples(samples);
671 mSetupParams->setFixedSamplesLocations(fixedsamplelocations);
672 mSetupParams->setGenMipmaps(
false);
673 mSetupParams->setBorder(
false);
679 prepareTexture2DMultisample(width, height, format, samples, fixedsamplelocations);
680 return createTexture();
688 mSetupParams->setWidth(width);
689 mSetupParams->setHeight(height);
690 mSetupParams->setDepth(depth);
691 mSetupParams->setFormat(format);
692 mSetupParams->setSamples(samples);
693 mSetupParams->setFixedSamplesLocations(fixedsamplelocations);
694 mSetupParams->setGenMipmaps(
false);
695 mSetupParams->setBorder(
false);
701 prepareTexture2DMultisampleArray(width, height, depth, format, samples, fixedsamplelocations);
702 return createTexture();
708 void setHandle(
unsigned int id,
bool managed =
true ) { mHandle = id; mManaged = managed; }
710 unsigned int handle()
const {
return mHandle; }
732 int width()
const {
return mWidth; }
742 int depth()
const {
return mDepth; }
769 bool isValid()
const;
772 bool isDepthTexture()
const;
776 void clone(
const Texture& other);
779 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);
782 static bool isCompressedFormat(
int format);
786 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)
The TextureImageUnit class associates a Texture object to an OpenGL texture unit. ...
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()
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.
ETexParamWrap wrapR() const
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.