HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_PickBuffer.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: Render Library (C++)
7  *
8  * COMMENTS:
9  * Holds a frame buffer object that can receive pick information.
10  */
11 
12 #ifndef __RE_PickBuffer_h__
13 #define __RE_PickBuffer_h__
14 
15 #include "RE_API.h"
16 #include "RE_Texture.h"
17 #include "RE_OGLFramebuffer.h"
18 
19 class UT_TokenString;
20 class RE_Geometry;
21 class re_BoxPickData;
22 
24 {
25 public:
26  RE_PickBuffer();
27  ~RE_PickBuffer();
28 
29  bool resize(RE_Render *r, int w, int h);
30  void invalidate();
31  void startRender(RE_Render *r);
32  void drawToBuffer(RE_Render *r,
34  int colorbufnum = 0);
35  void drawToAllBuffers(RE_Render *r);
36  void endRender(RE_Render *r, UT_TokenString *&new_hash);
37 
38  // The picks returned by this method are sequential in pick_dist in that
39  // if a pick_dist of d returns a sequence of n picks, these will also be
40  // the first n picks in the sequence for a pick_dist of d + 1.
41  //
42  // The sample_counts_by_dist parameter is provided to aid in determining
43  // which of the returned picks would also be picks for distances less
44  // than pick_dist. If a nonzero pointer is supplied, it will be set to
45  // point to an array such that the first (*sample_counts_by_dist)[i] of
46  // the returned picks would also be picks for a pick_dist of i, for i
47  // in [0 .. RE_MAX_PICK_DIST]. This array pointer will only be set if
48  // this method returns a nonzero count, and should *NOT* be deleted.
49  int getPicks(RE_Render *r,
50  int x, int y, int pick_dist,
51  RE_VertexArray *&high_array,
52  RE_VertexArray *&low_array,
53  RE_VertexArray *&z_array,
54  const UT_IntArray **sample_counts_by_dist = 0);
55 
56  int getPicks(RE_Render *r,
57  const UT_DimRect &area,
58  uint8 *texture,
59  UT_Vector3iArray &pick_high,
60  UT_Vector3iArray &pick_low);
61  RE_Texture *getZTexture();
62 
63  bool initialized() const;
64  bool checkHash(const UT_TokenString *hash) const;
65 
66  void saveBuffers(RE_Render *r,
67  const char *path,
68  const char *prefix,
69  bool mid_render) const;
70 
71 private:
72  int normalPickFetch(RE_Render *r,
73  const UT_DimRect &area,
74  uint8 *texture,
75  UT_Vector3iArray &pick_high,
76  UT_Vector3iArray &pick_low);
77  int slowPickFetch(RE_Render *r,
78  const UT_DimRect &area,
79  uint8 *texture,
80  UT_Vector3iArray &pick_high,
81  UT_Vector3iArray &pick_low);
82  RE_FBOStatus create(RE_Render *r, int w, int h);
83  void destroy();
84 
86  UT_UniquePtr<RE_Texture> myHighIdTexture;
87  UT_UniquePtr<RE_Texture> myLowIdTexture;
88  UT_UniquePtr<RE_Texture> myZTexture;
89  UT_UniquePtr<RE_Geometry> mySinglePickGeometry;
90  UT_UniquePtr<re_BoxPickData> myBoxPickData;
91  UT_TokenString *myBufferHash;
92  int myBufferVecSize;
93  mutable int mySaveCount;
94 };
95 
96 #endif
#define RE_API
Definition: RE_API.h:10
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:53
GLint y
Definition: glcorearb.h:102
RE_FBOStatus
RE_BufferAttachment
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
unsigned char uint8
Definition: SYS_Types.h:32
GLint GLenum GLint x
Definition: glcorearb.h:408
GLuint texture
Definition: glcorearb.h:414
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLboolean r
Definition: glcorearb.h:1221
GA_API const UT_StringHolder area