Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Texture.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Texture_INCUDE_DEFINE
33 #define Texture_INCUDE_DEFINE
34 
35 #include <vlCore/String.hpp>
36 #include <vlCore/Vector4.hpp>
37 #include <vlCore/Image.hpp>
39 
40 namespace vl
41 {
42  class OpenGLContext;
43 
44  //------------------------------------------------------------------------------
45  // TexParameter
46  //------------------------------------------------------------------------------
79  {
81  friend class Texture;
82 
83  public:
84  TexParameter();
85 
86  void apply(ETextureDimension dimension, OpenGLContext* gl) const;
87 
88  ETexParamFilter minFilter() const { return mMinFilter; }
89  ETexParamFilter magFilter() const { return mMagfilter; }
90  ETexParamWrap wrapS() const { return mWrapS; }
91  ETexParamWrap wrapT() const { return mWrapT; }
92  ETexParamWrap wrapR() const { return mWrapR; }
93  fvec4 borderColor() const { return mBorderColor; }
94  float anisotropy() const { return mAnisotropy; }
95  bool generateMipmap() const { return mGenerateMipmap; }
96  ETexCompareMode compareMode() const { return mCompareMode; }
97  ETexCompareFunc compareFunc() const { return mCompareFunc; }
98  EDepthTextureMode depthTextureMode() const { return mDepthTextureMode; }
99 
100  void setMinFilter(ETexParamFilter minfilter) { mDirty = true; mMinFilter = minfilter; }
101  void setMagFilter(ETexParamFilter magfilter);
102  void setWrap(ETexParamWrap wrap) { setWrapS(wrap); setWrapT(wrap); setWrapR(wrap); }
103  void setWrapS(ETexParamWrap texturewrap) { mDirty = true; mWrapS = texturewrap; }
104  void setWrapT(ETexParamWrap texturewrap) { mDirty = true; mWrapT = texturewrap; }
105  void setWrapR(ETexParamWrap texturewrap) { mDirty = true; mWrapR = texturewrap; }
106  void setBorderColor(fvec4 bordercolor) { mDirty = true; mBorderColor = bordercolor; }
107  void setAnisotropy(float anisotropy) { mDirty = true; mAnisotropy = anisotropy; }
108  void setGenerateMipmap(bool generate_mipmap) { mDirty = true; mGenerateMipmap = generate_mipmap; }
109  void setCompareMode(ETexCompareMode mode) { mDirty = true; mCompareMode = mode; }
110  void setCompareFunc(ETexCompareFunc func) { mDirty = true; mCompareFunc = func; }
111  void setDepthTextureMode(EDepthTextureMode mode) { mDirty = true; mDepthTextureMode = mode; }
112 
113  void setDirty(bool dirty) const { mDirty = dirty; }
114 
115  bool dirty() const { return mDirty; }
116 
117  protected:
127  float mAnisotropy;
129 
130  mutable bool mDirty;
131  };
132  //------------------------------------------------------------------------------
133  class TextureImageUnit;
134  //------------------------------------------------------------------------------
135  // Texture
136  //------------------------------------------------------------------------------
179  {
181  friend class TextureImageUnit;
182 
183  public:
189  class SetupParams: public Object
190  {
191  public:
193  {
194  mDimension = TD_TEXTURE_2D;
195  mFormat = TF_RGBA;
196  mBorder = false;
197  mGenMipmaps = false;
198  mWidth = mHeight = mDepth = 0;
199  mSamples = 0;
200  mFixedSamplesLocation = true;
201  }
202 
203  void setImagePath(const String& path) { mImagePath = path; }
204  const String& imagePath() const { return mImagePath; }
205 
206  void setImage(const Image* image) { mImage = image; }
207  const Image* image() const { return mImage.get(); }
208 
209  const BufferObject* bufferObject() const { return mBufferObject.get(); }
210  BufferObject* bufferObject() { return mBufferObject.get(); }
211  void setBufferObject(BufferObject* bo) { mBufferObject = bo; }
212 
213  void setDimension(ETextureDimension dimension) { mDimension = dimension; }
214  ETextureDimension dimension() const { return mDimension; }
215 
216  void setFormat(ETextureFormat format) { mFormat = format; }
217  ETextureFormat format() const { return mFormat; }
218 
219  void setBorder(bool on) { mBorder = on; }
220  bool border() const { return mBorder; }
221 
222  void setGenMipmaps(bool on) { mGenMipmaps = on; }
223  bool genMipmaps() const { return mGenMipmaps; }
224 
225  void setWidth(int w) { mWidth = w; }
226  int width() const { return mWidth; }
227 
228  void setHeight(int h) { mHeight = h; }
229  int height() const { return mHeight; }
230 
231  void setDepth(int d) { mDepth = d; }
232  int depth() const { return mDepth; }
233 
234  int samples() const { return mSamples; }
235  void setSamples(int samples) { mSamples = samples; }
236 
237  bool fixedSamplesLocations() const { return mFixedSamplesLocation; }
238  void setFixedSamplesLocations(bool fixed) { mFixedSamplesLocation = fixed; }
239 
240  protected:
246  int mWidth, mHeight, mDepth; // used when no image is specified.
247  int mSamples;
248  bool mBorder;
251  };
252 
253  public:
256  Texture(const String& image_path, ETextureFormat format = TF_RGBA, bool mipmaps = true, bool border=false);
257 
260  Texture(const Image* image, ETextureFormat format = TF_RGBA, bool mipmaps = true, bool border=false);
261 
264  Texture(int width, ETextureFormat format = TF_RGBA, bool border=false);
265 
268  Texture(int width, int height, ETextureFormat format = TF_RGBA, bool border=false);
269 
272  Texture(int width, int height, int depth, ETextureFormat format = TF_RGBA, bool border=false);
273 
275  Texture();
276 
278  ~Texture();
279 
281  TexParameter* getTexParameter() { return mTexParameter.get(); }
282 
284  const TexParameter* getTexParameter() const { return mTexParameter.get(); }
285 
287  BufferObject* bufferObject() { return mBufferObject.get(); }
288 
290  const BufferObject* bufferObject() const { return mBufferObject.get(); }
291 
294  void destroyTexture();
295 
299  bool createTexture();
300 
303  bool createTexture(ETextureDimension tex_dimension, ETextureFormat tex_format, int w, int h, int d, bool border, BufferObject* bo, int samples, bool fixedsamplelocations);
304 
312  bool setMipLevel(int mip_level, const Image* img, bool gen_mipmaps);
313 
315  void prepareTexture1D(int width, ETextureFormat format, bool border=false)
316  {
317  prepareTexture1D(NULL, format, false, border);
318  mSetupParams->setWidth(width);
319  }
320 
322  bool createTexture1D(int width, ETextureFormat format, bool border=false)
323  {
324  prepareTexture1D(width, format, border);
325  return createTexture();
326  }
327 
329  void prepareTexture1D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
330  {
331  prepareTexture1D(NULL, format, mipmaps, border);
332  mSetupParams->setImagePath(image_path);
333  }
334 
336  bool createTexture1D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
337  {
338  prepareTexture1D(image_path, format, mipmaps, border);
339  return createTexture();
340  }
341 
343  void prepareTexture1D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
344  {
345  mSetupParams = new SetupParams;
346  mSetupParams->setImage(image);
347  mSetupParams->setDimension(TD_TEXTURE_1D);
348  mSetupParams->setFormat(format);
349  mSetupParams->setGenMipmaps(mipmaps);
350  mSetupParams->setBorder(border);
351  }
352 
354  bool createTexture1D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
355  {
356  prepareTexture1D(image, format, mipmaps, border);
357  return createTexture();
358  }
359 
361  void prepareTexture2D(int width, int height, ETextureFormat format, bool border=false)
362  {
363  prepareTexture2D(NULL, format, false, border);
364  mSetupParams->setWidth(width);
365  mSetupParams->setHeight(height);
366  }
367 
369  bool createTexture2D(int width, int height, ETextureFormat format, bool border=false)
370  {
371  prepareTexture2D(width, height, format, border);
372  return createTexture();
373  }
374 
376  void prepareTexture2D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
377  {
378  prepareTexture2D(NULL, format, mipmaps, border);
379  mSetupParams->setImagePath(image_path);
380  }
381 
383  bool createTexture2D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
384  {
385  prepareTexture2D(image_path, format, mipmaps, border);
386  return createTexture();
387  }
388 
390  void prepareTexture2D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
391  {
392  mSetupParams = new SetupParams;
393  mSetupParams->setImage(image);
394  mSetupParams->setDimension(TD_TEXTURE_2D);
395  mSetupParams->setFormat(format);
396  mSetupParams->setGenMipmaps(mipmaps);
397  mSetupParams->setBorder(border);
398  }
399 
401  bool createTexture2D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
402  {
403  prepareTexture2D(image, format, mipmaps, border);
404  return createTexture();
405  }
406 
408  void prepareTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
409  {
410  prepareTexture3D(NULL, format, false, border);
411  mSetupParams->setWidth(width);
412  mSetupParams->setHeight(height);
413  mSetupParams->setDepth(depth);
414  }
415 
417  bool createTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
418  {
419  prepareTexture3D(width, height, depth, format, border);
420  return createTexture();
421  }
422 
424  void prepareTexture3D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
425  {
426  prepareTexture3D(NULL, format, mipmaps, border);
427  mSetupParams->setImagePath(image_path);
428  }
429 
431  bool createTexture3D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
432  {
433  prepareTexture3D(image_path, format, mipmaps, border);
434  return createTexture();
435  }
436 
438  void prepareTexture3D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
439  {
440  mSetupParams = new SetupParams;
441  mSetupParams->setImage(image);
442  mSetupParams->setDimension(TD_TEXTURE_3D);
443  mSetupParams->setFormat(format);
444  mSetupParams->setGenMipmaps(mipmaps);
445  mSetupParams->setBorder(border);
446  }
447 
449  bool createTexture3D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
450  {
451  prepareTexture3D(image, format, mipmaps, border);
452  return createTexture();
453  }
454 
456  void prepareTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
457  {
458  prepareTextureCubemap(NULL, format, false, border);
459  mSetupParams->setWidth(width);
460  mSetupParams->setHeight(height);
461  }
462 
464  bool createTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
465  {
466  prepareTextureCubemap(width, height, format, border);
467  return createTexture();
468  }
469 
471  void prepareTextureCubemap(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
472  {
473  prepareTextureCubemap(NULL, format, mipmaps, border);
474  mSetupParams->setImagePath(image_path);
475  }
476 
478  bool createTextureCubemap(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
479  {
480  prepareTextureCubemap(image_path, format, mipmaps, border);
481  return createTexture();
482  }
483 
485  void prepareTextureCubemap(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
486  {
487  mSetupParams = new SetupParams;
488  mSetupParams->setImage(image);
489  mSetupParams->setDimension(TD_TEXTURE_CUBE_MAP);
490  mSetupParams->setFormat(format);
491  mSetupParams->setGenMipmaps(mipmaps);
492  mSetupParams->setBorder(border);
493  }
494 
496  bool createTextureCubemap(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
497  {
498  prepareTextureCubemap(image, format, mipmaps, border);
499  return createTexture();
500  }
501 
503  void prepareTexture1DArray(int width, int count, ETextureFormat format)
504  {
505  prepareTexture1DArray(NULL, format, false);
506  mSetupParams->setWidth(width);
507  mSetupParams->setHeight(count);
508  }
509 
511  bool createTexture1DArray(int width, int count, ETextureFormat format)
512  {
513  prepareTexture1DArray(width, count, format);
514  return createTexture();
515  }
516 
518  void prepareTexture1DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
519  {
520  prepareTexture1DArray(NULL, format, mipmaps);
521  mSetupParams->setImagePath(image_path);
522  }
523 
525  bool createTexture1DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
526  {
527  prepareTexture1DArray(image_path, format, mipmaps);
528  return createTexture();
529  }
530 
532  void prepareTexture1DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
533  {
534  mSetupParams = new SetupParams;
535  mSetupParams->setImage(image);
536  mSetupParams->setDimension(TD_TEXTURE_1D_ARRAY);
537  mSetupParams->setFormat(format);
538  mSetupParams->setGenMipmaps(mipmaps);
539  mSetupParams->setBorder(false);
540  }
541 
543  bool createTexture1DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
544  {
545  prepareTexture1DArray(image, format, mipmaps);
546  return createTexture();
547  }
548 
550  void prepareTexture2DArray(int width, int height, int count, ETextureFormat format)
551  {
552  prepareTexture2DArray(NULL, format, false);
553  mSetupParams->setWidth(width);
554  mSetupParams->setHeight(height);
555  mSetupParams->setDepth(count);
556  }
557 
559  bool createTexture2DArray(int width, int height, int count, ETextureFormat format)
560  {
561  prepareTexture2DArray(width, height, count, format);
562  return createTexture();
563  }
564 
566  void prepareTexture2DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
567  {
568  prepareTexture2DArray(NULL, format, mipmaps);
569  mSetupParams->setImagePath(image_path);
570  }
571 
573  bool createTexture2DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
574  {
575  prepareTexture2DArray(image_path, format, mipmaps);
576  return createTexture();
577  }
578 
580  void prepareTexture2DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
581  {
582  mSetupParams = new SetupParams;
583  mSetupParams->setImage(image);
584  mSetupParams->setDimension(TD_TEXTURE_2D_ARRAY);
585  mSetupParams->setFormat(format);
586  mSetupParams->setGenMipmaps(mipmaps);
587  mSetupParams->setBorder(false);
588  }
589 
591  bool createTexture2DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
592  {
593  prepareTexture2DArray(image, format, mipmaps);
594  return createTexture();
595  }
596 
598  void prepareTextureRectangle(int width, int height, ETextureFormat format)
599  {
600  prepareTextureRectangle(NULL, format);
601  mSetupParams->setWidth(width);
602  mSetupParams->setHeight(height);
603  }
604 
606  bool createTextureRectangle(int width, int height, ETextureFormat format)
607  {
608  prepareTextureRectangle(width, height, format);
609  return createTexture();
610  }
611 
613  void prepareTextureRectangle(const String& image_path, ETextureFormat format)
614  {
615  prepareTextureRectangle(NULL, format);
616  mSetupParams->setImagePath(image_path);
617  }
618 
620  bool createTextureRectangle(const String& image_path, ETextureFormat format)
621  {
622  prepareTextureRectangle(image_path, format);
623  return createTexture();
624  }
625 
627  void prepareTextureRectangle(const Image* image, ETextureFormat format)
628  {
629  mSetupParams = new SetupParams;
630  mSetupParams->setImage(image);
631  mSetupParams->setDimension(TD_TEXTURE_RECTANGLE);
632  mSetupParams->setFormat(format);
633  mSetupParams->setGenMipmaps(false);
634  mSetupParams->setBorder(false);
635  }
636 
638  bool createTextureRectangle(const Image* image, ETextureFormat format)
639  {
640  prepareTextureRectangle(image, format);
641  return createTexture();
642  }
643 
646  {
647  mSetupParams = new SetupParams;
648  mSetupParams->setDimension(TD_TEXTURE_BUFFER);
649  mSetupParams->setFormat(format);
650  mSetupParams->setBufferObject(bo);
651  mSetupParams->setGenMipmaps(false);
652  mSetupParams->setBorder(false);
653  }
654 
657  {
658  prepareTextureBuffer(format, bo);
659  return createTexture();
660  }
661 
663  void prepareTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
664  {
665  mSetupParams = new SetupParams;
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);
674  }
675 
677  bool createTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
678  {
679  prepareTexture2DMultisample(width, height, format, samples, fixedsamplelocations);
680  return createTexture();
681  }
682 
684  void prepareTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
685  {
686  mSetupParams = new SetupParams;
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);
696  }
697 
699  bool createTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
700  {
701  prepareTexture2DMultisampleArray(width, height, depth, format, samples, fixedsamplelocations);
702  return createTexture();
703  }
704 
708  void setHandle(unsigned int id, bool managed = true ) { mHandle = id; mManaged = managed; }
710  unsigned int handle() const { return mHandle; }
711 
714  void setManaged( bool managed ) { mManaged = managed; }
717  bool managed() const { return mManaged; }
718 
720  void setDimension(ETextureDimension dimension) { mDimension = dimension; }
722  ETextureDimension dimension() const { return mDimension; }
723 
725  void setInternalFormat(ETextureFormat format) { mFormat = format; }
727  ETextureFormat internalFormat() const { return mFormat; }
728 
730  void setWidth(int x) { mWidth = x; }
732  int width() const { return mWidth; }
733 
735  void setHeight(int y) { mHeight = y; }
737  int height() const { return mHeight; }
738 
740  void setDepth(int z) { mDepth = z; }
742  int depth() const { return mDepth; }
743 
745  void setBorder(bool border) { mBorder = border; }
747  bool border() const { return mBorder; }
748 
750  void setSamples(int samples) { mSamples = samples; }
752  int samples() const { return mSamples; }
753 
755  void setFixedSamplesLocation(bool fixed) { mFixedSamplesLocation = fixed; }
757  bool fixedSamplesLocation() const { return mFixedSamplesLocation; }
758 
760  void setSetupParams(SetupParams* setup_params) { mSetupParams = setup_params; }
761 
763  const SetupParams* setupParams() const { return mSetupParams.get(); }
764 
766  SetupParams* setupParams() { return mSetupParams.get(); }
767 
769  bool isValid() const;
770 
772  bool isDepthTexture() const;
773 
776  void clone(const Texture& other);
777 
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);
780 
782  static bool isCompressedFormat(int format);
783 
784  private:
785  Texture(const Texture& other): Object(other) {}
786  void operator=(const Texture&) {}
787  // TexParameter is not reset but is marked dirty
788  void reset();
789 
790  protected:
791  unsigned int mHandle;
792  bool mManaged;
798  int mWidth;
799  int mHeight;
800  int mDepth;
801  int mSamples;
802  bool mBorder;
804  };
805 }
806 
807 #endif
int height() const
The vertical dimension of the texture in texels.
Definition: Texture.hpp:737
ETextureFormat format() const
Definition: Texture.hpp:217
TexParameter * getTexParameter()
The TexParameter object associated to a Texture.
Definition: Texture.hpp:281
void prepareTexture2D(int width, int height, ETextureFormat format, bool border=false)
Prepares for creation an empty 2D texture.
Definition: Texture.hpp:361
bool mFixedSamplesLocation
Definition: Texture.hpp:803
void prepareTexture2DArray(int width, int height, int count, ETextureFormat format)
Prepares for creation an empty 2D array texture.
Definition: Texture.hpp:550
ref< BufferObject > mBufferObject
Definition: Texture.hpp:242
unsigned int handle() const
OpenGL texture handle as returned by glGenTextures().
Definition: Texture.hpp:710
Wraps the OpenGL function glTexParameter(), see also http://www.opengl.org/sdk/docs/man/xhtml/glTexPa...
Definition: Texture.hpp:78
bool createTexture1DArray(int width, int count, ETextureFormat format)
Creates an empty 1D array texture.
Definition: Texture.hpp:511
void prepareTextureRectangle(const Image *image, ETextureFormat format)
Prepares for creation a texture rectangle from the specified image.
Definition: Texture.hpp:627
ETexCompareFunc compareFunc() const
Definition: Texture.hpp:97
void prepareTexture1D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 1D texture from the specified file.
Definition: Texture.hpp:329
ETexParamWrap mWrapT
Definition: Texture.hpp:121
void prepareTexture3D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 3D texture from the specified file.
Definition: Texture.hpp:424
void prepareTexture1DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 1d texture array from the specified image.
Definition: Texture.hpp:532
void setSetupParams(SetupParams *setup_params)
See SetupParams.
Definition: Texture.hpp:760
void setFixedSamplesLocation(bool fixed)
Whether the samples location is fixed for a a multisample texture.
Definition: Texture.hpp:755
void prepareTexture3D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 3D texture from the specified image.
Definition: Texture.hpp:438
ETexParamFilter
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
const String & imagePath() const
Definition: Texture.hpp:204
bool createTexture3D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 3D texture from the specified image.
Definition: Texture.hpp:449
void setImage(const Image *image)
Definition: Texture.hpp:206
ref< TexParameter > mTexParameter
Definition: Texture.hpp:793
bool createTexture2D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 2D texture from the specified image.
Definition: Texture.hpp:401
const SetupParams * setupParams() const
See SetupParams.
Definition: Texture.hpp:763
void setBorder(bool border)
Whether the texture has a 1 pixel texture border or not.
Definition: Texture.hpp:745
bool createTexture1DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Creates a 1d texture array from the specified file.
Definition: Texture.hpp:525
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.
Definition: Texture.hpp:580
bool createTextureCubemap(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a cubemap texture from the specified image.
Definition: Texture.hpp:496
void setWrap(ETexParamWrap wrap)
Definition: Texture.hpp:102
bool createTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Creates a 3D multisample texture.
Definition: Texture.hpp:699
void setWrapT(ETexParamWrap texturewrap)
Definition: Texture.hpp:104
bool dirty() const
Definition: Texture.hpp:115
bool createTextureBuffer(vl::ETextureFormat format, BufferObject *bo)
Creates a texture buffer texture.
Definition: Texture.hpp:656
ETexCompareFunc mCompareFunc
Definition: Texture.hpp:124
ETextureDimension mDimension
Definition: Texture.hpp:797
Wraps an OpenGL texture object representing and managing all the supported texture types...
Definition: Texture.hpp:178
void setWrapS(ETexParamWrap texturewrap)
Definition: Texture.hpp:103
bool createTextureRectangle(const String &image_path, ETextureFormat format)
Creates a texture rectangle from the specified file.
Definition: Texture.hpp:620
ETexParamFilter mMinFilter
Definition: Texture.hpp:118
bool mBorder
Definition: Texture.hpp:802
bool createTextureRectangle(const Image *image, ETextureFormat format)
Creates a texture rectangle from the specified image.
Definition: Texture.hpp:638
SetupParams * setupParams()
See SetupParams.
Definition: Texture.hpp:766
void prepareTexture2D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 2D texture from the specified file.
Definition: Texture.hpp:376
bool createTexture1D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 1D texture from the specified file.
Definition: Texture.hpp:336
void setFormat(ETextureFormat format)
Definition: Texture.hpp:216
void setDepth(int z)
The z dimension of the texture in texels.
Definition: Texture.hpp:740
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
bool genMipmaps() const
Definition: Texture.hpp:223
bool mGenerateMipmap
Definition: Texture.hpp:128
void prepareTextureCubemap(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a cubemap texture from the specified image.
Definition: Texture.hpp:485
bool border() const
Whether the texture has a 1 pixel texture border or not.
Definition: Texture.hpp:747
ETexParamFilter mMagfilter
Definition: Texture.hpp:119
void setSamples(int samples)
The number of samples of a multisample texture.
Definition: Texture.hpp:750
void setInternalFormat(ETextureFormat format)
The texture internal format as pecified by the internalFormat parameter of glTexImage*().
Definition: Texture.hpp:725
Visualization Library main namespace.
fvec4 mBorderColor
Definition: Texture.hpp:126
void prepareTexture1D(int width, ETextureFormat format, bool border=false)
Prepares for creation an empty 1D texture.
Definition: Texture.hpp:315
void setCompareFunc(ETexCompareFunc func)
Definition: Texture.hpp:110
void setGenerateMipmap(bool generate_mipmap)
Definition: Texture.hpp:108
The TextureImageUnit class associates a Texture object to an OpenGL texture unit. ...
Definition: Shader.hpp:1747
bool generateMipmap() const
Definition: Texture.hpp:95
void setBorder(bool on)
Definition: Texture.hpp:219
bool createTexture3D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 3D texture from the specified file.
Definition: Texture.hpp:431
void setFixedSamplesLocations(bool fixed)
Definition: Texture.hpp:238
void setMinFilter(ETexParamFilter minfilter)
Definition: Texture.hpp:100
BufferObject * bufferObject()
The buffer object bound to a buffer object texture.
Definition: Texture.hpp:287
ETextureFormat mFormat
Definition: Texture.hpp:796
void setDepthTextureMode(EDepthTextureMode mode)
Definition: Texture.hpp:111
void setImagePath(const String &path)
Definition: Texture.hpp:203
void setHeight(int y)
The vertical dimension of the texture in texels.
Definition: Texture.hpp:735
void prepareTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
Prepares for creation an empty 3D texture.
Definition: Texture.hpp:408
int samples() const
The number of samples of a multisample texture.
Definition: Texture.hpp:752
BufferObject * bufferObject()
Definition: Texture.hpp:210
void prepareTextureBuffer(vl::ETextureFormat format, BufferObject *bo)
Prepares a texture buffer texture.
Definition: Texture.hpp:645
void setHandle(unsigned int id, bool managed=true)
OpenGL texture handle as returned by glGenTextures().
Definition: Texture.hpp:708
void prepareTexture1DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 1d texture array from the specified file.
Definition: Texture.hpp:518
void setDimension(ETextureDimension dimension)
The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
Definition: Texture.hpp:720
void prepareTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Prepares a 2D multisample texture.
Definition: Texture.hpp:663
void setSamples(int samples)
Definition: Texture.hpp:235
bool createTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
Creates an empty 3D texture.
Definition: Texture.hpp:417
void prepareTexture1DArray(int width, int count, ETextureFormat format)
Prepares for creation an empty 1D array texture.
Definition: Texture.hpp:503
void prepareTexture1D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 1D texture from the specified image.
Definition: Texture.hpp:343
The base class for all the reference counted objects.
Definition: Object.hpp:158
ref< BufferObject > mBufferObject
Definition: Texture.hpp:795
bool mManaged
Definition: Texture.hpp:792
void setBorderColor(fvec4 bordercolor)
Definition: Texture.hpp:106
bool createTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
Creates an empty cubemap texture.
Definition: Texture.hpp:464
void prepareTexture2D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a 2D texture from the specified image.
Definition: Texture.hpp:390
bool createTexture2DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Creates a 2d texture array from the specified image.
Definition: Texture.hpp:591
ETexCompareMode
ETexParamWrap wrapR() const
Definition: Texture.hpp:92
bool createTexture1DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Creates a 1d texture array from the specified image.
Definition: Texture.hpp:543
EImageDimension
bool createTexture2D(int width, int height, ETextureFormat format, bool border=false)
Creates an empty 2D texture.
Definition: Texture.hpp:369
ETexParamWrap wrapS() const
Definition: Texture.hpp:90
fvec4 borderColor() const
Definition: Texture.hpp:93
const BufferObject * bufferObject() const
Definition: Texture.hpp:209
void prepareTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Prepares a 3D multisample texture.
Definition: Texture.hpp:684
const BufferObject * bufferObject() const
The buffer object bound to a buffer object texture.
Definition: Texture.hpp:290
void setDimension(ETextureDimension dimension)
Definition: Texture.hpp:213
bool fixedSamplesLocation() const
Whether the samples location is fixed for a a multisample texture.
Definition: Texture.hpp:757
ETextureDimension dimension() const
Definition: Texture.hpp:214
ETextureFormat internalFormat() const
The texture internal format as pecified by the internalFormat parameter of glTexImage*().
Definition: Texture.hpp:727
#define NULL
Definition: OpenGLDefs.hpp:81
bool createTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Creates a 2D multisample texture.
Definition: Texture.hpp:677
void setDirty(bool dirty) const
Definition: Texture.hpp:113
float anisotropy() const
Definition: Texture.hpp:94
ETexParamWrap mWrapR
Definition: Texture.hpp:122
bool createTexture2D(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 2D texture from the specified file.
Definition: Texture.hpp:383
ETextureDimension dimension() const
The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
Definition: Texture.hpp:722
int mSamples
Definition: Texture.hpp:801
ETextureDimension
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.
Definition: Texture.hpp:354
bool createTextureRectangle(int width, int height, ETextureFormat format)
Creates an empty texture rectangle.
Definition: Texture.hpp:606
ETexParamFilter magFilter() const
Definition: Texture.hpp:89
bool createTexture1D(int width, ETextureFormat format, bool border=false)
Creates an empty 1D texture.
Definition: Texture.hpp:322
SetupParams wraps all the parameters needed to crate a Texture.
Definition: Texture.hpp:189
ETexParamWrap
void prepareTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
Prepares for creation an empty cubemap texture.
Definition: Texture.hpp:456
void prepareTextureRectangle(int width, int height, ETextureFormat format)
Prepares for creation an empty texture rectangle.
Definition: Texture.hpp:598
bool createTextureCubemap(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates creation a cubemap texture from the specified file.
Definition: Texture.hpp:478
EDepthTextureMode mDepthTextureMode
Definition: Texture.hpp:125
void prepareTextureRectangle(const String &image_path, ETextureFormat format)
Prepares for creation a texture rectangle from the specified file.
Definition: Texture.hpp:613
void prepareTexture2DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 2d texture array from the specified file.
Definition: Texture.hpp:566
const TexParameter * getTexParameter() const
The TexParameter object associated to a Texture.
Definition: Texture.hpp:284
void setWrapR(ETexParamWrap texturewrap)
Definition: Texture.hpp:105
unsigned int mHandle
Definition: Texture.hpp:791
ETexCompareFunc
ETexParamWrap wrapT() const
Definition: Texture.hpp:91
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
Definition: Image.hpp:54
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
ETexCompareMode compareMode() const
Definition: Texture.hpp:96
void setAnisotropy(float anisotropy)
Definition: Texture.hpp:107
ETextureFormat mFormat
Definition: Texture.hpp:245
ETextureFormat
Definition: vlnamespace.hpp:45
EDepthTextureMode depthTextureMode() const
Definition: Texture.hpp:98
int depth() const
The z dimension of the texture in texels.
Definition: Texture.hpp:742
ETexCompareMode mCompareMode
Definition: Texture.hpp:123
void setGenMipmaps(bool on)
Definition: Texture.hpp:222
ref< SetupParams > mSetupParams
Definition: Texture.hpp:794
EDepthTextureMode
void setWidth(int x)
The horizontal dimension of the texture in texels.
Definition: Texture.hpp:730
void setBufferObject(BufferObject *bo)
Definition: Texture.hpp:211
ETexParamWrap mWrapS
Definition: Texture.hpp:120
bool fixedSamplesLocations() const
Definition: Texture.hpp:237
ETextureDimension mDimension
Definition: Texture.hpp:244
void setManaged(bool managed)
If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or d...
Definition: Texture.hpp:714
const Image * image() const
Definition: Texture.hpp:207
void setCompareMode(ETexCompareMode mode)
Definition: Texture.hpp:109
void prepareTextureCubemap(const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
Prepares for creation a cubemap texture from the specified file.
Definition: Texture.hpp:471
bool managed() const
If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or d...
Definition: Texture.hpp:717
bool createTexture2DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Creates a 2d texture array from the specified file.
Definition: Texture.hpp:573
bool createTexture2DArray(int width, int height, int count, ETextureFormat format)
Creates an empty 2D array texture.
Definition: Texture.hpp:559
int width() const
The horizontal dimension of the texture in texels.
Definition: Texture.hpp:732