GlobeEngine
Texture.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_Texture_h
10 #define GlobeEngine_Texture_h
11 
12 #include "OpenGL_Includes.h"
13 #include "Buffer.h"
14 #include "TextureHandle.h"
15 #include "Image.h"
16 #include "Common.h"
17 #include <vmmlib/vector.hpp>
18 #include <stdlib.h>
19 #include <iostream>
20 #include <string>
21 #include <memory>
22 #include <fstream>
23 
24 #ifdef __APPLE__
25 #include <ApplicationServices/ApplicationServices.h>
26 #endif
27 
28 namespace ge {
29 
30  // default config is GL_CLAMP_TO_EDGE
31  template <int D> class TextureWrapParameter
32  {
33  public:
35  for (int i = 0; i<D; i++) {
36  this->param[i] = GL_CLAMP_TO_EDGE;
37  }
38  }
39 
40  TextureWrapParameter(const std::shared_ptr<TextureWrapParameter> copy){
41  for (int i = 0; i<D; i++) {
42  this->param[i] = copy->param[i];
43  }
44  }
45 
46  GLint param[D];
47  };
48 
50  {
51  public:
53  this->param[0] = _in;
54  }
55  };
56 
58  {
59  public:
61  this->param[0] = GL_CLAMP_TO_EDGE;
62  this->param[1] = GL_CLAMP_TO_EDGE;
63  }
64 
65  TextureWrapParameter2D(GLint _s, GLint _t) {
66  this->param[0] = _s;
67  this->param[1] = _t;
68  }
69  };
70 
72  {
73  public:
74  TextureWrapParameter3D(GLint _s, GLint _t, GLint _r) {
75  this->param[0] = _s;
76  this->param[1] = _t;
77  this->param[2] = _r;
78  }
79  };
80 
81  // default config is GL_NEAREST
83  {
84  GLint min;
85  GLint mag;
86 
88  min = GL_NEAREST; mag = GL_NEAREST;
89  }
90 
91  TextureMinMagParameters(GLint _min, GLint _mag){
92  min = _min; mag = _mag;
93  }
94 
95  TextureMinMagParameters(const std::shared_ptr<TextureMinMagParameters> copy){
96  min = copy->min;
97  mag = copy->mag;
98  }
99 
100  void set(GLint _min, GLint _mag){
101  min = _min; mag = _mag;
102  }
103  };
104 
106  {
107  public:
108  short compCount; // number of color components in pixelformat
109 
114  GLenum pixelformat;
119  GLenum datatype;
127  compCount=0;
128  colorComponents = 0;
129  pixelformat = 0;
130  datatype = 0; }
131 
132  TextureTypeInternals(GLint _colorComponents, GLenum _pixelformat, GLenum _datatype){
133  this->set(_colorComponents, _pixelformat,_datatype);
134  }
135 
136  TextureTypeInternals(const std::shared_ptr<TextureTypeInternals> copy){
137  colorComponents = copy->colorComponents;
138  pixelformat = copy->pixelformat;
139  datatype = copy->datatype;
140  this->setComponentCount();
141  }
142 
143  void set(GLint _colorComponents, GLenum _pixelformat, GLenum _datatype){
144  colorComponents = _colorComponents;
145  pixelformat = _pixelformat;
146  datatype = _datatype;
147  this->setComponentCount();
148  }
149 
151 
152 
153  if (pixelformat == GL_RED || pixelformat == GL_R32F ||
154  pixelformat == GL_R8I || pixelformat == GL_R8 ||
155  pixelformat == GL_R16 || pixelformat == GL_R16F ||
156  pixelformat == GL_R16I || pixelformat == GL_R16UI ||
157  pixelformat == GL_R32UI || pixelformat == GL_R32I)
158  {
159  compCount = 1;
160  }
161  else if (pixelformat == GL_RGB || pixelformat == GL_BGR){
162  compCount = 3;
163  }else if(pixelformat == GL_RGBA || pixelformat == GL_RGBA32F ||
164  pixelformat == GL_RGBA32I || pixelformat == GL_RGBA32UI ||
165  pixelformat == GL_BGRA || pixelformat == GL_RGBA32UI ||
166  pixelformat == GL_BGRA_INTEGER){
167  compCount = 4;
168  }else{
169  compCount = 0;
170  }
171  }
172 
173  static TextureTypeInternals r32f(){ return TextureTypeInternals(GL_R32F, GL_RED, GL_FLOAT); };
174  static TextureTypeInternals r32i(){ return TextureTypeInternals(GL_R32I, GL_RED_INTEGER, GL_INT); }
175  static TextureTypeInternals r32ui(){ return TextureTypeInternals(GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT); }
176  static TextureTypeInternals r16us(){ return TextureTypeInternals(GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT); }
177  static TextureTypeInternals r16ui(){ return TextureTypeInternals(GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_INT); }
178  static TextureTypeInternals r16f(){ return TextureTypeInternals(GL_R16F, GL_RED, GL_HALF_FLOAT); }
179  static TextureTypeInternals rg16f(){ return TextureTypeInternals(GL_RG16F, GL_RG, GL_HALF_FLOAT); }
180  static TextureTypeInternals rg8(){ return TextureTypeInternals(GL_RG, GL_RG, GL_UNSIGNED_BYTE); }
181  static TextureTypeInternals rgb8(){ return TextureTypeInternals(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE); }
182  static TextureTypeInternals rgba8(){ return TextureTypeInternals(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE); }
183  static TextureTypeInternals rgba8i(){ return TextureTypeInternals(GL_RGBA, GL_RGBA_INTEGER, GL_INT); }
184  static TextureTypeInternals rgba8ui(){ return TextureTypeInternals(GL_RGBA, GL_RGBA_INTEGER, GL_UNSIGNED_INT); }
185  static TextureTypeInternals rgba32f(){ return TextureTypeInternals(GL_RGBA32F, GL_RGBA, GL_FLOAT); }
186  static TextureTypeInternals rgba32i(){ return TextureTypeInternals(GL_RGBA32I, GL_RGBA_INTEGER, GL_INT); }
187  static TextureTypeInternals rgba32ui(){ return TextureTypeInternals(GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT); }
188  };
189 
190  //typedef TextureTypeInternals<4> rgba8(){ return TextureTypeInternals<4>(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE); }
191 
192  //typedef Texture2D <TextureTypeInternals<count of components, component type, pixelformat, bit coverage=datatype> > Texture2Di;
193  //typedef Texture2D <TextureTypeInternals<1, GLint, GL_RED_INTEGER, GL_INT> > Texture2Di;
194  //typedef Texture2D <TextureTypeInternals<1, GLushort, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT_4_4_4_4_REV> > Texture2Dus4444Rev;
195 
197  {
198  GLint compareFunc;
199  GLint mode;
200  GLint compareMode;
201 
203  compareFunc = 0;
204  mode = 0;
205  compareMode = 0;
206  }
207 
208  TextureDepthProperties(GLint _compareFunc, GLenum _mode, GLenum _compareMode){
209  compareFunc = _compareFunc;
210  mode = _mode;
211  compareMode = _compareMode;
212  }
213 
214  TextureDepthProperties(const std::shared_ptr<TextureDepthProperties> copy){
215  compareFunc = copy->compareFunc;
216  mode = copy->mode;
217  compareMode = copy->compareMode;
218  }
219  };
220 
221  template <typename WRAP> class TextureProperties
222  {
223  public:
226  TextureMinMagParameters _minmag,
227  WRAP _wrap)
228  {
229  this->type = _type;
230  this->minmag = _minmag;
231  this->wrap = _wrap;
232  }
233 
234  TextureProperties(const std::shared_ptr<TextureProperties> copy) {
235  this->wrapProperties = copy->wrapProperties;
236  this->minmagParameters = copy->minmagParameters;
237  this->type = copy->type;
238  }
239 
242  WRAP wrap;
243  };
244 
248 
249  template <int D, typename T, typename PROPERTIES> class TextureType : public TextureHandle
250  {
251  public:
253  data = NULL;
254  clear();
255  }
256 
258  clear();
259  }
260 
261  void clear()
262  {
263  for (int i = 0; i<D; i++) {
264  this->dim[i] = 0;
265  }
266  this->name = "";
267  if (data != NULL) {
268  //delete [] data;
269  }
270  data = NULL;
271  }
272 
273  int countPixel() const {
274  int res = 1;
275  for (int i = 0; i<D; i++) {
276  res *= this->dim[i];
277  }
278  return res;
279  }
280 
282  {
283  this->bind();
284  this->properties.minmag = _minmag;
285  glTexParameteri(this->target, GL_TEXTURE_MIN_FILTER, this->properties.minmag.min);
286  glTexParameteri(this->target, GL_TEXTURE_MAG_FILTER, this->properties.minmag.mag);
287  this->getOpenGLError("error while setMinMagParameter()\n");
288  }
289 
291  this->bind();
292  glGenerateMipmap(this->target);
293  }
294 
295 #ifndef GENGINE_GL_BELOW_410
296 
297  void bindTextureForCompute(GLuint _unit, GLint _level,
298  GLboolean _layered, GLint _layer, GLenum _access) {
299  return glBindImageTexture(_unit, this->handle, _level, _layered,
300  _layer, _access, this->internalFormat);
301  }
302 #endif
303 
304  friend std::ostream& operator<< (std::ostream &out, const TextureType<D, T, PROPERTIES> &tex) {
305  out << "Dim: (" << tex.dim[0];
306  for (int i = 1; i<D; i++) {
307  out << "," << tex.dim[i];
308  }
309  out << ")";
310  return out;
311  }
312 
313  std::string getName() { return this->name; }
314  short getHeight() const { return this->dim[0]; }
315  short getWidth() const { return this->dim[1]; }
316  int getStorageSize() const { return this->countPixel() * this->properties.type.compCount; }
317  vmml::vector< D, short> getDimensions() const { return this->dim; }
318  GLint getInternalFormat() const { return this->properties.type.colorComponents; }
319  GLenum getFormat() const { return this->properties.type.pixelformat; }
320  GLenum getType() const { return this->properties.type.datatype; }
321  const T& getData() const { return data; }
322 
324  int storageSize = this->getStorageSize();
325 #ifndef GENGINE_GL_BELOW_410
326  return this->textureBuffer.template mapBufferStorage<T>(storageSize);
327 #else
328  return this->textureBuffer.template mapBuffer<T>(storageSize);
329 #endif
330  }
331 
332  protected:
333  // abstract methods to define in subclass
334  virtual void setTextureData(T* _pixels) = 0;
335 
336  void loadDataToPBO(T* _data)
337  {
338  T* texBuffer = this->mapStoragePointer();
339  //int storageSize = this->getStorageSize();
340  memcpy(texBuffer, _data, this->getStorageSize()*sizeof(T));
341  this->unmapStoragePointer();
342  }
343 
344  // potentially not working because from texture bound?
346  this->textureBuffer.unmapBuffer();
347  this->textureBuffer.unbindBuffer();
348  }
349 
350  void unpackPBO(){
351  this->textureBuffer.bindBuffer();
352  this->setTextureData(data);
353  this->textureBuffer.unbindBuffer();
354  this->unbind();
355  }
356 
357  void setSize(vmml::vector< D, short> _dim) {
358  this->dim = _dim;
359  }
360 
361  vmml::vector< D, short> dim;
362  T* data;
363  std::string name;
364 
365  //TextureProperties< TextureWrapParameter< D > > properties;
366  PROPERTIES properties;
367  // for texture buffer objects
369  };
370 
371  /*
372  * 1D Texture
373  *
374  * 2D Texture funktions used for 1D texture (resolution = width x 1)
375  */
376  template <typename T, typename PROPERTIES> class Texture1D : public TextureType< 1, T, PROPERTIES>
377  {
378  public:
379  Texture1D() { }
380 
381  GLuint loadEmpty(short _width, TextureTypeInternals _type){
382  this->properties.type = _type;
383  this->setSize(vmml::Vector1s(_width));
384  this->createHandle(GL_TEXTURE_2D);
385  this->setMinMagParameter(TextureMinMagParameters(GL_NEAREST, GL_NEAREST));
386  this->setWrapParameter(TextureWrapParameter1D(GL_CLAMP_TO_EDGE));
387  this->setTextureData(this->data);
388  return this->handle;
389  }
390 
391  GLuint load(short _width, TextureTypeInternals _type, T* _data){
392  this->loadEmpty(_width, _type);
393  this->data = _data;
394  this->setTextureData(this->data);
395  return this->handle;
396  }
397 
399  {
400  this->bind();
401  this->properties.wrap = _wrap;
402  glTexParameteri(this->target, GL_TEXTURE_WRAP_S, _wrap.param[0]);
403  }
404 
405  void setTextureData(T* _pixels) {
406  this->bind();
407  glTexImage2D(this->target, 0, this->properties.type.colorComponents, this->dim[0], 1, 0, this->properties.type.pixelformat, this->properties.type.datatype, _pixels);
408  }
409 
410  private:
411  };
412 
417 
418  /*
419  * 2D Texture
420  *
421  *
422  */
423  template <typename T, typename PROPERTIES> class Texture2D : public TextureType< 2, T, PROPERTIES>
424  {
425  public:
426  Texture2D() { }
427 
428  GLuint loadEmptyWithDefaultParameter(vmml::Vector2s _dim, TextureTypeInternals _type, bool _allocateTexImage = true){
429  return this->loadEmpty(_dim, _type,
430  TextureMinMagParameters(GL_NEAREST, GL_NEAREST),
431  TextureWrapParameter2D(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE),
432  _allocateTexImage);
433  }
434 
435  GLuint loadEmpty(const vmml::Vector2s& _dim, TextureTypeInternals _type,
436  TextureMinMagParameters _minmag, TextureWrapParameter2D _wrap, bool _allocateTexImage = true){
437  this->properties.type = _type;
438  this->setSize(_dim);
439  this->createHandle(GL_TEXTURE_2D);
440  this->setMinMagParameter(_minmag);
441  this->setWrapParameter(_wrap);
442  if( _allocateTexImage )
443  this->setTextureData(this->data);
444  return this->handle;
445  }
446 
447  GLuint load(const vmml::Vector2s& _dim, TextureTypeInternals _type,
448  TextureMinMagParameters _minmag, TextureWrapParameter2D _wrap, T* _data) {
449  this->loadEmpty(_dim,_type,_minmag,_wrap,false);
450  this->data = _data;
451  this->setTextureData(this->data);
452  return this->handle;
453  }
454 
455  GLuint loadWithDefaultParameter(const vmml::Vector2s& _dim, TextureTypeInternals _type, T* _data) {
456  this->loadEmptyWithDefaultParameter(_dim, _type, false);
457  this->data = _data;
458  this->setTextureData(this->data);
459  return this->handle;
460  }
461 
462  GLuint loadSynchWithDefaultParameter(const vmml::Vector2s& _dim, TextureTypeInternals _type, T* _data) {
463  this->loadEmptyWithDefaultParameter(_dim, _type, false);
464  this->loadDataToPBO(_data);
465  this->unpackPBO();
466  return this->handle;
467  }
468 
469  void preloadSyncWithDefaultParameter(const vmml::Vector2s& _dim, TextureTypeInternals _type, T* _data) {
470  this->loadEmptyWithDefaultParameter(_dim, _type, false);
471  this->loadDataToPBO(_data);
472  }
473 
474  void preloadCommit() {
475  this->unpackPBO();
476  this->textureBuffer.clear();
477  }
478 
479  /* void closeAsynchLoad() {
480  this->unmapStoragePointer();
481  this->unpackPBO();
482  }*/
483 
484  GLuint loadFromImage(std::string _filename) {
485  this->createHandle(GL_TEXTURE_2D);
486  this->loadImage(_filename);
487  this->setMinMagParameter(TextureMinMagParameters(GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR));
488  this->setWrapParameter(TextureWrapParameter2D(GL_REPEAT, GL_REPEAT));
489  this->setTextureData(this->data);
490  this->generateMipMaps();
491  return this->handle;
492  }
493 
494 #ifndef GENGINE_GL_BELOW_410
495  void setTextureStorage(const vmml::Vector2s& _dim, GLsizei _levels, GLenum _internalFormat) {
496  this->setSize(_dim);
497  this->properties.type.colorComponents = _internalFormat;
498  glTextureStorage2DEXT(this->handle, this->target, _levels, this->properties.type.colorComponents, this->dim[0], this->dim[1]);
499  }
500 #endif
501 
502  protected:
503 
504  void loadImage(std::string _filename) {
505  imageRef = std::make_shared<Image>();
506  imageRef->load(_filename);
507  this->setSize(vmml::Vector2s(imageRef->width, imageRef->height));
508  this->properties.type = TextureTypeInternals(imageRef->internal_format, imageRef->pixel_format, imageRef->data_type);
509  this->data = imageRef->data.rgba;
510  }
511 
513  this->bind();
514  this->properties.wrap = _wrap;
515  glTexParameteri(this->target, GL_TEXTURE_WRAP_S, this->properties.wrap.param[0]);
516  if (-1 != _wrap.param[1]) {
517  glTexParameteri(this->target, GL_TEXTURE_WRAP_T, this->properties.wrap.param[1]);
518  }
519  }
520 
521  void setTextureData(T* _pixels) {
522  this->bind();
523  glTexImage2D(this->target, 0, this->properties.type.colorComponents, this->dim[0], this->dim[1], 0, this->properties.type.pixelformat, this->properties.type.datatype, _pixels);
524  }
525 
526  std::shared_ptr<ge::Image> imageRef;
527 
528  };
529 
532 
535 
538 
543  // todo refactoring to
544  //typedef Texture2D <TextureTypeInternals<1, GLint> > Texture2Di;
545 
546  /*
547  * Depth Texture
548  *
549  * typical types:
550  *
551  * TextureTypeInternals(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT)
552  * TextureDepthProperties(GL_LEQUAL, GL_INTENSITY, GL_COMPARE_R_TO_TEXTURE);
553  *
554  */
555  template <typename T, typename PROPERTIES> class DepthTexture : public Texture2D<T, PROPERTIES>
556  {
557  public:
559 
560  GLuint loadEmpty(const vmml::Vector2s& _dim, TextureTypeInternals _type,
562  this->type = _type;
563  this->setSize(_dim);
564  this->createHandle(GL_TEXTURE_2D);
565  this->setMinMagParameter(_minmag);
566  //this->setWrapParameter(_wrap);
567  this->setDepthParameter(_prop);
568  this->setTextureData(this->data);
569  this->generateMipMaps();
570  return this->handle;
571  }
572 
573  GLuint loadEmpty(const vmml::Vector2s& _dim, TextureTypeInternals _type,
575  this->properties.type = _type;
576  this->setSize(_dim);
577  this->createHandle(GL_TEXTURE_2D);
578  this->setMinMagParameter(_minmag);
579  this->setWrapParameter(_wrap);
580  if(_type.colorComponents == GL_STENCIL_INDEX){
581  this->setDepthStencilMode(GL_STENCIL_INDEX);
582  }
583  this->setTextureData(this->data);
584  this->generateMipMaps();
585  return this->handle;
586  }
587 
589  {
590  this->bind();
591  glTexParameteri(this->target, GL_TEXTURE_COMPARE_FUNC, _prop.compareFunc);
592 #ifndef __APPLE__
593  glTexParameteri(this->target, GL_DEPTH_TEXTURE_MODE, _prop.mode);
594 #endif
595  glTexParameteri(this->target, GL_TEXTURE_COMPARE_MODE, _prop.compareMode);
596  this->getOpenGLError("error while setDepthParameter()\n");
597  }
598 
599  /*
600  * set the texture lookup mode to the depth part (DEPTH_COMPONENT) or the
601  * stencil part (STENCIL_INDEX) of the texture.
602  */
603  void setDepthStencilMode(GLenum _mode)
604  {
605  this->bind();
606 #ifndef GENGINE_GL_BELOW_410
607  glTexParameteri(this->target, GL_DEPTH_STENCIL_TEXTURE_MODE, _mode);
608 #endif
609  }
610  private:
611 
612 
613  TextureDepthProperties depthProperties;
614  };
615 
617 
618  /*
619  * 3D Texture
620  *
621  *
622  */
623  template <typename T, typename PROPERTIES> class Texture3D : public TextureType< 3, T, PROPERTIES>
624  {
625  public:
626  Texture3D() { }
627  GLuint load(const vmml::Vector3s& _dim, TextureTypeInternals _type, float* _data)
628  {
629  this->setSize(_dim);
630  int sumDim = this->dim.x() * this->dim.y() * this->dim.z();
631 
632  this->createHandle(GL_TEXTURE_3D);
633  this->properties.type = _type;
634  this->setMinMagParameter(TextureMinMagParameters(GL_LINEAR, GL_LINEAR));
635  this->setWrapParameter(ge::TextureWrapParameter3D(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE));
636  this->setTextureData(_data);
637 
638  return this->handle;
639  }
640 
641  GLuint loadEmpty(const vmml::Vector3s& _dim, TextureTypeInternals _type)
642  {
643  this->setSize(_dim);
644  int sumDim = this->dim.x() * this->dim.y() * this->dim.z();
645 
646  this->createHandle(GL_TEXTURE_3D);
647  this->properties.type = _type;
648  this->setMinMagParameter(TextureMinMagParameters(GL_LINEAR, GL_LINEAR));
649  this->setWrapParameter(ge::TextureWrapParameter3D(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE));
650 
651  return this->handle;
652  }
653 
655  this->bind();
656  glTexParameteri(this->target, GL_TEXTURE_WRAP_S, _wrap.param[0]);
657  if (-1 != _wrap.param[1]) {
658  glTexParameteri(this->target, GL_TEXTURE_WRAP_T, _wrap.param[1]);
659  }
660  if (-1 != _wrap.param[2]) {
661  glTexParameteri(this->target, GL_TEXTURE_WRAP_R, _wrap.param[2]);
662  }
663  }
664 
665  void setTextureData(T* _pixels) {
666  this->bind();
667  glTexImage3D(this->target, 0, this->properties.type.colorComponents, this->dim[0], this->dim[1], this->dim[2], 0, this->properties.type.pixelformat, this->properties.type.datatype, _pixels);
668  }
669 
670  private:
671  };
672 
675 
678 
681 
685 
686 }
687 #endif
Texture1D< GLubyte, TextureProperties< TextureWrapParameter< 1 > > > Texture1Drgb
Definition: Texture.h:415
std::string getName()
Definition: Texture.h:313
Texture2D< GLshort, TextureProperties< TextureWrapParameter< 2 > > > Texture2Ds
Definition: Texture.h:533
void setWrapParameter(TextureWrapParameter3D _wrap)
Definition: Texture.h:654
TextureWrapParameter2D(GLint _s, GLint _t)
Definition: Texture.h:65
Texture3D< GLushort, TextureProperties< TextureWrapParameter< 3 > > > Texture3Dus
Definition: Texture.h:677
Definition: Texture.h:82
TextureWrapParameter()
Definition: Texture.h:34
TextureProperties< TextureWrapParameter1D > TextureProperties1D
Definition: Texture.h:245
GLuint load(const vmml::Vector3s &_dim, TextureTypeInternals _type, float *_data)
Definition: Texture.h:627
GLuint loadFromImage(std::string _filename)
Definition: Texture.h:484
Definition: Texture.h:105
void setWrapParameter(TextureWrapParameter2D _wrap)
Definition: Texture.h:512
Definition: Texture.h:249
GLint compareFunc
Definition: Texture.h:198
TextureMinMagParameters minmag
Definition: Texture.h:241
short getHeight() const
Definition: Texture.h:314
TextureDepthProperties(GLint _compareFunc, GLenum _mode, GLenum _compareMode)
Definition: Texture.h:208
const T & getData() const
Definition: Texture.h:321
void unmapStoragePointer()
Definition: Texture.h:345
Definition: Texture.h:31
WRAP wrap
Definition: Texture.h:242
DepthTexture< GLubyte, TextureProperties< TextureWrapParameter< 2 > > > DepthMap2Drgba
Definition: Texture.h:616
void setDepthParameter(TextureDepthProperties _prop)
Definition: Texture.h:588
Texture2D< GLubyte, TextureProperties< TextureWrapParameter< 2 > > > Texture2Drgb
Definition: Texture.h:541
void clear()
Definition: Buffer.h:29
Texture2D< GLubyte, TextureProperties< TextureWrapParameter< 2 > > > Texture2Drgba
Definition: Texture.h:542
Texture2D< GLubyte, TextureProperties< TextureWrapParameter< 2 > > > Texture2Dub
Definition: Texture.h:539
GLuint load(short _width, TextureTypeInternals _type, T *_data)
Definition: Texture.h:391
void setDepthStencilMode(GLenum _mode)
Definition: Texture.h:603
GLenum target
Definition: TextureHandle.h:83
static TextureTypeInternals r32ui()
Definition: Texture.h:175
GLint param[D]
Definition: Texture.h:46
void setTextureData(T *_pixels)
Definition: Texture.h:405
GLuint loadEmpty(short _width, TextureTypeInternals _type)
Definition: Texture.h:381
void bindTextureForCompute(GLuint _unit, GLint _level, GLboolean _layered, GLint _layer, GLenum _access)
Definition: Texture.h:297
TextureWrapParameter1D(GLint _in)
Definition: Texture.h:52
Texture2D< GLushort, TextureProperties< TextureWrapParameter< 2 > > > Texture2Dus
Definition: Texture.h:534
Texture3D< GLshort, TextureProperties< TextureWrapParameter< 3 > > > Texture3Ds
Definition: Texture.h:676
TextureWrapParameter2D()
Definition: Texture.h:60
TextureDepthProperties()
Definition: Texture.h:202
void generateMipMaps()
Definition: Texture.h:290
static TextureTypeInternals rgba32i()
Definition: Texture.h:186
TextureTypeInternals(GLint _colorComponents, GLenum _pixelformat, GLenum _datatype)
Definition: Texture.h:132
void setTextureData(T *_pixels)
Definition: Texture.h:665
TextureMinMagParameters(GLint _min, GLint _mag)
Definition: Texture.h:91
TextureDepthProperties(const std::shared_ptr< TextureDepthProperties > copy)
Definition: Texture.h:214
Texture2D< GLfloat, TextureProperties< TextureWrapParameter< 2 > > > Texture2Dhdr
Definition: Texture.h:537
GLenum datatype
Definition: Texture.h:119
static TextureTypeInternals r16us()
Definition: Texture.h:176
Texture3D< GLfloat, TextureProperties< TextureWrapParameter< 3 > > > Texture3Df
Definition: Texture.h:679
GLuint load(const vmml::Vector2s &_dim, TextureTypeInternals _type, TextureMinMagParameters _minmag, TextureWrapParameter2D _wrap, T *_data)
Definition: Texture.h:447
GLint colorComponents
Definition: Texture.h:110
Texture3D< GLubyte, TextureProperties< TextureWrapParameter< 3 > > > Texture3Drgba
Definition: Texture.h:684
GLenum getType() const
Definition: Texture.h:320
GLint mode
Definition: Texture.h:199
DepthTexture()
Definition: Texture.h:558
short getWidth() const
Definition: Texture.h:315
void unpackPBO()
Definition: Texture.h:350
void setSize(vmml::vector< D, short > _dim)
Definition: Texture.h:357
GLuint loadSynchWithDefaultParameter(const vmml::Vector2s &_dim, TextureTypeInternals _type, T *_data)
Definition: Texture.h:462
void setWrapParameter(TextureWrapParameter1D _wrap)
Definition: Texture.h:398
void createHandle(GLenum _target)
Definition: TextureHandle.cpp:43
std::shared_ptr< ge::Image > imageRef
Definition: Texture.h:526
static TextureTypeInternals rgba32f()
Definition: Texture.h:185
void preloadCommit()
Definition: Texture.h:474
TextureTypeInternals type
Definition: Texture.h:240
GLuint loadEmptyWithDefaultParameter(vmml::Vector2s _dim, TextureTypeInternals _type, bool _allocateTexImage=true)
Definition: Texture.h:428
T * data
Definition: Texture.h:362
TextureProperties(TextureTypeInternals _type, TextureMinMagParameters _minmag, WRAP _wrap)
Definition: Texture.h:225
static TextureTypeInternals rgba8i()
Definition: Texture.h:183
static TextureTypeInternals rgba8()
Definition: Texture.h:182
virtual void setTextureData(T *_pixels)=0
void set(GLint _min, GLint _mag)
Definition: Texture.h:100
static TextureTypeInternals r32f()
Definition: Texture.h:173
Definition: Texture.h:623
Definition: Texture.h:376
void bind(GLint _unit=-1) const
Definition: TextureHandle.cpp:65
Definition: Texture.h:49
Texture1D< GLfloat, TextureProperties< TextureWrapParameter< 1 > > > Texture1Df
Definition: Texture.h:413
Definition: Texture.h:423
GLint mag
Definition: Texture.h:85
Definition: Texture.h:57
int getStorageSize() const
Definition: Texture.h:316
Texture2D< GLuint, TextureProperties< TextureWrapParameter< 2 > > > Texture2Dui
Definition: Texture.h:531
void setTextureStorage(const vmml::Vector2s &_dim, GLsizei _levels, GLenum _internalFormat)
Definition: Texture.h:495
Texture3D< GLubyte, TextureProperties< TextureWrapParameter< 3 > > > Texture3Dub
Definition: Texture.h:682
Definition: Texture.h:71
Texture2D< GLfloat, TextureProperties< TextureWrapParameter< 2 > > > Texture2Df
Definition: Texture.h:536
GLint getInternalFormat() const
Definition: Texture.h:318
TextureWrapParameter(const std::shared_ptr< TextureWrapParameter > copy)
Definition: Texture.h:40
Definition: Texture.h:555
static TextureTypeInternals rgba32ui()
Definition: Texture.h:187
GLenum pixelformat
Definition: Texture.h:114
GLuint loadEmpty(const vmml::Vector2s &_dim, TextureTypeInternals _type, TextureMinMagParameters _minmag, TextureWrapParameter2D _wrap, bool _allocateTexImage=true)
Definition: Texture.h:435
TextureMinMagParameters(const std::shared_ptr< TextureMinMagParameters > copy)
Definition: Texture.h:95
TextureType()
Definition: Texture.h:252
Definition: Texture.h:196
Texture3D< GLfloat, TextureProperties< TextureWrapParameter< 3 > > > Texture3Dhdr
Definition: Texture.h:680
TextureTypeInternals()
Definition: Texture.h:126
GLint compareMode
Definition: Texture.h:200
GLint min
Definition: Texture.h:84
Texture1D< GLubyte, TextureProperties< TextureWrapParameter< 1 > > > Texture1Dub
Definition: Texture.h:414
Texture3D()
Definition: Texture.h:626
GLuint loadEmpty(const vmml::Vector3s &_dim, TextureTypeInternals _type)
Definition: Texture.h:641
vmml::vector< D, short > dim
Definition: Texture.h:361
void bindBuffer()
Definition: Buffer.h:96
GLuint loadWithDefaultParameter(const vmml::Vector2s &_dim, TextureTypeInternals _type, T *_data)
Definition: Texture.h:455
Texture3D< GLuint, TextureProperties< TextureWrapParameter< 3 > > > Texture3Dui
Definition: Texture.h:674
TextureProperties(const std::shared_ptr< TextureProperties > copy)
Definition: Texture.h:234
void loadDataToPBO(T *_data)
Definition: Texture.h:336
TextureMinMagParameters()
Definition: Texture.h:87
void setTextureData(T *_pixels)
Definition: Texture.h:521
Texture3D< GLint, TextureProperties< TextureWrapParameter< 3 > > > Texture3Di
Definition: Texture.h:673
Texture3D< GLubyte, TextureProperties< TextureWrapParameter< 3 > > > Texture3Drgb
Definition: Texture.h:683
static TextureTypeInternals r16ui()
Definition: Texture.h:177
TextureTypeInternals(const std::shared_ptr< TextureTypeInternals > copy)
Definition: Texture.h:136
void setComponentCount()
Definition: Texture.h:150
~TextureType()
Definition: Texture.h:257
int countPixel() const
Definition: Texture.h:273
void clear()
Definition: Texture.h:261
GLenum getFormat() const
Definition: Texture.h:319
TextureProperties()
Definition: Texture.h:224
Texture1D()
Definition: Texture.h:379
vmml::vector< D, short > getDimensions() const
Definition: Texture.h:317
TextureWrapParameter3D(GLint _s, GLint _t, GLint _r)
Definition: Texture.h:74
Definition: AvalancheTrainingSimulationEngine.h:28
static TextureTypeInternals rgba8ui()
Definition: Texture.h:184
void set(GLint _colorComponents, GLenum _pixelformat, GLenum _datatype)
Definition: Texture.h:143
static TextureTypeInternals rg8()
Definition: Texture.h:180
void getOpenGLError(std::string _input)
Definition: TextureHandle.cpp:137
Texture2D< GLint, TextureProperties< TextureWrapParameter< 2 > > > Texture2Di
Definition: Texture.h:530
void unmapBuffer()
Definition: Buffer.h:91
void loadImage(std::string _filename)
Definition: Texture.h:504
Texture1D< GLubyte, TextureProperties< TextureWrapParameter< 1 > > > Texture1Drgba
Definition: Texture.h:416
TextureProperties< TextureWrapParameter3D > TextureProperties3D
Definition: Texture.h:247
GLuint handle
Definition: TextureHandle.h:84
static TextureTypeInternals rg16f()
Definition: Texture.h:179
Definition: Texture.h:221
PROPERTIES properties
Definition: Texture.h:366
void preloadSyncWithDefaultParameter(const vmml::Vector2s &_dim, TextureTypeInternals _type, T *_data)
Definition: Texture.h:469
Texture2D< GLubyte, TextureProperties< TextureWrapParameter< 2 > > > Texture2Drg
Definition: Texture.h:540
static TextureTypeInternals rgb8()
Definition: Texture.h:181
ge::PixelUnpackBuffer textureBuffer
Definition: Texture.h:368
static TextureTypeInternals r16f()
Definition: Texture.h:178
GLuint loadEmpty(const vmml::Vector2s &_dim, TextureTypeInternals _type, TextureMinMagParameters _minmag, TextureWrapParameter2D _wrap)
Definition: Texture.h:573
static TextureTypeInternals r32i()
Definition: Texture.h:174
void setMinMagParameter(TextureMinMagParameters _minmag)
Definition: Texture.h:281
Texture2D()
Definition: Texture.h:426
void unbindBuffer()
Definition: Buffer.h:100
GLuint loadEmpty(const vmml::Vector2s &_dim, TextureTypeInternals _type, TextureMinMagParameters _minmag, TextureWrapParameter2D _wrap, TextureDepthProperties _prop)
Definition: Texture.h:560
std::string name
Definition: Texture.h:363
T * mapStoragePointer()
Definition: Texture.h:323
void unbind(GLint _unit=-1) const
Definition: TextureHandle.cpp:77
Definition: TextureHandle.h:18
short compCount
Definition: Texture.h:108
TextureProperties< TextureWrapParameter2D > TextureProperties2D
Definition: Texture.h:246