All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compositor.h
1 //
2 // Copyright 2018 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef HDX_COMPOSITOR_H
25 #define HDX_COMPOSITOR_H
26 
27 #include "pxr/pxr.h"
28 
29 #include "pxr/imaging/hdx/api.h"
30 #include "pxr/imaging/hd/types.h"
31 #include "pxr/imaging/garch/gl.h"
32 #include "pxr/base/gf/vec2i.h"
33 
34 #include <boost/shared_ptr.hpp>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 class HdStGLSLProgram;
39 typedef boost::shared_ptr<class HdStGLSLProgram> HdStGLSLProgramSharedPtr;
40 
48 public:
51  HDX_API
52  HdxCompositor();
53 
55  HDX_API
57 
65  HDX_API
66  void UpdateColor(int width, int height, HdFormat format, void *data);
67 
73  HDX_API
74  void UpdateDepth(int width, int height, uint8_t *data);
75 
78  HDX_API
79  void Draw();
80 
83  HDX_API
84  void Draw(GLuint colorId, GLuint depthId, bool remapDepth);
85 
86 private:
87  // Utility function to create a GL texture.
88  void _CreateTextureResources(GLuint *texture);
89  // Utility function to create a GL program using the compositor source.
90  void _CreateShaderResources(bool useDepthProgram);
91  // Utility function to create buffer resources.
92  void _CreateBufferResources();
93 
94  GLuint _colorTexture;
95  GLuint _depthTexture;
96 
97  HdStGLSLProgramSharedPtr _compositorProgram;
98  GLint _locations[5];
99  GLuint _vertexBuffer;
100  bool _useDepthProgram;
101 };
102 
103 PXR_NAMESPACE_CLOSE_SCOPE
104 
105 #endif // HDX_COMPOSITOR_H
An instance of a glsl program.
Definition: glslProgram.h:44
HDX_API void Draw()
Draw the internal color/depth buffers to the bound framebuffer.
HDX_API HdxCompositor()
Create a new compositor object.
This class is a utility for rendering deep raytracer or aov output (color/depth) to the GL framebuffe...
Definition: compositor.h:47
HDX_API ~HdxCompositor()
Destroy the compositor object, releasing GL resources.
HDX_API void UpdateColor(int width, int height, HdFormat format, void *data)
Upload a new color texture for compositing.
HDX_API void UpdateDepth(int width, int height, uint8_t *data)
Upload a new depth texture for compositing.