HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_PolySurfaceGL3.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: GR_PolySurfaceGL3.h ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Base class for polygon meshes and soups for the GL3 renderer
10  */
11 #ifndef GR_PolySurfaceGL3_h
12 #define GR_PolySurfaceGL3_h
13 
14 class RE_Render;
15 class RE_Geometry;
16 
17 #include "GR_PolySurface.h"
18 #include <RE/RE_ShaderHandle.h>
19 #include <RE/RE_ShaderRegistry.h>
20 
22 {
23 public:
25  bool needs_convexing = false);
26  virtual ~GR_PolySurfaceGL3();
27 
28  virtual const char *className() const { return "GR_PolySurfaceGL3"; }
29 
30  virtual void draw(RE_Render *r,
33  GR_DrawParms dp);
34 
35  virtual bool supportsInstances() const { return true; }
36  virtual bool isConvexed() const { return (myConvexFlag &&
37  !myMultiMaterialFlag); }
38  virtual bool canFrustumCull();
39 
40 protected:
41  void drawBeauty(RE_Render *r,
44  GR_DrawParms dp);
45 
46  void drawUtility(RE_Render *r,
49  GR_DrawParms dp);
50 
51  void drawHiddenLine(RE_Render *r,
54  GR_DrawParms dp);
55 
56  int buildSurfaceAttributes(RE_Render *r,
57  const GT_Primitive *prim,
58  const GR_UpdateParms &parms,
59  bool needs_normal, bool needs_uv);
60 
61  bool getGeometryHasColor() const;
62 
63  RE_Shader *getMaterialShader(RE_Render *r,
66  int nlights,
67  int prim_vertex,
68  bool has_color_attrib,
69  bool draw_textures,
70  bool needs_displacement,
71  bool multi_material,
72  bool fill_selections,
73  bool has_prim_transforms,
74  bool is_lops);
75 
76  virtual void updateBoneTransforms(RE_Render *r,const GT_DataArrayHandle &a);
77  virtual int numMaterials() const { return myMatGroups.getNumGroups(); }
78 
79 
80 private:
81  virtual int buildVertexAttributes(RE_Render *r,
82  const GT_PrimPolygonMesh *pmesh,
83  const GR_UpdateParms &parms,
84  bool needs_normal, bool needs_uv,
85  bool new_geometry,
86  bool &vertex_promote);
87 
88  virtual void buildConnectivity(RE_Render *r,
89  const GT_PrimPolygonMesh *pmesh,
90  const char *cache_name,
91  RE_CacheVersion top_version,
92  const RE_MaterialAtlas &mats,
93  int npoints,
94  bool wireframe,
95  bool vertex_promote,
96  bool convexed);
97 
98  void buildPrimTransforms(RE_Render *r,
99  const GR_UpdateParms &p,
100  const GT_DataArrayHandle &ptr);
101  void buildPrimVisibility(RE_Render *r,
102  const GR_UpdateParms &p,
103  const GT_DataArrayHandle &prv);
104 
106 
107  void drawAsPoints(RE_Render *r,
108  GR_DrawParms dp);
109  void drawAllGeometry(RE_Render *r,
111  GR_DrawParms dp,
112  RE_OverrideList *override_list,
113  bool use_displacement);
114 
115  void drawLayered(RE_Render *r,
116  int mat_index,
117  int nlayers,
118  UT_StringHolder & current_layer,
119  const RE_MaterialPtr &mat,
120  int instances,
122  bool use_displacement);
123 
124  bool getUVSetForLayer(const RE_Material *material,
125  const int layer,
126  UT_UniquePtr<RE_OverrideList>&override_list,
127  bool &has_overrides,
128  int &uv_override_idx,
129  UT_StringHolder *uvset_override = nullptr);
130  void checkForUVs(const UT_StringHolder &uvset_name);
131  void clearCachedDrawData();
132 
133  static RE_ShaderRegistry &getShaders();
134  static RE_ShaderRegistry theShaders;
135  static bool theShadersAreRegistered;
136 
137  bool myPrimSelectionInit;
138  bool myVertexSelectionInit;
139  RE_VertexArray *myPrimSelection;
140  RE_VertexArray *myVertexSelection;
141  RE_VertexArray *myBoneTransforms;
142  void *myLastShader;
143  UT_String myMatGroup;
144  int myNumBoneTransforms;
145  RE_CacheVersion myTopConnectID;
146  unsigned myHasCd : 1,
147  myLastCd:1,
148  myLastPrimVert:2,
149  myWindingOrder:1,
150  myAutoGenNml:1,
151  myLastNeedsUV:1;
152 
153  bool myMultiMaterialFlag;
154  bool myLastShowSelections;
155  bool myHasPrimTransform;
156  bool myHasPrimVisibility;
157 
158  UT_IntArray myMaterialMap;
159 };
160 
161 #endif
virtual int buildVertexAttributes(RE_Render *r, const GT_PrimPolygonMesh *pmesh, const GR_UpdateParms &p, bool needs_normal, bool needs_uv, bool new_geo, bool &vertex_promote)=0
virtual int numMaterials() const
A mesh of polygons.
GLenum mode
Definition: glew.h:2163
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:53
GT_API const UT_StringHolder cache_name
virtual const char * className() const
virtual void updateBoneTransforms(RE_Render *r, const GT_DataArrayHandle &a)=0
virtual bool isConvexed() const
virtual bool canFrustumCull()
Definition: GR_GeoRender.h:105
set of parameters sent to GR_Primitive::update()
GR_RenderMode
Definition: GR_Defines.h:44
#define GR_API
Definition: GR_API.h:10
GR_RenderFlags
Definition: GR_Defines.h:80
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual GT_PrimitiveHandle convexSurface(const GT_PrimPolygonMesh *pmesh)=0
GLfloat GLfloat p
Definition: glew.h:16321
virtual void buildConnectivity(RE_Render *r, const GT_PrimPolygonMesh *pmesh, const char *cache_name, RE_CacheVersion geo_version, const RE_MaterialAtlas &mats, int npoints, bool wireframe, bool vertex_promote, bool convexed)=0
const void * ptr(const T *p)
Definition: format.h:3292
virtual bool supportsInstances() const
By default, no instanced drawing support.
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:47
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
GLint GLboolean GLint layer
Definition: glew.h:3601
Simple class for a mutli-integer cache tag.
virtual void draw(RE_Render *r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms draw_parms)=0
Normal drawing method. Only issue rendering commands.