Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoOffscreenRenderer.h
1 #ifndef COIN_SOOFFSCREENRENDERER_H
2 #define COIN_SOOFFSCREENRENDERER_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/SbViewportRegion.h>
37 #include <Inventor/SbColor.h>
38 #include <Inventor/lists/SbList.h>
39 #include <Inventor/lists/SbPList.h>
40 #include <Inventor/SbString.h>
41 #include <Inventor/SbName.h>
42 
43 #include <cstdio>
44 
45 class SoBase;
46 class SoGLRenderAction;
47 class SoNode;
48 class SoPath;
49 
50 // This shouldn't strictly be necessary, but the OSF1/cxx compiler
51 // complains if this is left out, while using the "friend class
52 // SoExtSelectionP" statement in the class definition.
53 class SoOffscreenRendererP;
54 
55 
56 class COIN_DLL_API SoOffscreenRenderer {
57 public:
58  enum Components {
59  LUMINANCE = 1,
60  LUMINANCE_TRANSPARENCY = 2,
61  RGB = 3,
62  RGB_TRANSPARENCY = 4
63  };
64 
65  SoOffscreenRenderer(const SbViewportRegion & viewportregion);
68 
69  static float getScreenPixelsPerInch(void);
70  static SbVec2s getMaximumResolution(void);
71  void setComponents(const Components components);
72  Components getComponents(void) const;
73  void setViewportRegion(const SbViewportRegion & region);
74  const SbViewportRegion & getViewportRegion(void) const;
75  void setBackgroundColor(const SbColor & color);
76  const SbColor & getBackgroundColor(void) const;
77  void setGLRenderAction(SoGLRenderAction * action);
78  SoGLRenderAction * getGLRenderAction(void) const;
79  SbBool render(SoNode * scene);
80  SbBool render(SoPath * scene);
81  unsigned char * getBuffer(void) const;
82  const void * const & getDC(void) const;
83 
84  SbBool writeToRGB(FILE * fp) const;
85  SbBool writeToPostScript(FILE * fp) const;
86  SbBool writeToPostScript(FILE * fp, const SbVec2f & printsize) const;
87 
88  SbBool writeToRGB(const char * filename) const;
89  SbBool writeToPostScript(const char * filename) const;
90  SbBool writeToPostScript(const char * filename, const SbVec2f & printsize) const;
91 
92  SbBool isWriteSupported(const SbName & filetypeextension) const;
93  int getNumWriteFiletypes(void) const;
94  void getWriteFiletypeInfo(const int idx,
95  SbPList & extlist,
96  SbString & fullname,
97  SbString & description);
98  SbBool writeToFile(const SbString & filename, const SbName & filetypeextension) const;
99 
100  void setPbufferEnable(SbBool enable);
101  SbBool getPbufferEnable(void) const;
102 
103 private:
104  friend class SoOffscreenRendererP;
105  class SoOffscreenRendererP * pimpl;
106 };
107 
108 #endif // !COIN_SOOFFSCREENRENDERER_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:49
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:45
The SoOffscreenRenderer class is used for rendering scenes in offscreen buffers.
Definition: SoOffscreenRenderer.h:56
The SbColor class contains the red, green and blue components which make up a color value...
Definition: SbColor.h:39
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
The SbPList class is a container class for void pointers.
Definition: lists/SbPList.h:40
Components
Definition: SoOffscreenRenderer.h:58
The SoPath class is a container class for traversal path descriptions.
Definition: SoPath.h:52
The SbViewportRegion class is a viewport within a full window.
Definition: SbViewportRegion.h:40
The SbString class is a string class with convenience functions for string operations.
Definition: SbString.h:52
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition: SbVec2s.h:51
The SbName class stores strings by reference.
Definition: SbName.h:40
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition: SoGLRenderAction.h:50