Visualization Library 2.0.0-b3

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-2017, 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  //------------------------------------------------------------------------------
63  {
65  friend class Texture;
66 
67  public:
68  TexParameter();
69 
70  void apply(ETextureDimension dimension, OpenGLContext* gl) const;
71 
72  ETexParamFilter minFilter() const { return mMinFilter; }
73  ETexParamFilter magFilter() const { return mMagfilter; }
74  ETexParamWrap wrapS() const { return mWrapS; }
75  ETexParamWrap wrapT() const { return mWrapT; }
76  ETexParamWrap wrapR() const { return mWrapR; }
77  fvec4 borderColor() const { return mBorderColor; }
78  float anisotropy() const { return mAnisotropy; }
79  bool generateMipmap() const { return mGenerateMipmap; }
80  ETexCompareMode compareMode() const { return mCompareMode; }
81  ETexCompareFunc compareFunc() const { return mCompareFunc; }
82  EDepthTextureMode depthTextureMode() const { return mDepthTextureMode; }
83 
84  void setMinFilter(ETexParamFilter minfilter) { mDirty = true; mMinFilter = minfilter; }
85  void setMagFilter(ETexParamFilter magfilter);
86  void setWrap(ETexParamWrap wrap) { setWrapS(wrap); setWrapT(wrap); setWrapR(wrap); }
87  void setWrapS(ETexParamWrap texturewrap) { mDirty = true; mWrapS = texturewrap; }
88  void setWrapT(ETexParamWrap texturewrap) { mDirty = true; mWrapT = texturewrap; }
89  void setWrapR(ETexParamWrap texturewrap) { mDirty = true; mWrapR = texturewrap; }
90  void setBorderColor(fvec4 bordercolor) { mDirty = true; mBorderColor = bordercolor; }
91  void setAnisotropy(float anisotropy) { mDirty = true; mAnisotropy = anisotropy; }
92  void setGenerateMipmap(bool generate_mipmap) { mDirty = true; mGenerateMipmap = generate_mipmap; }
93  void setCompareMode(ETexCompareMode mode) { mDirty = true; mCompareMode = mode; }
94  void setCompareFunc(ETexCompareFunc func) { mDirty = true; mCompareFunc = func; }
95  void setDepthTextureMode(EDepthTextureMode mode) { mDirty = true; mDepthTextureMode = mode; }
96 
97  void setDirty(bool dirty) const { mDirty = dirty; }
98 
99  bool dirty() const { return mDirty; }
100 
101  protected:
111  float mAnisotropy;
113 
114  mutable bool mDirty;
115  };
116  //------------------------------------------------------------------------------
117  class TextureSampler;
118  //------------------------------------------------------------------------------
119  // Texture
120  //------------------------------------------------------------------------------
144  {
146  friend class TextureSampler;
147 
148  public:
154  class SetupParams: public Object
155  {
156  public:
158  {
159  mDimension = TD_TEXTURE_2D;
160  mFormat = TF_RGBA;
161  mBorder = false;
162  mGenMipmaps = false;
163  mWidth = mHeight = mDepth = 0;
164  mSamples = 0;
165  mFixedSamplesLocation = true;
166  }
167 
168  void setImagePath(const String& path) { mImagePath = path; }
169  const String& imagePath() const { return mImagePath; }
170 
171  void setImage(const Image* image) { mImage = image; }
172  const Image* image() const { return mImage.get(); }
173 
174  const BufferObject* bufferObject() const { return mBufferObject.get(); }
175  BufferObject* bufferObject() { return mBufferObject.get(); }
176  void setBufferObject(BufferObject* bo) { mBufferObject = bo; }
177 
178  void setDimension(ETextureDimension dimension) { mDimension = dimension; }
179  ETextureDimension dimension() const { return mDimension; }
180 
181  void setFormat(ETextureFormat format) { mFormat = format; }
182  ETextureFormat format() const { return mFormat; }
183 
184  void setBorder(bool on) { mBorder = on; }
185  bool border() const { return mBorder; }
186 
187  void setGenMipmaps(bool on) { mGenMipmaps = on; }
188  bool genMipmaps() const { return mGenMipmaps; }
189 
190  void setWidth(int w) { mWidth = w; }
191  int width() const { return mWidth; }
192 
193  void setHeight(int h) { mHeight = h; }
194  int height() const { return mHeight; }
195 
196  void setDepth(int d) { mDepth = d; }
197  int depth() const { return mDepth; }
198 
199  int samples() const { return mSamples; }
200  void setSamples(int samples) { mSamples = samples; }
201 
202  bool fixedSamplesLocations() const { return mFixedSamplesLocation; }
203  void setFixedSamplesLocations(bool fixed) { mFixedSamplesLocation = fixed; }
204 
205  protected:
211  int mWidth, mHeight, mDepth; // used when no image is specified.
212  int mSamples;
213  bool mBorder;
216  };
217 
218  public:
221  Texture(const String& image_path, ETextureFormat format = TF_RGBA, bool mipmaps = true, bool border=false);
222 
225  Texture(const Image* image, ETextureFormat format = TF_RGBA, bool mipmaps = true, bool border=false);
226 
229  Texture(int width, ETextureFormat format = TF_RGBA, bool border=false);
230 
233  Texture(int width, int height, ETextureFormat format = TF_RGBA, bool border=false);
234 
237  Texture(int width, int height, int depth, ETextureFormat format = TF_RGBA, bool border=false);
238 
240  Texture();
241 
243  ~Texture();
244 
246  TexParameter* getTexParameter() { return mTexParameter.get(); }
247 
249  const TexParameter* getTexParameter() const { return mTexParameter.get(); }
250 
252  const TexParameter* getTexParameterOverride() const { return mTexParameterOverride.get(); }
253 
255  BufferObject* bufferObject() { return mBufferObject.get(); }
256 
258  const BufferObject* bufferObject() const { return mBufferObject.get(); }
259 
262  void destroyTexture();
263 
267  bool createTexture();
268 
271  bool createTexture(ETextureDimension tex_dimension, ETextureFormat tex_format, int w, int h, int d, bool border, BufferObject* bo, int samples, bool fixedsamplelocations);
272 
280  bool setMipLevel(int mip_level, const Image* img, bool gen_mipmaps);
281 
283  void prepareTexture1D(int width, ETextureFormat format, bool border=false)
284  {
285  prepareTexture1D(NULL, format, false, border);
286  mSetupParams->setWidth(width);
287  }
288 
290  bool createTexture1D(int width, ETextureFormat format, bool border=false)
291  {
292  prepareTexture1D(width, format, border);
293  return createTexture();
294  }
295 
297  void prepareTexture1D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
298  {
299  prepareTexture1D(NULL, format, mipmaps, border);
300  mSetupParams->setImagePath(image_path);
301  }
302 
304  bool createTexture1D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
305  {
306  prepareTexture1D(image_path, format, mipmaps, border);
307  return createTexture();
308  }
309 
311  void prepareTexture1D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
312  {
313  mSetupParams = new SetupParams;
314  mSetupParams->setImage(image);
315  mSetupParams->setDimension(TD_TEXTURE_1D);
316  mSetupParams->setFormat(format);
317  mSetupParams->setGenMipmaps(mipmaps);
318  mSetupParams->setBorder(border);
319  }
320 
322  bool createTexture1D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
323  {
324  prepareTexture1D(image, format, mipmaps, border);
325  return createTexture();
326  }
327 
329  void prepareTexture2D(int width, int height, ETextureFormat format, bool border=false)
330  {
331  prepareTexture2D(NULL, format, false, border);
332  mSetupParams->setWidth(width);
333  mSetupParams->setHeight(height);
334  }
335 
337  bool createTexture2D(int width, int height, ETextureFormat format, bool border=false)
338  {
339  prepareTexture2D(width, height, format, border);
340  return createTexture();
341  }
342 
344  void prepareTexture2D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
345  {
346  prepareTexture2D(NULL, format, mipmaps, border);
347  mSetupParams->setImagePath(image_path);
348  }
349 
351  bool createTexture2D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
352  {
353  prepareTexture2D(image_path, format, mipmaps, border);
354  return createTexture();
355  }
356 
358  void prepareTexture2D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
359  {
360  mSetupParams = new SetupParams;
361  mSetupParams->setImage(image);
362  mSetupParams->setDimension(TD_TEXTURE_2D);
363  mSetupParams->setFormat(format);
364  mSetupParams->setGenMipmaps(mipmaps);
365  mSetupParams->setBorder(border);
366  }
367 
369  bool createTexture2D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
370  {
371  prepareTexture2D(image, format, mipmaps, border);
372  return createTexture();
373  }
374 
376  void prepareTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
377  {
378  prepareTexture3D(NULL, format, false, border);
379  mSetupParams->setWidth(width);
380  mSetupParams->setHeight(height);
381  mSetupParams->setDepth(depth);
382  }
383 
385  bool createTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
386  {
387  prepareTexture3D(width, height, depth, format, border);
388  return createTexture();
389  }
390 
392  void prepareTexture3D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
393  {
394  prepareTexture3D(NULL, format, mipmaps, border);
395  mSetupParams->setImagePath(image_path);
396  }
397 
399  bool createTexture3D(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
400  {
401  prepareTexture3D(image_path, format, mipmaps, border);
402  return createTexture();
403  }
404 
406  void prepareTexture3D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
407  {
408  mSetupParams = new SetupParams;
409  mSetupParams->setImage(image);
410  mSetupParams->setDimension(TD_TEXTURE_3D);
411  mSetupParams->setFormat(format);
412  mSetupParams->setGenMipmaps(mipmaps);
413  mSetupParams->setBorder(border);
414  }
415 
417  bool createTexture3D(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
418  {
419  prepareTexture3D(image, format, mipmaps, border);
420  return createTexture();
421  }
422 
424  void prepareTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
425  {
426  prepareTextureCubemap(NULL, format, false, border);
427  mSetupParams->setWidth(width);
428  mSetupParams->setHeight(height);
429  }
430 
432  bool createTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
433  {
434  prepareTextureCubemap(width, height, format, border);
435  return createTexture();
436  }
437 
439  void prepareTextureCubemap(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
440  {
441  prepareTextureCubemap(NULL, format, mipmaps, border);
442  mSetupParams->setImagePath(image_path);
443  }
444 
446  bool createTextureCubemap(const String& image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
447  {
448  prepareTextureCubemap(image_path, format, mipmaps, border);
449  return createTexture();
450  }
451 
453  void prepareTextureCubemap(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
454  {
455  mSetupParams = new SetupParams;
456  mSetupParams->setImage(image);
457  mSetupParams->setDimension(TD_TEXTURE_CUBE_MAP);
458  mSetupParams->setFormat(format);
459  mSetupParams->setGenMipmaps(mipmaps);
460  mSetupParams->setBorder(border);
461  }
462 
464  bool createTextureCubemap(const Image* image, ETextureFormat format, bool mipmaps=true, bool border=false)
465  {
466  prepareTextureCubemap(image, format, mipmaps, border);
467  return createTexture();
468  }
469 
471  void prepareTexture1DArray(int width, int count, ETextureFormat format)
472  {
473  prepareTexture1DArray(NULL, format, false);
474  mSetupParams->setWidth(width);
475  mSetupParams->setHeight(count);
476  }
477 
479  bool createTexture1DArray(int width, int count, ETextureFormat format)
480  {
481  prepareTexture1DArray(width, count, format);
482  return createTexture();
483  }
484 
486  void prepareTexture1DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
487  {
488  prepareTexture1DArray(NULL, format, mipmaps);
489  mSetupParams->setImagePath(image_path);
490  }
491 
493  bool createTexture1DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
494  {
495  prepareTexture1DArray(image_path, format, mipmaps);
496  return createTexture();
497  }
498 
500  void prepareTexture1DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
501  {
502  mSetupParams = new SetupParams;
503  mSetupParams->setImage(image);
504  mSetupParams->setDimension(TD_TEXTURE_1D_ARRAY);
505  mSetupParams->setFormat(format);
506  mSetupParams->setGenMipmaps(mipmaps);
507  mSetupParams->setBorder(false);
508  }
509 
511  bool createTexture1DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
512  {
513  prepareTexture1DArray(image, format, mipmaps);
514  return createTexture();
515  }
516 
518  void prepareTexture2DArray(int width, int height, int count, ETextureFormat format)
519  {
520  prepareTexture2DArray(NULL, format, false);
521  mSetupParams->setWidth(width);
522  mSetupParams->setHeight(height);
523  mSetupParams->setDepth(count);
524  }
525 
527  bool createTexture2DArray(int width, int height, int count, ETextureFormat format)
528  {
529  prepareTexture2DArray(width, height, count, format);
530  return createTexture();
531  }
532 
534  void prepareTexture2DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
535  {
536  prepareTexture2DArray(NULL, format, mipmaps);
537  mSetupParams->setImagePath(image_path);
538  }
539 
541  bool createTexture2DArray(const String& image_path, ETextureFormat format, bool mipmaps=true)
542  {
543  prepareTexture2DArray(image_path, format, mipmaps);
544  return createTexture();
545  }
546 
548  void prepareTexture2DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
549  {
550  mSetupParams = new SetupParams;
551  mSetupParams->setImage(image);
552  mSetupParams->setDimension(TD_TEXTURE_2D_ARRAY);
553  mSetupParams->setFormat(format);
554  mSetupParams->setGenMipmaps(mipmaps);
555  mSetupParams->setBorder(false);
556  }
557 
559  bool createTexture2DArray(const Image* image, ETextureFormat format, bool mipmaps=true)
560  {
561  prepareTexture2DArray(image, format, mipmaps);
562  return createTexture();
563  }
564 
566  void prepareTextureRectangle(int width, int height, ETextureFormat format)
567  {
568  prepareTextureRectangle(NULL, format);
569  mSetupParams->setWidth(width);
570  mSetupParams->setHeight(height);
571  }
572 
574  bool createTextureRectangle(int width, int height, ETextureFormat format)
575  {
576  prepareTextureRectangle(width, height, format);
577  return createTexture();
578  }
579 
581  void prepareTextureRectangle(const String& image_path, ETextureFormat format)
582  {
583  prepareTextureRectangle(NULL, format);
584  mSetupParams->setImagePath(image_path);
585  }
586 
588  bool createTextureRectangle(const String& image_path, ETextureFormat format)
589  {
590  prepareTextureRectangle(image_path, format);
591  return createTexture();
592  }
593 
595  void prepareTextureRectangle(const Image* image, ETextureFormat format)
596  {
597  mSetupParams = new SetupParams;
598  mSetupParams->setImage(image);
599  mSetupParams->setDimension(TD_TEXTURE_RECTANGLE);
600  mSetupParams->setFormat(format);
601  mSetupParams->setGenMipmaps(false);
602  mSetupParams->setBorder(false);
603  }
604 
606  bool createTextureRectangle(const Image* image, ETextureFormat format)
607  {
608  prepareTextureRectangle(image, format);
609  return createTexture();
610  }
611 
614  {
615  mSetupParams = new SetupParams;
616  mSetupParams->setDimension(TD_TEXTURE_BUFFER);
617  mSetupParams->setFormat(format);
618  mSetupParams->setBufferObject(bo);
619  mSetupParams->setGenMipmaps(false);
620  mSetupParams->setBorder(false);
621  }
622 
625  {
626  prepareTextureBuffer(format, bo);
627  return createTexture();
628  }
629 
631  void prepareTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
632  {
633  mSetupParams = new SetupParams;
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);
642  }
643 
645  bool createTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
646  {
647  prepareTexture2DMultisample(width, height, format, samples, fixedsamplelocations);
648  return createTexture();
649  }
650 
652  void prepareTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
653  {
654  mSetupParams = new SetupParams;
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);
664  }
665 
667  bool createTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
668  {
669  prepareTexture2DMultisampleArray(width, height, depth, format, samples, fixedsamplelocations);
670  return createTexture();
671  }
672 
676  void setHandle(unsigned int id, bool managed = true ) { mHandle = id; mManaged = managed; }
678  unsigned int handle() const { return mHandle; }
679 
682  void setManaged( bool managed ) { mManaged = managed; }
685  bool managed() const { return mManaged; }
686 
688  void setDimension(ETextureDimension dimension) { mDimension = dimension; }
690  ETextureDimension dimension() const { return mDimension; }
691 
693  void setInternalFormat(ETextureFormat format) { mFormat = format; }
695  ETextureFormat internalFormat() const { return mFormat; }
696 
698  void setWidth(int x) { mWidth = x; }
700  int width() const { return mWidth; }
701 
703  void setHeight(int y) { mHeight = y; }
705  int height() const { return mHeight; }
706 
708  void setDepth(int z) { mDepth = z; }
710  int depth() const { return mDepth; }
711 
713  void setBorder(bool border) { mBorder = border; }
715  bool border() const { return mBorder; }
716 
718  void setSamples(int samples) { mSamples = samples; }
720  int samples() const { return mSamples; }
721 
723  void setFixedSamplesLocation(bool fixed) { mFixedSamplesLocation = fixed; }
725  bool fixedSamplesLocation() const { return mFixedSamplesLocation; }
726 
728  void setSetupParams(SetupParams* setup_params) { mSetupParams = setup_params; }
729 
731  const SetupParams* setupParams() const { return mSetupParams.get(); }
732 
734  SetupParams* setupParams() { return mSetupParams.get(); }
735 
737  bool isValid() const;
738 
740  bool isDepthTexture() const;
741 
744  void clone(const Texture& other);
745 
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);
748 
750  static bool isCompressedFormat(int format);
751 
752  private:
753  Texture(const Texture& other): Object(other) {}
754  void operator=(const Texture&) {}
755  // TexParameter is not reset but is marked dirty
756  void reset();
757 
758  protected:
759  unsigned int mHandle;
760  bool mManaged;
767  int mWidth;
768  int mHeight;
769  int mDepth;
770  int mSamples;
771  bool mBorder;
773  };
774 }
775 
776 #endif
int height() const
The vertical dimension of the texture in texels.
Definition: Texture.hpp:705
ETextureFormat format() const
Definition: Texture.hpp:182
TexParameter * getTexParameter()
The TexParameter object associated to a Texture.
Definition: Texture.hpp:246
void prepareTexture2D(int width, int height, ETextureFormat format, bool border=false)
Prepares for creation an empty 2D texture.
Definition: Texture.hpp:329
bool mFixedSamplesLocation
Definition: Texture.hpp:772
void prepareTexture2DArray(int width, int height, int count, ETextureFormat format)
Prepares for creation an empty 2D array texture.
Definition: Texture.hpp:518
ref< BufferObject > mBufferObject
Definition: Texture.hpp:207
unsigned int handle() const
OpenGL texture handle as returned by glGenTextures().
Definition: Texture.hpp:678
Wraps the OpenGL function glTexParameter(), see also http://www.opengl.org/sdk/docs/man/xhtml/glTexPa...
Definition: Texture.hpp:62
bool createTexture1DArray(int width, int count, ETextureFormat format)
Creates an empty 1D array texture.
Definition: Texture.hpp:479
void prepareTextureRectangle(const Image *image, ETextureFormat format)
Prepares for creation a texture rectangle from the specified image.
Definition: Texture.hpp:595
ETexCompareFunc compareFunc() const
Definition: Texture.hpp:81
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:297
ETexParamWrap mWrapT
Definition: Texture.hpp:105
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:392
void prepareTexture1DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Prepares for creation a 1d texture array from the specified image.
Definition: Texture.hpp:500
void setSetupParams(SetupParams *setup_params)
See SetupParams.
Definition: Texture.hpp:728
void setFixedSamplesLocation(bool fixed)
Whether the samples location is fixed for a a multisample texture.
Definition: Texture.hpp:723
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:406
ETexParamFilter
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
const String & imagePath() const
Definition: Texture.hpp:169
bool createTexture3D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 3D texture from the specified image.
Definition: Texture.hpp:417
void setImage(const Image *image)
Definition: Texture.hpp:171
ref< TexParameter > mTexParameter
Definition: Texture.hpp:761
bool createTexture2D(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a 2D texture from the specified image.
Definition: Texture.hpp:369
const SetupParams * setupParams() const
See SetupParams.
Definition: Texture.hpp:731
void setBorder(bool border)
Whether the texture has a 1 pixel texture border or not.
Definition: Texture.hpp:713
bool createTexture1DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Creates a 1d texture array from the specified file.
Definition: Texture.hpp:493
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:548
bool createTextureCubemap(const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
Creates a cubemap texture from the specified image.
Definition: Texture.hpp:464
void setWrap(ETexParamWrap wrap)
Definition: Texture.hpp:86
bool createTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Creates a 3D multisample texture.
Definition: Texture.hpp:667
void setWrapT(ETexParamWrap texturewrap)
Definition: Texture.hpp:88
bool dirty() const
Definition: Texture.hpp:99
bool createTextureBuffer(vl::ETextureFormat format, BufferObject *bo)
Creates a texture buffer texture.
Definition: Texture.hpp:624
ETexCompareFunc mCompareFunc
Definition: Texture.hpp:108
ETextureDimension mDimension
Definition: Texture.hpp:766
Wraps an OpenGL texture object representing and managing all the supported texture types...
Definition: Texture.hpp:143
void setWrapS(ETexParamWrap texturewrap)
Definition: Texture.hpp:87
bool createTextureRectangle(const String &image_path, ETextureFormat format)
Creates a texture rectangle from the specified file.
Definition: Texture.hpp:588
ETexParamFilter mMinFilter
Definition: Texture.hpp:102
bool mBorder
Definition: Texture.hpp:771
bool createTextureRectangle(const Image *image, ETextureFormat format)
Creates a texture rectangle from the specified image.
Definition: Texture.hpp:606
SetupParams * setupParams()
See SetupParams.
Definition: Texture.hpp:734
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:344
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:304
void setFormat(ETextureFormat format)
Definition: Texture.hpp:181
void setDepth(int z)
The z dimension of the texture in texels.
Definition: Texture.hpp:708
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
bool genMipmaps() const
Definition: Texture.hpp:188
bool mGenerateMipmap
Definition: Texture.hpp:112
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:453
bool border() const
Whether the texture has a 1 pixel texture border or not.
Definition: Texture.hpp:715
ETexParamFilter mMagfilter
Definition: Texture.hpp:103
void setSamples(int samples)
The number of samples of a multisample texture.
Definition: Texture.hpp:718
void setInternalFormat(ETextureFormat format)
The texture internal format as pecified by the internalFormat parameter of glTexImage*().
Definition: Texture.hpp:693
Visualization Library main namespace.
fvec4 mBorderColor
Definition: Texture.hpp:110
void prepareTexture1D(int width, ETextureFormat format, bool border=false)
Prepares for creation an empty 1D texture.
Definition: Texture.hpp:283
void setCompareFunc(ETexCompareFunc func)
Definition: Texture.hpp:94
void setGenerateMipmap(bool generate_mipmap)
Definition: Texture.hpp:92
bool generateMipmap() const
Definition: Texture.hpp:79
void setBorder(bool on)
Definition: Texture.hpp:184
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:399
void setFixedSamplesLocations(bool fixed)
Definition: Texture.hpp:203
void setMinFilter(ETexParamFilter minfilter)
Definition: Texture.hpp:84
BufferObject * bufferObject()
The buffer object bound to a buffer object texture.
Definition: Texture.hpp:255
ETextureFormat mFormat
Definition: Texture.hpp:765
void setDepthTextureMode(EDepthTextureMode mode)
Definition: Texture.hpp:95
void setImagePath(const String &path)
Definition: Texture.hpp:168
void setHeight(int y)
The vertical dimension of the texture in texels.
Definition: Texture.hpp:703
void prepareTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
Prepares for creation an empty 3D texture.
Definition: Texture.hpp:376
int samples() const
The number of samples of a multisample texture.
Definition: Texture.hpp:720
BufferObject * bufferObject()
Definition: Texture.hpp:175
ref< TexParameter > mTexParameterOverride
Definition: Texture.hpp:762
void prepareTextureBuffer(vl::ETextureFormat format, BufferObject *bo)
Prepares a texture buffer texture.
Definition: Texture.hpp:613
void setHandle(unsigned int id, bool managed=true)
OpenGL texture handle as returned by glGenTextures().
Definition: Texture.hpp:676
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:486
void setDimension(ETextureDimension dimension)
The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
Definition: Texture.hpp:688
void prepareTexture2DMultisample(int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Prepares a 2D multisample texture.
Definition: Texture.hpp:631
void setSamples(int samples)
Definition: Texture.hpp:200
bool createTexture3D(int width, int height, int depth, ETextureFormat format, bool border=false)
Creates an empty 3D texture.
Definition: Texture.hpp:385
void prepareTexture1DArray(int width, int count, ETextureFormat format)
Prepares for creation an empty 1D array texture.
Definition: Texture.hpp:471
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:311
The base class for all the reference counted objects.
Definition: Object.hpp:158
ref< BufferObject > mBufferObject
Definition: Texture.hpp:764
bool mManaged
Definition: Texture.hpp:760
void setBorderColor(fvec4 bordercolor)
Definition: Texture.hpp:90
bool createTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
Creates an empty cubemap texture.
Definition: Texture.hpp:432
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:358
bool createTexture2DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Creates a 2d texture array from the specified image.
Definition: Texture.hpp:559
The TextureSampler class associates a Texture object to an OpenGL texture unit.
Definition: Shader.hpp:1747
ETexCompareMode
ETexParamWrap wrapR() const
Definition: Texture.hpp:76
const TexParameter * getTexParameterOverride() const
The TexParameter belonging to a TextureSampler that is currently overriding the Texture&#39;s own TexPara...
Definition: Texture.hpp:252
bool createTexture1DArray(const Image *image, ETextureFormat format, bool mipmaps=true)
Creates a 1d texture array from the specified image.
Definition: Texture.hpp:511
EImageDimension
bool createTexture2D(int width, int height, ETextureFormat format, bool border=false)
Creates an empty 2D texture.
Definition: Texture.hpp:337
ETexParamWrap wrapS() const
Definition: Texture.hpp:74
fvec4 borderColor() const
Definition: Texture.hpp:77
const BufferObject * bufferObject() const
Definition: Texture.hpp:174
void prepareTexture2DMultisampleArray(int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
Prepares a 3D multisample texture.
Definition: Texture.hpp:652
const BufferObject * bufferObject() const
The buffer object bound to a buffer object texture.
Definition: Texture.hpp:258
void setDimension(ETextureDimension dimension)
Definition: Texture.hpp:178
bool fixedSamplesLocation() const
Whether the samples location is fixed for a a multisample texture.
Definition: Texture.hpp:725
ETextureDimension dimension() const
Definition: Texture.hpp:179
ETextureFormat internalFormat() const
The texture internal format as pecified by the internalFormat parameter of glTexImage*().
Definition: Texture.hpp:695
#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:645
void setDirty(bool dirty) const
Definition: Texture.hpp:97
float anisotropy() const
Definition: Texture.hpp:78
ETexParamWrap mWrapR
Definition: Texture.hpp:106
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:351
ETextureDimension dimension() const
The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
Definition: Texture.hpp:690
int mSamples
Definition: Texture.hpp:770
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:322
bool createTextureRectangle(int width, int height, ETextureFormat format)
Creates an empty texture rectangle.
Definition: Texture.hpp:574
ETexParamFilter magFilter() const
Definition: Texture.hpp:73
bool createTexture1D(int width, ETextureFormat format, bool border=false)
Creates an empty 1D texture.
Definition: Texture.hpp:290
SetupParams wraps all the parameters needed to crate a Texture.
Definition: Texture.hpp:154
ETexParamWrap
void prepareTextureCubemap(int width, int height, ETextureFormat format, bool border=false)
Prepares for creation an empty cubemap texture.
Definition: Texture.hpp:424
void prepareTextureRectangle(int width, int height, ETextureFormat format)
Prepares for creation an empty texture rectangle.
Definition: Texture.hpp:566
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:446
EDepthTextureMode mDepthTextureMode
Definition: Texture.hpp:109
void prepareTextureRectangle(const String &image_path, ETextureFormat format)
Prepares for creation a texture rectangle from the specified file.
Definition: Texture.hpp:581
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:534
const TexParameter * getTexParameter() const
The TexParameter object associated to a Texture.
Definition: Texture.hpp:249
void setWrapR(ETexParamWrap texturewrap)
Definition: Texture.hpp:89
unsigned int mHandle
Definition: Texture.hpp:759
ETexCompareFunc
ETexParamWrap wrapT() const
Definition: Texture.hpp:75
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:80
void setAnisotropy(float anisotropy)
Definition: Texture.hpp:91
ETextureFormat mFormat
Definition: Texture.hpp:210
ETextureFormat
Definition: vlnamespace.hpp:45
EDepthTextureMode depthTextureMode() const
Definition: Texture.hpp:82
int depth() const
The z dimension of the texture in texels.
Definition: Texture.hpp:710
ETexCompareMode mCompareMode
Definition: Texture.hpp:107
void setGenMipmaps(bool on)
Definition: Texture.hpp:187
ref< SetupParams > mSetupParams
Definition: Texture.hpp:763
EDepthTextureMode
void setWidth(int x)
The horizontal dimension of the texture in texels.
Definition: Texture.hpp:698
void setBufferObject(BufferObject *bo)
Definition: Texture.hpp:176
ETexParamWrap mWrapS
Definition: Texture.hpp:104
bool fixedSamplesLocations() const
Definition: Texture.hpp:202
ETextureDimension mDimension
Definition: Texture.hpp:209
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:682
const Image * image() const
Definition: Texture.hpp:172
void setCompareMode(ETexCompareMode mode)
Definition: Texture.hpp:93
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:439
bool managed() const
If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or d...
Definition: Texture.hpp:685
bool createTexture2DArray(const String &image_path, ETextureFormat format, bool mipmaps=true)
Creates a 2d texture array from the specified file.
Definition: Texture.hpp:541
bool createTexture2DArray(int width, int height, int count, ETextureFormat format)
Creates an empty 2D array texture.
Definition: Texture.hpp:527
int width() const
The horizontal dimension of the texture in texels.
Definition: Texture.hpp:700