HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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
9
/// @file
10
/// OpenGL texture handler
11
12
#include <
MaterialXRenderGlsl/Export.h
>
13
14
#include <
MaterialXRender/ImageHandler.h
>
15
16
MATERIALX_NAMESPACE_BEGIN
17
18
/// Shared pointer to an OpenGL texture handler
19
using
GLTextureHandlerPtr
= std::shared_ptr<class GLTextureHandler>;
20
21
/// @class GLTextureHandler
22
/// An OpenGL texture handler class
23
class
MX_RENDERGLSL_API
GLTextureHandler
:
public
ImageHandler
24
{
25
public
:
26
static
ImageHandlerPtr
create
(
ImageLoaderPtr
imageLoader)
27
{
28
return
ImageHandlerPtr
(
new
GLTextureHandler
(imageLoader));
29
}
30
31
/// Bind an image. This method will bind the texture to an active texture
32
/// unit as defined by the corresponding image description. The method
33
/// will fail if there are not enough available image units to bind to.
34
bool
bindImage
(
ImagePtr
image
,
const
ImageSamplingProperties
& samplingProperties)
override
;
35
36
/// Unbind an image.
37
bool
unbindImage
(
ImagePtr
image
)
override
;
38
39
/// Create rendering resources for the given image.
40
bool
createRenderResources
(
ImagePtr
image
,
bool
generateMipMaps)
override
;
41
42
/// Release rendering resources for the given image, or for all cached images
43
/// if no image pointer is specified.
44
void
releaseRenderResources
(
ImagePtr
image
=
nullptr
)
override
;
45
46
/// Return the bound texture location for a given resource
47
int
getBoundTextureLocation(
unsigned
int
resourceId);
48
49
/// Utility to map an address mode enumeration to an OpenGL address mode
50
static
int
mapAddressModeToGL(
ImageSamplingProperties::AddressMode
addressModeEnum);
51
52
/// Utility to map a filter type enumeration to an OpenGL filter type
53
static
int
mapFilterTypeToGL(
ImageSamplingProperties::FilterType
filterTypeEnum,
bool
enableMipmaps);
54
55
/// Utility to map generic texture properties to OpenGL texture formats.
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
61
GLTextureHandler
(
ImageLoaderPtr
imageLoader);
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
70
MATERIALX_NAMESPACE_END
71
72
#endif
ImageHandler::unbindImage
virtual bool unbindImage(ImagePtr image)
Export.h
MATERIALX_NAMESPACE_BEGIN
#define MATERIALX_NAMESPACE_BEGIN
Definition:
Generated.h:23
image
GLenum GLsizei GLenum GLenum const void * image
Definition:
glew.h:4973
GLTextureHandler::create
static ImageHandlerPtr create(ImageLoaderPtr imageLoader)
Definition:
GLTextureHandler.h:26
ImageSamplingProperties::AddressMode
AddressMode
Definition:
ImageHandler.h:54
GLTextureHandler
Definition:
GLTextureHandler.h:23
ImageHandler.h
Image::BaseType
BaseType
Definition:
Image.h:45
ImageHandler::bindImage
virtual bool bindImage(ImagePtr image, const ImageSamplingProperties &samplingProperties)
ImageHandlerPtr
std::shared_ptr< ImageHandler > ImageHandlerPtr
Shared pointer to an ImageHandler.
Definition:
ImageHandler.h:32
ImageLoaderPtr
std::shared_ptr< ImageLoader > ImageLoaderPtr
Shared pointer to an ImageLoader.
Definition:
ImageHandler.h:35
MX_RENDERGLSL_API
#define MX_RENDERGLSL_API
Definition:
Export.h:18
ImageHandler::releaseRenderResources
virtual void releaseRenderResources(ImagePtr image=nullptr)
ImageSamplingProperties
Definition:
ImageHandler.h:42
ImageHandler::createRenderResources
virtual bool createRenderResources(ImagePtr image, bool generateMipMaps)
Create rendering resources for the given image.
MATERIALX_NAMESPACE_END
#define MATERIALX_NAMESPACE_END
Definition:
Generated.h:24
GLTextureHandler::_boundTextureLocations
std::vector< unsigned int > _boundTextureLocations
Definition:
GLTextureHandler.h:67
ImageSamplingProperties::FilterType
FilterType
Definition:
ImageHandler.h:70
ImagePtr
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition:
Image.h:23
GLTextureHandlerPtr
std::shared_ptr< class GLTextureHandler > GLTextureHandlerPtr
Shared pointer to an OpenGL texture handler.
Definition:
GLTextureHandler.h:19
ImageHandler
Definition:
ImageHandler.h:147
MaterialXRenderGlsl
GLTextureHandler.h
Generated on Sat Mar 25 2023 02:51:52 for HDK by
1.8.6