MaterialX 1.38.10
Loading...
Searching...
No Matches
GLTextureHandler.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_GLTEXTUREHANDLER_H
7#define MATERIALX_GLTEXTUREHANDLER_H
8
11
13
15
16MATERIALX_NAMESPACE_BEGIN
17
19using GLTextureHandlerPtr = std::shared_ptr<class GLTextureHandler>;
20
23class MX_RENDERGLSL_API GLTextureHandler : public ImageHandler
24{
25 public:
26 static ImageHandlerPtr create(ImageLoaderPtr imageLoader)
27 {
28 return ImageHandlerPtr(new GLTextureHandler(imageLoader));
29 }
30
34 bool bindImage(ImagePtr image, const ImageSamplingProperties& samplingProperties) override;
35
37 bool unbindImage(ImagePtr image) override;
38
40 bool createRenderResources(ImagePtr image, bool generateMipMaps, bool useAsRenderTarget = false) override;
41
44 void releaseRenderResources(ImagePtr image = nullptr) override;
45
47 int getBoundTextureLocation(unsigned int resourceId);
48
50 static int mapAddressModeToGL(ImageSamplingProperties::AddressMode addressModeEnum);
51
53 static int mapFilterTypeToGL(ImageSamplingProperties::FilterType filterTypeEnum, bool enableMipmaps);
54
56 static void mapTextureFormatToGL(Image::BaseType baseType, unsigned int channelCount, bool srgb,
57 int& glType, int& glFormat, int& glInternalFormat);
58
59 protected:
60 // Protected constructor
62
63 // Return the first free texture location that can be bound to.
64 int getNextAvailableTextureLocation();
65
66 protected:
67 std::vector<unsigned int> _boundTextureLocations;
68};
69
70MATERIALX_NAMESPACE_END
71
72#endif
std::shared_ptr< class GLTextureHandler > GLTextureHandlerPtr
Shared pointer to an OpenGL texture handler.
Definition: GLTextureHandler.h:19
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:23
Image handler interfaces.
std::shared_ptr< ImageLoader > ImageLoaderPtr
Shared pointer to an ImageLoader.
Definition: ImageHandler.h:35
std::shared_ptr< ImageHandler > ImageHandlerPtr
Shared pointer to an ImageHandler.
Definition: ImageHandler.h:32
Macros for declaring imported and exported symbols.
An OpenGL texture handler class.
Definition: GLTextureHandler.h:24
Base image handler class.
Definition: ImageHandler.h:164
virtual bool createRenderResources(ImagePtr image, bool generateMipMaps, bool useAsRenderTarget=false)
Create rendering resources for the given image.
Definition: ImageHandler.cpp:168
virtual bool bindImage(ImagePtr image, const ImageSamplingProperties &samplingProperties)
Bind an image for rendering.
Definition: ImageHandler.cpp:150
virtual void releaseRenderResources(ImagePtr image=nullptr)
Release rendering resources for the given image, or for all cached images if no image pointer is spec...
Definition: ImageHandler.cpp:173
virtual bool unbindImage(ImagePtr image)
Unbind an image, making it no longer active for rendering.
Definition: ImageHandler.cpp:155
Interface to describe sampling properties for images.
Definition: ImageHandler.h:43
FilterType
Filter type options.
Definition: ImageHandler.h:73
AddressMode
Address mode options.
Definition: ImageHandler.h:57