MaterialX 1.39.1
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
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
bool unbindImage(ImagePtr image) override
Unbind an image.
int getBoundTextureLocation(unsigned int resourceId)
Return the bound texture location for a given resource.
bool bindImage(ImagePtr image, const ImageSamplingProperties &samplingProperties) override
Bind an image.
bool createRenderResources(ImagePtr image, bool generateMipMaps, bool useAsRenderTarget=false) override
Create rendering resources for the given image.
static int mapAddressModeToGL(ImageSamplingProperties::AddressMode addressModeEnum)
Utility to map an address mode enumeration to an OpenGL address mode.
static void mapTextureFormatToGL(Image::BaseType baseType, unsigned int channelCount, bool srgb, int &glType, int &glFormat, int &glInternalFormat)
Utility to map generic texture properties to OpenGL texture formats.
static int mapFilterTypeToGL(ImageSamplingProperties::FilterType filterTypeEnum, bool enableMipmaps)
Utility to map a filter type enumeration to an OpenGL filter type.
void releaseRenderResources(ImagePtr image=nullptr) override
Release rendering resources for the given image, or for all cached images if no image pointer is spec...
Base image handler class.
Definition: ImageHandler.h:164
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