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 <SYS/SYS_Types.h>
24 
25 #include <functional>
26 
27 
28 class TIL_Raster;
29 class RE_OGLFramebuffer;
30 class RE_Render;
31 
32 
34  = std::function<void (RE_Render *, int, int, int, int, void *)>;
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 
50  /// Frees the offscreen buffer associated with this object without
51  /// clearing the other data (texture, raster).
52  void resetBuffer();
53 
54  // build() does not create the texture because a valid OGL Context may
55  // not be present yet. It can safely render into a RasterWindow, as that
56  // pushes a valid context. We can't render to a RasterWindow in the middle
57  // of a redraw as that messes up stacks & contexts. So, the texture
58  // creation is split into 2 parts - build() (called during init) and
59  // getTexture() (called during redraw).
60 
61  /// Render offscreen, calling the render callback.
62  bool build(RE_Render *r);
63 
64  /// Generate and get the OpenGL ID of a texture that contains the contents
65  /// of what was render when build() was called.
66  RE_Texture *getTexture(RE_Render *r);
67 
68  /// If the color scheme changes, we need to re-render everything.
69  void rebuild(RE_Render *r);
70 
71  /// Whether build() has successfully been called.
72  bool isBuilt() const;
73 
74  /// The texture's width. Should be a power of two.
75  int getTexWidth() const;
76 
77  /// The texture's height. Should be a power of two.
78  int getTexHeight() const;
79 
80  /// The width of what you actually want to render.
81  int getWidth() const;
82 
83  /// The height of what you actually want to render.
84  int getHeight() const;
85 
86  /// Force PXL_Raster creation
87  void setForceRaster(bool on) { myForceRaster = on; }
88 
89  TIL_Raster* getRaster() { return myRaster; }
90 
91  /// Renders this object directly using the callback.
92  void renderDirect(RE_Render *r, int x, int y, int w, int h);
93 
94 private: // methods
95  void render(RE_Render *r);
96  bool buildFramebuffer(RE_Render *r);
97 
98 private:
99 
100  RE_RenderCallback myCallback;
101  void *myVoidData;
102  int myTexWidth;
103  int myTexHeight;
104  int myWidth;
105  int myHeight;
106  bool myBuiltFlag;
107  RE_Texture *myTexture;
108  TIL_Raster *myRaster;
109  bool myForceRaster;
111 
112  static bool theRenderToBuffer;
113 };
114 
115 #endif
116 
#define RE_API
Definition: RE_API.h:10
IFDmantra you can see code vm_image_mplay_direction endcode When SOHO starts a render
Definition: HDK_Image.dox:266
GLint GLenum GLint x
Definition: glcorearb.h:409
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
void setForceRaster(bool on)
Force PXL_Raster creation.
std::function< void(RE_Render *, int, int, int, int, void *)> RE_RenderCallback
GLboolean r
Definition: glcorearb.h:1222
GLint y
Definition: glcorearb.h:103
TIL_Raster * getRaster()
Definition: format.h:895