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