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 
20 #include "RE_OGLFramebuffer.h"
21 #include "RE_Texture.h"
22 
23 #include <UT/UT_Function.h>
24 #include <UT/UT_NonCopyable.h>
25 #include <SYS/SYS_Types.h>
26 
27 
28 class TIL_Raster;
29 class RE_OGLFramebuffer;
30 class RE_Render;
31 
32 
35  // ( render, x, y, w, h, data)
36 
38 {
39 public:
40  /// Provide this class with a callback, the width and height you want to
41  /// render into, the height and width you want the texture to be (this
42  /// should be a power of two), and some data to be passed to the callback.
43  RE_RasterObject(RE_RenderCallback callback, int w, int h, int tw, int th,
44  void *data);
45 
46  /// Be very careful before calling this - do you have an OpenGL context
47  /// pushed?
48  ~RE_RasterObject();
49 
51 
52  /// Frees the offscreen buffer associated with this object without
53  /// clearing the other data (texture, raster).
54  void resetBuffer();
55 
56  // build() does not create the texture because a valid OGL Context may
57  // not be present yet. It can safely render into a RasterWindow, as that
58  // pushes a valid context. We can't render to a RasterWindow in the middle
59  // of a redraw as that messes up stacks & contexts. So, the texture
60  // creation is split into 2 parts - build() (called during init) and
61  // getTexture() (called during redraw).
62 
63  /// Render offscreen, calling the render callback.
64  bool build(RE_Render *r);
65 
66  /// Generate and get the OpenGL ID of a texture that contains the contents
67  /// of what was render when build() was called.
68  RE_Texture *getTexture(RE_Render *r);
69 
70  /// If the color scheme changes, we need to re-render everything.
71  void rebuild(RE_Render *r);
72 
73  /// Whether build() has successfully been called.
74  bool isBuilt() const;
75 
76  /// The texture's width. Should be a power of two.
77  int getTexWidth() const;
78 
79  /// The texture's height. Should be a power of two.
80  int getTexHeight() const;
81 
82  /// The width of what you actually want to render.
83  int getWidth() const;
84 
85  /// The height of what you actually want to render.
86  int getHeight() const;
87 
88  /// Force PXL_Raster creation
89  void setForceRaster(bool on) { myForceRaster = on; }
90 
91  TIL_Raster* getRaster() { return myRaster; }
92 
93  /// Renders this object directly using the callback.
94  void renderDirect(RE_Render *r, int x, int y, int w, int h);
95 
96 private: // methods
97  void render(RE_Render *r);
98  bool buildFramebuffer(RE_Render *r);
99 
100 private:
101 
102  RE_RenderCallback myCallback;
103  void *myVoidData;
104  int myTexWidth;
105  int myTexHeight;
106  int myWidth;
107  int myHeight;
108  bool myBuiltFlag;
109  RE_Texture *myTexture;
110  TIL_Raster *myRaster;
111  bool myForceRaster;
113 
114  static bool theRenderToBuffer;
115 };
116 
117 #endif
118 
#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
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
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:1821