20 #ifdef SL_BUILD_WITH_KTX
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)
42 #ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
43 # define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
45 #ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
46 # define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
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
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
118 SLint min_filter = GL_LINEAR,
119 SLint mag_filter = GL_LINEAR,
120 SLint wrapS = GL_REPEAT,
146 SLint min_filter = GL_LINEAR_MIPMAP_LINEAR,
147 SLint mag_filter = GL_LINEAR,
149 SLint wrapS = GL_REPEAT,
150 SLint wrapT = GL_REPEAT);
155 SLint min_filter = GL_LINEAR,
156 SLint mag_filter = GL_LINEAR,
157 SLint wrapS = GL_REPEAT,
158 SLint wrapT = GL_REPEAT,
160 SLbool loadGrayscaleIntoAlpha =
false);
166 SLint min_filter = GL_LINEAR,
167 SLint mag_filter = GL_LINEAR,
168 SLint wrapS = GL_REPEAT,
169 SLint wrapT = GL_REPEAT,
171 SLbool loadGrayscaleIntoAlpha =
false);
181 SLint min_filter = GL_LINEAR,
182 SLint mag_filter = GL_LINEAR,
245 #ifdef SL_BUILD_WITH_KTX
246 SLint compressionFormat()
248 return _compressionFormat;
253 void buildCudaTexture();
254 CUtexObject getCudaTextureObject()
257 return _cudaTextureObject;
263 #ifdef SL_BUILD_WITH_KTX
264 static string compressionFormatStr(
int compressionFormat);
265 static string ktxErrorStr(
int ktxErrorCode);
285 void calc3DGradients(
SLint sampleRadius,
const function<
void(
int)>& onUpdateProgress =
nullptr);
298 SLbool flipVertical =
true,
299 SLbool loadGrayscaleIntoAlpha =
false);
329 #ifdef SL_BUILD_WITH_KTX
330 ktxTexture2* _ktxTexture =
nullptr;
331 ktx_transcode_fmt_e _compressionFormat = KTX_TTF_NOSELECTION;
332 std::string _ktxFileName;
336 CUgraphicsResource _cudaGraphicsResource;
337 CUtexObject _cudaTextureObject;
CVPixelFormatGL
Pixel format according to OpenGL pixel format defines.
vector< CVImage * > CVVImage
vector< SLstring > SLVstring
SLTextureType
Texture type enumeration & their filename appendix for auto type detection.
vector< SLGLTexture * > SLVGLTexture
STL vector of SLGLTexture pointers.
Wrapper class around OpenGL Vertex Array Objects (VAO)
vector< SLCol4f > SLVCol4f
Toplevel holder of the assets meshes, materials, textures and shaders.
Encapsulation of an OpenGL shader program object.
Singleton class holding all OpenGL states.
Texture object for OpenGL texturing.
SLbool _resizeToPow2
Flag if image should be resized to n^2.
void needsUpdate(SLbool update)
void deleteImages()
Deletes the CVImages in _images. No more texture mapping in ray tracing.
void build2DMipmaps(SLint target, SLuint index)
SLbool autoCalcTM3D() const
void minFiler(SLint minF)
static string internalFormatStr(int internalFormat)
Returns the internal pixel format from OpenGL.
void magFiler(SLint magF)
SLint _bytesPerPixel
Bytes per texture image pixel (images exist either in _images or on the GPU or on both)
void textureSize(int width, int height)
SLint _width
Texture image width in pixels (images exist either in _images or on the GPU or on both)
SLfloat bumpScale() const
SLfloat _bumpScale
Bump mapping scale factor.
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.
SLuint _bytesOnGPU
NO. of bytes on GPU.
SLMat4f _tm
texture matrix
void deleteImageAfterBuild(SLbool delImg)
If deleteImageAfterBuild is set to true you won't be able to ray trace the scene.
SLint _wrap_t
Wrapping in t direction.
SLVec2f dudv(SLfloat u, SLfloat v)
SLint _min_filter
Minification filter.
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.
static SLfloat maxAnisotropy
Returns the derivation as [s,t].
SLstring minificationFilterName()
SLbool _deleteImageAfterBuild
Flag if images should be deleted after build on GPU.
SLint _height
Texture image height in pixels (images exist either in _images or on the GPU or on both)
SLTextureType _texType
See SLTextureType.
void bumpScale(SLfloat bs)
void deleteData(SLbool deleteAlsoOnGPU)
Delete all data (CVImages and GPU textures)
CVVImage _images
Vector of CVImage pointers.
SLint _depth
3D Texture image depth (images exist either in _images or on the GPU or on both)
SLbyte _uvIndex
Texture coordinate index in SLMesh (0 = default)
SLstring typeShortName()
Returns the texture type short.
virtual void build(SLint texUnit)
SLenum _target
texture target
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.
SLstring typeName()
Returns the texture type as string.
std::atomic< bool > _needsUpdate
Flag if image needs an single update.
SLint _internalFormat
Internal OpenGL format.
void texType(SLTextureType bt)
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)
std::mutex _mutex
Mutex to protect parallel access (used in ray tracing)
void calc3DGradients(SLint sampleRadius, const function< void(int)> &onUpdateProgress=nullptr)
void deleteDataGpu()
Deletes the OpenGL texture objects and releases the memory on the GPU.
SLbool _compressedTexture
True for compressed texture format on GPU.
SLstring magnificationFilterName()
SLuint _bytesInFile
NO. of bytes in file.
SLint _mag_filter
Magnification filter.
SLstring filterString(SLint glFilter)
Returns OpenGL texture filter as string.
void smooth3DGradients(SLint smoothRadius, function< void(int)> onUpdateProgress=nullptr)
static SLuint totalNumBytesOnGPU
Total NO. of bytes used for textures on GPU.
void bindActive(SLuint texUnit=0)
SLbool _autoCalcTM3D
Flag if texture matrix should be calculated from AABB for 3D mapping.
SLGLVertexArray _vaoSprite
Vertex array object for sprite rendering.
void drawSprite(SLbool doUpdate, SLfloat x, SLfloat y, SLfloat w, SLfloat h)
Draws the texture as 2D sprite with OpenGL buffers.
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.
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.
const SLstring & name() const