MaterialX 1.38.2
GLTextureHandler.h
Go to the documentation of this file.
1//
2// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3// All rights reserved. See LICENSE.txt for license.
4//
5
6#ifndef MATERIALX_GLTEXTUREHANDLER_H
7#define MATERIALX_GLTEXTUREHANDLER_H
8
11
13
15
16namespace MaterialX
17{
18
20using GLTextureHandlerPtr = std::shared_ptr<class GLTextureHandler>;
21
24class MX_RENDERGLSL_API GLTextureHandler : public ImageHandler
25{
26 public:
27 static ImageHandlerPtr create(ImageLoaderPtr imageLoader)
28 {
29 return ImageHandlerPtr(new GLTextureHandler(imageLoader));
30 }
31
35 bool bindImage(ImagePtr image, const ImageSamplingProperties& samplingProperties) override;
36
38 bool unbindImage(ImagePtr image) override;
39
41 bool createRenderResources(ImagePtr image, bool generateMipMaps) override;
42
45 void releaseRenderResources(ImagePtr image = nullptr) override;
46
48 int getBoundTextureLocation(unsigned int resourceId);
49
51 static int mapAddressModeToGL(ImageSamplingProperties::AddressMode addressModeEnum);
52
54 static int mapFilterTypeToGL(ImageSamplingProperties::FilterType filterTypeEnum, bool enableMipmaps);
55
57 static void mapTextureFormatToGL(Image::BaseType baseType, unsigned int channelCount, bool srgb,
58 int& glType, int& glFormat, int& glInternalFormat);
59
60 protected:
61 // Protected constructor
63
64 // Return the first free texture location that can be bound to.
65 int getNextAvailableTextureLocation();
66
67 protected:
68 std::vector<unsigned int> _boundTextureLocations;
69};
70
71} // namespace MaterialX
72
73#endif
std::shared_ptr< class GLTextureHandler > GLTextureHandlerPtr
Shared pointer to an OpenGL texture handler.
Definition: GLTextureHandler.h:20
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:24
Image handler interfaces.
std::shared_ptr< ImageLoader > ImageLoaderPtr
Shared pointer to an ImageLoader.
Definition: ImageHandler.h:36
std::shared_ptr< ImageHandler > ImageHandlerPtr
Shared pointer to an ImageHandler.
Definition: ImageHandler.h:33
Macros for declaring imported and exported symbols.
An OpenGL texture handler class.
Definition: GLTextureHandler.h:25
Base image handler class.
Definition: ImageHandler.h:149
Interface to describe sampling properties for images.
Definition: ImageHandler.h:44
FilterType
Filter type options.
Definition: ImageHandler.h:72
AddressMode
Address mode options.
Definition: ImageHandler.h:56