AGX Dynamics  2.35.0.1
RenderToImage.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, is copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXOSG_RENDERTOIMAGE_H
18 #define AGXOSG_RENDERTOIMAGE_H
19 
20 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
21 
22 #include <agxOSG/export.h>
23 #include <agxOSG/RenderTarget.h>
24 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
25 
26 namespace agxOSG
27 {
30 
35  {
36  public:
37 
46  RenderToImage(agx::UInt width, agx::UInt height, BufferComponent bufferComponent = COLOR_BUFFER, agx::UInt multiSamples = 8, RenderTarget::TextureFormat textureFormat = RenderTarget::RGBA);
47 
51  osg::Image* getImage();
52 
59  bool extractImageData(unsigned char* img, int size);
60 
62  unsigned char* getImageData();
63 
70  bool saveImage(const agx::String& filename);
71 
72  protected:
73  virtual ~RenderToImage();
74 
75  private:
76  osg::ref_ptr<osg::Image> m_renderImage;
77  };
78 }
79 
80 #endif /* AGXOSG_RENDERTOTEXTURE_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXOSG_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Render target is used for rendering camera content to a buffer, either a DEPTH or COLOR target.
Definition: RenderTarget.h:41
TextureFormat
Specifies target texture format.
Definition: RenderTarget.h:54
BufferComponent
Specifies which type of buffer to render.
Definition: RenderTarget.h:47
This class will transfer the camera buffer to the CPU for local storage/processing.
Definition: RenderToImage.h:35
bool extractImageData(unsigned char *img, int size)
Will try to extract the image data as a raw data array of length size.
RenderToImage(agx::UInt width, agx::UInt height, BufferComponent bufferComponent=COLOR_BUFFER, agx::UInt multiSamples=8, RenderTarget::TextureFormat textureFormat=RenderTarget::RGBA)
Constructor of a RenderTarget that can render the camera buffer to an image.
bool saveImage(const agx::String &filename)
Save the current image to disk given a filename Note: Only works for COLOR_BUFFER not DEPTH_BUFFER.
osg::Image * getImage()
unsigned char * getImageData()
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
uint32_t UInt
Definition: Integer.h:34