MaterialX 1.39.1
Loading...
Searching...
No Matches
GLFramebuffer.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_GLFRAMEBUFFER_H
7#define MATERIALX_GLFRAMEBUFFER_H
8
11
13
15
16MATERIALX_NAMESPACE_BEGIN
17
18class GLFramebuffer;
19
21using GLFramebufferPtr = std::shared_ptr<GLFramebuffer>;
22
25class MX_RENDERGLSL_API GLFramebuffer
26{
27 public:
29 static GLFramebufferPtr create(unsigned int width, unsigned int height, unsigned int channelCount, Image::BaseType baseType);
30
32 virtual ~GLFramebuffer();
33
35 unsigned int getWidth() const
36 {
37 return _width;
38 }
39
41 unsigned int getHeight() const
42 {
43 return _height;
44 }
45
48 void setEncodeSrgb(bool encode)
49 {
50 _encodeSrgb = encode;
51 }
52
55 {
56 return _encodeSrgb;
57 }
58
60 void bind();
61
63 void unbind();
64
66 unsigned int getColorTexture() const
67 {
68 return _colorTexture;
69 }
70
72 unsigned int getDepthTexture() const
73 {
74 return _depthTexture;
75 }
76
81
83 void blit();
84
85 protected:
86 GLFramebuffer(unsigned int width, unsigned int height, unsigned int channelCount, Image::BaseType baseType);
87
88 protected:
89 unsigned int _width;
90 unsigned int _height;
91 unsigned int _channelCount;
92 Image::BaseType _baseType;
93 bool _encodeSrgb;
94
95 unsigned int _framebuffer;
96 unsigned int _colorTexture;
97 unsigned int _depthTexture;
98};
99
100MATERIALX_NAMESPACE_END
101
102#endif
std::shared_ptr< GLFramebuffer > GLFramebufferPtr
Shared pointer to a GLFramebuffer.
Definition: GLFramebuffer.h:21
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:23
Image handler interfaces.
Macros for declaring imported and exported symbols.
Wrapper for an OpenGL framebuffer.
Definition: GLFramebuffer.h:26
virtual ~GLFramebuffer()
Destructor.
unsigned int getHeight() const
Return the height of the framebuffer.
Definition: GLFramebuffer.h:41
ImagePtr getColorImage(ImagePtr image=nullptr)
Return the color data of this framebuffer as an image.
void setEncodeSrgb(bool encode)
Set the encode sRGB flag, which controls whether values written to the framebuffer are encoded to the...
Definition: GLFramebuffer.h:48
static GLFramebufferPtr create(unsigned int width, unsigned int height, unsigned int channelCount, Image::BaseType baseType)
Create a new framebuffer.
void bind()
Bind the framebuffer for rendering.
void blit()
Blit our color texture to the back buffer.
unsigned int getColorTexture() const
Return our color texture handle.
Definition: GLFramebuffer.h:66
bool getEncodeSrgb()
Return the encode sRGB flag.
Definition: GLFramebuffer.h:54
unsigned int getWidth() const
Return the width of the framebuffer.
Definition: GLFramebuffer.h:35
unsigned int getDepthTexture() const
Return our depth texture handle.
Definition: GLFramebuffer.h:72
void unbind()
Unbind the frame buffer after rendering.