SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGLTexture.h
Go to the documentation of this file.
1 /**
2  * \file SLGLTexture.h
3  * \date July 2014
4  * \authors Marcus Hudritsch, Martin Christen
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLGLTEXTURE_H
11 #define SLGLTEXTURE_H
12 
13 #include <SLObject.h>
14 #include <CVImage.h>
15 #include <SLGLVertexArray.h>
16 #include <SLMat4.h>
17 #include <atomic>
18 #include <mutex>
19 
20 #ifdef SL_BUILD_WITH_KTX
21 # include <ktx.h>
22 #endif
23 
24 #ifdef SL_HAS_OPTIX
25 # include <cuda.h>
26 #endif
27 
28 class SLGLState;
29 class SLAssetManager;
30 class SLGLProgram;
31 
32 //-----------------------------------------------------------------------------
33 // Special constants for anisotropic filtering
34 #define SL_ANISOTROPY_MAX (GL_LINEAR_MIPMAP_LINEAR + 1)
35 #define SL_ANISOTROPY_2 (GL_LINEAR_MIPMAP_LINEAR + 2)
36 #define SL_ANISOTROPY_4 (GL_LINEAR_MIPMAP_LINEAR + 4)
37 #define SL_ANISOTROPY_8 (GL_LINEAR_MIPMAP_LINEAR + 8)
38 #define SL_ANISOTROPY_16 (GL_LINEAR_MIPMAP_LINEAR + 16)
39 #define SL_ANISOTROPY_32 (GL_LINEAR_MIPMAP_LINEAR + 32)
40 //-----------------------------------------------------------------------------
41 // Extension constant for anisotropic filtering
42 #ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
43 # define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
44 #endif
45 #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
46 # define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
47 #endif
48 //-----------------------------------------------------------------------------
49 // Constants for HDR and BRDF LUT images
50 #ifndef SL_EMSCRIPTEN
51 # define SL_HDR_GL_INTERNAL_FORMAT GL_RGB16F
52 # define SL_HDR_GL_FORMAT GL_RGB
53 # define SL_HDR_GL_TYPE GL_FLOAT
54 # define SL_HDR_PIXEL_BYTES 3
55 # define SL_BRDF_LUT_GL_INTERNAL_FORMAT GL_RG16F
56 # define SL_BRDF_LUT_GL_FORMAT GL_RG
57 # define SL_BRDF_LUT_GL_TYPE GL_FLOAT
58 # define SL_BRDF_LUT_PIXEL_BYTES 4
59 # define SL_READ_PIXELS_GL_FORMAT GL_RGB
60 # define SL_READ_PIXELS_CV_FORMAT PF_rgb
61 #else
62 # define SL_HDR_GL_INTERNAL_FORMAT GL_RGB
63 # define SL_HDR_GL_FORMAT GL_RGB
64 # define SL_HDR_GL_TYPE GL_UNSIGNED_BYTE
65 # define SL_HDR_PIXEL_BYTES 3
66 # define SL_BRDF_LUT_GL_INTERNAL_FORMAT GL_RGBA
67 # define SL_BRDF_LUT_GL_FORMAT GL_RGBA
68 # define SL_BRDF_LUT_GL_TYPE GL_UNSIGNED_BYTE
69 # define SL_BRDF_LUT_PIXEL_BYTES 3
70 # define SL_READ_PIXELS_GL_FORMAT GL_RGBA
71 # define SL_READ_PIXELS_CV_FORMAT PF_rgba
72 #endif
73 //-----------------------------------------------------------------------------
74 //! Texture type enumeration & their filename appendix for auto type detection
76 {
77  TT_unknown, // Will be handled as color maps
78  TT_diffuse, // D: Diffuse color map (aka albedo or just color map)
79  TT_normal, // N: Normal map for normal bump mapping
80  TT_height, // H: Height map for height map bump or parallax mapping
81  TT_specular, // S: Specular map
82  TT_emissive, // E: Emissive map
83  TT_occlusion, // O: Ambient occlusion map
84  TT_roughness, // R: Roughness map (PBR Cook-Torrance roughness 0-1)
85  TT_metallic, // M: Metalness map (PBR Cook-Torrance metallic 0-1)
86  TT_roughMetal, // RM: Roughness on G, metallness on B (R unused)
87  TT_occluRoughMetal, // ORM: Occlusion on R, roughness on G, metallness on B
88  TT_font, // F: Texture map for fonts
89  TT_hdr, // High Dynamic Range images
90  TT_environmentCubemap, // Environment cubemap generated from HDR Textures
91  TT_irradianceCubemap, // Irradiance cubemap generated from HDR Textures
92  TT_roughnessCubemap, // Prefilter roughness cubemap
93  TT_brdfLUT, // BRDF 2D look up table Texture
94  TT_videoBkgd, // Video background
95  TT_numTextureType // New texture types must be before TT_numTextureType
96 };
97 //-----------------------------------------------------------------------------
98 //! Texture object for OpenGL texturing
99 /*!
100  The SLGLTexture class implements an OpenGL texture object that can be used by the
101  SLMaterial class. A texture can have 1-n CVImages in the vector _images.
102  A simple 2D texture has just a single texture image (_images[0]). For cube maps
103  you will need 6 images (_images[0-5]). For 3D textures you can have as much
104  images of the same size than your GPU and/or CPU memory can hold.
105  The images are not released after the OpenGL texture creation unless you set the
106  flag _deleteImageAfterBuild to true. If the images get deleted after build,
107  you won't be able to ray trace the scene.
108 */
109 class SLGLTexture : public SLObject
110 {
111 public:
112  //! Default ctor for all stack instances (not created with new)
113  SLGLTexture();
114 
115  //! ctor for 1D texture with internal image allocation
116  explicit SLGLTexture(SLAssetManager* assetMgr,
117  const SLVCol4f& colors,
118  SLint min_filter = GL_LINEAR,
119  SLint mag_filter = GL_LINEAR,
120  SLint wrapS = GL_REPEAT,
121  const SLstring& name = "2D-Texture");
122 
123  //! ctor for empty 2D textures
124  explicit SLGLTexture(SLAssetManager* assetMgr,
125  SLint min_filter,
126  SLint mag_filter,
127  SLint wrapS,
128  SLint wrapT,
129  SLenum target = GL_TEXTURE_2D);
130 
131  //! ctor for 2D textures from byte pointer
132  explicit SLGLTexture(SLAssetManager* assetMgr,
133  unsigned char* data,
134  int width,
135  int height,
136  int cvtype,
137  SLint min_filter,
138  SLint mag_filter,
139  SLTextureType type,
140  SLint wrapS,
141  SLint wrapT);
142 
143  //! ctor for 2D textures with internal image allocation
144  explicit SLGLTexture(SLAssetManager* assetMgr,
145  const SLstring& imageFilename,
146  SLint min_filter = GL_LINEAR_MIPMAP_LINEAR,
147  SLint mag_filter = GL_LINEAR,
148  SLTextureType type = TT_unknown,
149  SLint wrapS = GL_REPEAT,
150  SLint wrapT = GL_REPEAT);
151 
152  //! ctor for 3D texture with internal image allocation
153  explicit SLGLTexture(SLAssetManager* assetMgr,
154  const SLVstring& imageFilenames,
155  SLint min_filter = GL_LINEAR,
156  SLint mag_filter = GL_LINEAR,
157  SLint wrapS = GL_REPEAT,
158  SLint wrapT = GL_REPEAT,
159  const SLstring& name = "3D-Texture",
160  SLbool loadGrayscaleIntoAlpha = false);
161 
162  //! ctor for 3D texture from a single file with depth as 3rd dimension
163  explicit SLGLTexture(SLAssetManager* assetMgr,
164  SLint depth,
165  const SLstring& imageFilename,
166  SLint min_filter = GL_LINEAR,
167  SLint mag_filter = GL_LINEAR,
168  SLint wrapS = GL_REPEAT,
169  SLint wrapT = GL_REPEAT,
170  const SLstring& name = "3D-Texture",
171  SLbool loadGrayscaleIntoAlpha = false);
172 
173  //! ctor for cube mapping with internal image allocation
174  SLGLTexture(SLAssetManager* assetMgr,
175  const SLstring& imageFilenameXPos,
176  const SLstring& imageFilenameXNeg,
177  const SLstring& imageFilenameYPos,
178  const SLstring& imageFilenameYNeg,
179  const SLstring& imageFilenameZPos,
180  const SLstring& imageFilenameZNeg,
181  SLint min_filter = GL_LINEAR,
182  SLint mag_filter = GL_LINEAR,
183  SLTextureType type = TT_unknown);
184 
185  ~SLGLTexture() override;
186 
187  virtual void build(SLint texUnit);
188 
189  void deleteData(SLbool deleteAlsoOnGPU);
190  void deleteDataGpu();
191  void deleteImages();
192  void bindActive(SLuint texUnit = 0);
193  void fullUpdate();
194  void drawSprite(SLbool doUpdate, SLfloat x, SLfloat y, SLfloat w, SLfloat h);
195  void cubeUV2XYZ(SLint index, SLfloat u, SLfloat v, SLfloat& x, SLfloat& y, SLfloat& z);
196  void cubeXYZ2UV(SLfloat x, SLfloat y, SLfloat z, SLint& index, SLfloat& u, SLfloat& v);
197  SLstring filterString(SLint glFilter);
198 
199  // Setters
200  void texType(SLTextureType bt) { _texType = bt; }
201  void uvIndex(SLbyte i) { _uvIndex = i; }
202  void bumpScale(SLfloat bs) { _bumpScale = bs; }
203  void minFiler(SLint minF) { _min_filter = minF; } // must be called before build
204  void magFiler(SLint magF) { _mag_filter = magF; } // must be called before build
205  void needsUpdate(SLbool update) { _needsUpdate = update; }
206 
207  // must be called before build and makes only sense for SL_TEXTURE_EXTERNAL
208  void textureSize(int width, int height)
209  {
210  _width = width;
211  _height = height;
212  }
213 
214  //! If deleteImageAfterBuild is set to true you won't be able to ray trace the scene
216 
217  // Getters
218  SLuint width() { return _width; }
219  SLuint height() { return _height; }
220  SLuint depth() { return _depth; }
221  SLbyte uvIndex() { return _uvIndex; }
225  CVVImage& images() { return _images; }
226  SLenum target() const { return _target; }
227  SLuint texID() const { return _texID; }
229  SLfloat bumpScale() const { return _bumpScale; }
230  SLCol4f getTexelf(SLfloat u, SLfloat v, SLuint imgIndex = 0);
231  SLCol4f getTexelf(const SLVec3f& cubemapDir);
232  SLbool hasAlpha() { return (!_images.empty() &&
233  ((_images[0]->format() == PF_rgba ||
234  _images[0]->format() == PF_bgra) ||
235  _texType == TT_font)); }
236  SLMat4f tm() { return _tm; }
237  SLbool autoCalcTM3D() const { return _autoCalcTM3D; }
239  SLstring typeName();
241  bool isTexture() { return (bool)glIsTexture(_texID); }
244 
245 #ifdef SL_BUILD_WITH_KTX
246  SLint compressionFormat()
247  {
248  return _compressionFormat;
249  }
250 #endif
251 
252 #ifdef SL_HAS_OPTIX
253  void buildCudaTexture();
254  CUtexObject getCudaTextureObject()
255  {
256  buildCudaTexture();
257  return _cudaTextureObject;
258  }
259 #endif
260 
261  // Misc
262  static SLTextureType detectType(const SLstring& filename);
263 #ifdef SL_BUILD_WITH_KTX
264  static string compressionFormatStr(int compressionFormat);
265  static string ktxErrorStr(int ktxErrorCode);
266 #endif
267  static string internalFormatStr(int internalFormat);
268 
269  void build2DMipmaps(SLint target, SLuint index);
270  SLbool copyVideoImage(SLint camWidth,
271  SLint camHeight,
272  CVPixelFormatGL glFormat,
273  SLuchar* data,
274  SLbool isContinuous,
275  SLbool isTopLeft);
276 
277  SLbool copyVideoImage(SLint camWidth,
278  SLint camHeight,
279  CVPixelFormatGL srcFormat,
280  CVPixelFormatGL dstFormat,
281  SLuchar* data,
282  SLbool isContinuous,
283  SLbool isTopLeft);
284 
285  void calc3DGradients(SLint sampleRadius, const function<void(int)>& onUpdateProgress = nullptr);
286  void smooth3DGradients(SLint smoothRadius, function<void(int)> onUpdateProgress = nullptr);
287 
288  // Bumpmap methods
289  SLVec2f dudv(SLfloat u, SLfloat v); //! Returns the derivation as [s,t]
290 
291  // Statics
292  static SLfloat maxAnisotropy; //!< max. anisotropy available
293  static SLuint totalNumBytesOnGPU; //!< Total NO. of bytes used for textures on GPU
294 
295 protected:
296  // loading the image files
297  void load(const SLstring& filename,
298  SLbool flipVertical = true,
299  SLbool loadGrayscaleIntoAlpha = false);
300  void load(const SLVCol4f& colors);
301 
302  CVVImage _images; //!< Vector of CVImage pointers
303  SLuint _texID; //!< OpenGL texture ID
304  SLTextureType _texType; //!< See SLTextureType
305  SLint _width; //!< Texture image width in pixels (images exist either in _images or on the GPU or on both)
306  SLint _height; //!< Texture image height in pixels (images exist either in _images or on the GPU or on both)
307  SLint _depth; //!< 3D Texture image depth (images exist either in _images or on the GPU or on both)
308  SLbyte _uvIndex; //!< Texture coordinate index in SLMesh (0 = default)
309  SLint _internalFormat; //!< Internal OpenGL format
310  SLint _bytesPerPixel; //!< Bytes per texture image pixel (images exist either in _images or on the GPU or on both)
311  SLint _min_filter; //!< Minification filter
312  SLint _mag_filter; //!< Magnification filter
313  SLint _wrap_s; //!< Wrapping in s direction
314  SLint _wrap_t; //!< Wrapping in t direction
315  SLenum _target; //!< texture target
316  SLMat4f _tm; //!< texture matrix
317  SLuint _bytesOnGPU; //!< NO. of bytes on GPU
318  SLuint _bytesInFile; //!< NO. of bytes in file
319  SLbool _autoCalcTM3D; //!< Flag if texture matrix should be calculated from AABB for 3D mapping
320  SLfloat _bumpScale; //!< Bump mapping scale factor
321  SLbool _resizeToPow2; //!< Flag if image should be resized to n^2
322  SLGLVertexArray _vaoSprite; //!< Vertex array object for sprite rendering
323  std::atomic<bool> _needsUpdate{}; //!< Flag if image needs an single update
324  std::mutex _mutex; //!< Mutex to protect parallel access (used in ray tracing)
325 
326  SLbool _deleteImageAfterBuild; //!< Flag if images should be deleted after build on GPU
327  SLbool _compressedTexture = false; //!< True for compressed texture format on GPU
328 
329 #ifdef SL_BUILD_WITH_KTX
330  ktxTexture2* _ktxTexture = nullptr; //!< Pointer to the KTX texture after loading
331  ktx_transcode_fmt_e _compressionFormat = KTX_TTF_NOSELECTION; //!< compression format on GPU
332  std::string _ktxFileName;
333 #endif
334 
335 #ifdef SL_HAS_OPTIX
336  CUgraphicsResource _cudaGraphicsResource; //!< Cuda Graphics object
337  CUtexObject _cudaTextureObject;
338 #endif
339 };
340 //-----------------------------------------------------------------------------
341 //! STL vector of SLGLTexture pointers
342 typedef vector<SLGLTexture*> SLVGLTexture;
343 //-----------------------------------------------------------------------------
344 #endif
CVPixelFormatGL
Pixel format according to OpenGL pixel format defines.
Definition: CVImage.h:24
@ PF_bgra
Definition: CVImage.h:39
@ PF_rgba
Definition: CVImage.h:37
vector< CVImage * > CVVImage
Definition: CVImage.h:152
float SLfloat
Definition: SL.h:173
unsigned int SLenum
Definition: SL.h:176
unsigned int SLuint
Definition: SL.h:171
unsigned char SLuchar
Definition: SL.h:163
bool SLbool
Definition: SL.h:175
vector< SLstring > SLVstring
Definition: SL.h:201
signed char SLbyte
Definition: SL.h:166
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
SLTextureType
Texture type enumeration & their filename appendix for auto type detection.
Definition: SLGLTexture.h:76
@ TT_occluRoughMetal
Definition: SLGLTexture.h:87
@ TT_brdfLUT
Definition: SLGLTexture.h:93
@ TT_height
Definition: SLGLTexture.h:80
@ TT_videoBkgd
Definition: SLGLTexture.h:94
@ TT_metallic
Definition: SLGLTexture.h:85
@ TT_unknown
Definition: SLGLTexture.h:77
@ TT_irradianceCubemap
Definition: SLGLTexture.h:91
@ TT_environmentCubemap
Definition: SLGLTexture.h:90
@ TT_roughnessCubemap
Definition: SLGLTexture.h:92
@ TT_roughMetal
Definition: SLGLTexture.h:86
@ TT_roughness
Definition: SLGLTexture.h:84
@ TT_specular
Definition: SLGLTexture.h:81
@ TT_numTextureType
Definition: SLGLTexture.h:95
@ TT_normal
Definition: SLGLTexture.h:79
@ TT_diffuse
Definition: SLGLTexture.h:78
@ TT_occlusion
Definition: SLGLTexture.h:83
@ TT_hdr
Definition: SLGLTexture.h:89
@ TT_emissive
Definition: SLGLTexture.h:82
@ TT_font
Definition: SLGLTexture.h:88
vector< SLGLTexture * > SLVGLTexture
STL vector of SLGLTexture pointers.
Definition: SLGLTexture.h:342
Wrapper class around OpenGL Vertex Array Objects (VAO)
vector< SLCol4f > SLVCol4f
Definition: SLVec4.h:241
Toplevel holder of the assets meshes, materials, textures and shaders.
Encapsulation of an OpenGL shader program object.
Definition: SLGLProgram.h:56
Singleton class holding all OpenGL states.
Definition: SLGLState.h:71
Texture object for OpenGL texturing.
Definition: SLGLTexture.h:110
SLMat4f tm()
Definition: SLGLTexture.h:236
SLbool _resizeToPow2
Flag if image should be resized to n^2.
Definition: SLGLTexture.h:321
SLint bytesPerPixel()
Definition: SLGLTexture.h:222
void needsUpdate(SLbool update)
Definition: SLGLTexture.h:205
void deleteImages()
Deletes the CVImages in _images. No more texture mapping in ray tracing.
void build2DMipmaps(SLint target, SLuint index)
SLbool autoCalcTM3D() const
Definition: SLGLTexture.h:237
void minFiler(SLint minF)
Definition: SLGLTexture.h:203
static string internalFormatStr(int internalFormat)
Returns the internal pixel format from OpenGL.
void magFiler(SLint magF)
Definition: SLGLTexture.h:204
SLint _bytesPerPixel
Bytes per texture image pixel (images exist either in _images or on the GPU or on both)
Definition: SLGLTexture.h:310
void textureSize(int width, int height)
Definition: SLGLTexture.h:208
SLTextureType texType()
Definition: SLGLTexture.h:228
SLint _width
Texture image width in pixels (images exist either in _images or on the GPU or on both)
Definition: SLGLTexture.h:305
SLfloat bumpScale() const
Definition: SLGLTexture.h:229
SLfloat _bumpScale
Bump mapping scale factor.
Definition: SLGLTexture.h:320
SLuint height()
Definition: SLGLTexture.h:219
void cubeXYZ2UV(SLfloat x, SLfloat y, SLfloat z, SLint &index, SLfloat &u, SLfloat &v)
Computes the uv and cubemap image index from a unnormalised vector x,y,z.
CVVImage & images()
Definition: SLGLTexture.h:225
SLuint _bytesOnGPU
NO. of bytes on GPU.
Definition: SLGLTexture.h:317
SLMat4f _tm
texture matrix
Definition: SLGLTexture.h:316
void deleteImageAfterBuild(SLbool delImg)
If deleteImageAfterBuild is set to true you won't be able to ray trace the scene.
Definition: SLGLTexture.h:215
SLint bytesOnGPU()
Definition: SLGLTexture.h:223
SLenum target() const
Definition: SLGLTexture.h:226
SLuint width()
Definition: SLGLTexture.h:218
SLint bytesInFile()
Definition: SLGLTexture.h:224
SLint _wrap_t
Wrapping in t direction.
Definition: SLGLTexture.h:314
SLVec2f dudv(SLfloat u, SLfloat v)
SLint _min_filter
Minification filter.
Definition: SLGLTexture.h:311
void load(const SLstring &filename, SLbool flipVertical=true, SLbool loadGrayscaleIntoAlpha=false)
Loads the texture, converts color depth & applies vertical mirroring.
SLint _wrap_s
Wrapping in s direction.
Definition: SLGLTexture.h:313
static SLfloat maxAnisotropy
Returns the derivation as [s,t].
Definition: SLGLTexture.h:292
SLstring minificationFilterName()
Definition: SLGLTexture.h:242
SLbool _deleteImageAfterBuild
Flag if images should be deleted after build on GPU.
Definition: SLGLTexture.h:326
SLint _height
Texture image height in pixels (images exist either in _images or on the GPU or on both)
Definition: SLGLTexture.h:306
SLTextureType _texType
See SLTextureType.
Definition: SLGLTexture.h:304
~SLGLTexture() override
void bumpScale(SLfloat bs)
Definition: SLGLTexture.h:202
SLbyte uvIndex()
Definition: SLGLTexture.h:221
void deleteData(SLbool deleteAlsoOnGPU)
Delete all data (CVImages and GPU textures)
CVVImage _images
Vector of CVImage pointers.
Definition: SLGLTexture.h:302
SLbool hasAlpha()
Definition: SLGLTexture.h:232
SLint _depth
3D Texture image depth (images exist either in _images or on the GPU or on both)
Definition: SLGLTexture.h:307
SLbyte _uvIndex
Texture coordinate index in SLMesh (0 = default)
Definition: SLGLTexture.h:308
SLstring typeShortName()
Returns the texture type short.
virtual void build(SLint texUnit)
SLenum _target
texture target
Definition: SLGLTexture.h:315
void cubeUV2XYZ(SLint index, SLfloat u, SLfloat v, SLfloat &x, SLfloat &y, SLfloat &z)
Computes the unnormalised vector x,y,z from tex. coords. uv with cubemap index.
void uvIndex(SLbyte i)
Definition: SLGLTexture.h:201
SLstring typeName()
Returns the texture type as string.
std::atomic< bool > _needsUpdate
Flag if image needs an single update.
Definition: SLGLTexture.h:323
SLint _internalFormat
Internal OpenGL format.
Definition: SLGLTexture.h:309
void texType(SLTextureType bt)
Definition: SLGLTexture.h:200
static SLTextureType detectType(const SLstring &filename)
Detects the texture type from the filename appendix (See SLTexType def.)
SLGLTexture()
Default ctor for all stack instances (not created with new)
Definition: SLGLTexture.cpp:37
std::mutex _mutex
Mutex to protect parallel access (used in ray tracing)
Definition: SLGLTexture.h:324
SLuint depth()
Definition: SLGLTexture.h:220
void calc3DGradients(SLint sampleRadius, const function< void(int)> &onUpdateProgress=nullptr)
void deleteDataGpu()
Deletes the OpenGL texture objects and releases the memory on the GPU.
SLuint texID() const
Definition: SLGLTexture.h:227
SLbool _compressedTexture
True for compressed texture format on GPU.
Definition: SLGLTexture.h:327
SLstring magnificationFilterName()
Definition: SLGLTexture.h:243
SLuint _bytesInFile
NO. of bytes in file.
Definition: SLGLTexture.h:318
SLint _mag_filter
Magnification filter.
Definition: SLGLTexture.h:312
SLstring filterString(SLint glFilter)
Returns OpenGL texture filter as string.
void smooth3DGradients(SLint smoothRadius, function< void(int)> onUpdateProgress=nullptr)
SLbool needsUpdate()
Definition: SLGLTexture.h:238
static SLuint totalNumBytesOnGPU
Total NO. of bytes used for textures on GPU.
Definition: SLGLTexture.h:293
void fullUpdate()
void bindActive(SLuint texUnit=0)
SLbool _autoCalcTM3D
Flag if texture matrix should be calculated from AABB for 3D mapping.
Definition: SLGLTexture.h:319
SLGLVertexArray _vaoSprite
Vertex array object for sprite rendering.
Definition: SLGLTexture.h:322
void drawSprite(SLbool doUpdate, SLfloat x, SLfloat y, SLfloat w, SLfloat h)
Draws the texture as 2D sprite with OpenGL buffers.
bool isTexture()
Definition: SLGLTexture.h:241
SLbool copyVideoImage(SLint camWidth, SLint camHeight, CVPixelFormatGL glFormat, SLuchar *data, SLbool isContinuous, SLbool isTopLeft)
Copies the image data from a video camera into the current video image.
SLuint _texID
OpenGL texture ID.
Definition: SLGLTexture.h:303
SLCol4f getTexelf(SLfloat u, SLfloat v, SLuint imgIndex=0)
SLGLTexture::getTexelf returns a pixel color from u & v texture coordinates.
SLGLVertexArray encapsulates the core OpenGL drawing.
Base class for all other classes.
Definition: SLObject.h:23
const SLstring & name() const
Definition: SLObject.h:38