HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_RasterObject.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_RasterObject.h (RE Library, C++)
7  *
8  * COMMENTS:
9  *
10  * Wraps RE_OGLFramebuffer rendering into a nice interface.
11  *
12  */
13 
14 #ifndef __RE_RasterObject__
15 #define __RE_RasterObject__
16 
17 #include "RE_API.h"
18 
19 #include "RE_Texture.h"
20 #include "RE_OGLFramebuffer.h"
22 
23 #include <UT/UT_Function.h>
24 #include <SYS/SYS_Types.h>
25 
26 
27 class TIL_Raster;
28 class RE_OGLFramebuffer;
29 class RE_Render;
30 
31 
34  // ( render, x, y, w, h, data)
35 
37 {
38 public:
39  /// Provide this class with a callback, the width and height you want to
40  /// render into, the height and width you want the texture to be (this
41  /// should be a power of two), and some data to be passed to the callback.
42  RE_RasterObject(RE_RenderCallback callback, int w, int h, int tw, int th,
43  void *data);
44 
45  /// Be very careful before calling this - do you have an OpenGL context
46  /// pushed?
47  ~RE_RasterObject();
48 
49  /// Frees the offscreen buffer associated with this object without
50  /// clearing the other data (texture, raster).
51  void resetBuffer();
52 
53  // build() does not create the texture because a valid OGL Context may
54  // not be present yet. It can safely render into a RasterWindow, as that
55  // pushes a valid context. We can't render to a RasterWindow in the middle
56  // of a redraw as that messes up stacks & contexts. So, the texture
57  // creation is split into 2 parts - build() (called during init) and
58  // getTexture() (called during redraw).
59 
60  /// Render offscreen, calling the render callback.
61  bool build(RE_Render *r);
62 
63  /// Generate and get the OpenGL ID of a texture that contains the contents
64  /// of what was render when build() was called.
65  RE_Texture *getTexture(RE_Render *r);
66 
67  /// If the color scheme changes, we need to re-render everything.
68  void rebuild(RE_Render *r);
69 
70  /// Whether build() has successfully been called.
71  bool isBuilt() const;
72 
73  /// The texture's width. Should be a power of two.
74  int getTexWidth() const;
75 
76  /// The texture's height. Should be a power of two.
77  int getTexHeight() const;
78 
79  /// The width of what you actually want to render.
80  int getWidth() const;
81 
82  /// The height of what you actually want to render.
83  int getHeight() const;
84 
85  /// Force PXL_Raster creation
86  void setForceRaster(bool on) { myForceRaster = on; }
87 
88  TIL_Raster* getRaster() { return myRaster; }
89 
90  /// Renders this object directly using the callback.
91  void renderDirect(RE_Render *r, int x, int y, int w, int h);
92 
93 private: // methods
94  void render(RE_Render *r);
95  bool buildFramebuffer(RE_Render *r);
96 
97 private:
98 
99  RE_RenderCallback myCallback;
100  void *myVoidData;
101  int myTexWidth;
102  int myTexHeight;
103  int myWidth;
104  int myHeight;
105  bool myBuiltFlag;
106  RE_Texture *myTexture;
107  TIL_Raster *myRaster;
108  bool myForceRaster;
110 
111  static bool theRenderToBuffer;
112 };
113 
114 #endif
115 
#define RE_API
Definition: RE_API.h:10
GLint y
Definition: glcorearb.h:103
IFDmantra you can see code vm_image_mplay_direction endcode When SOHO starts a render
Definition: HDK_Image.dox:266
std::function< T > UT_Function
Definition: UT_Function.h:37
GLint GLenum GLint x
Definition: glcorearb.h:409
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
void setForceRaster(bool on)
Force PXL_Raster creation.
UT_Function< void(RE_Render *, int, int, int, int, void *)> RE_RenderCallback
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GLboolean r
Definition: glcorearb.h:1222
TIL_Raster * getRaster()
Definition: format.h:895