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 class RE_ShaderAtlas;
17 
18 #include "GR_PolySurface.h"
19 #include <RE/RE_ShaderHandle.h>
20 #include <RE/RE_ShaderRegistry.h>
21 
22 #define USE_SHADER_ATLAS 1
23 
25 {
26 public:
28  bool needs_convexing = false);
29  ~GR_PolySurfaceGL3() override;
30 
31  const char *className() const override { return "GR_PolySurfaceGL3"; }
32 
33  void draw(RE_RenderContext r,
36  GR_DrawParms dp) override;
37 
38  bool supportsInstances() const override { return true; }
39  bool isConvexed() const override { return (myConvexFlag &&
40  !myMultiMaterialFlag); }
41  bool canFrustumCull() override;
42  bool getWindingOrder() const { return myWindingOrder; }
43 protected:
44  void drawBeauty(RE_Render *r,
47  GR_DrawParms dp);
48 
49  void drawUtility(RE_Render *r,
52  GR_DrawParms dp);
53 
54  void drawHiddenLine(RE_Render *r,
57  GR_DrawParms dp);
58 
59  int buildSurfaceAttributes(RE_Render *r,
60  const GT_Primitive *prim,
61  const GR_UpdateParms &parms,
62  bool needs_normal,
63  bool needs_uv,
64  bool needs_tangent);
65 
66  bool getGeometryHasColor() const;
67 
68  RE_Shader *getMaterialShader(RE_Render *r,
71  int nlights,
72  int prim_vertex,
73  bool has_color_attrib,
74  bool draw_textures,
75  bool needs_displacement,
76  bool multi_material,
77  bool fill_selections,
78  bool has_prim_transforms,
79  bool is_lops,
80  bool need_tangent);
81 
83  RE_Render *r,
84  const GT_DataArrayHandle &a) override;
85 
87  RE_Render *r,
88  const GT_DataArrayHandle &weights_attr) override;
89 
90  int numMaterials() const override
91  { return myMatGroups.getNumGroups(); }
92 
93 
94 private:
96  const GT_PrimPolygonMesh *pmesh,
97  const GR_UpdateParms &parms,
98  bool needs_normal,
99  bool needs_uv,
100  bool needs_tangent,
101  bool new_geometry,
102  bool &vertex_promote) override;
103 
105  const GT_PrimPolygonMesh *pmesh,
106  const char *cache_name,
107  RE_CacheVersion top_version,
108  const RE_MaterialAtlas &mats,
109  int npoints,
110  bool wireframe,
111  bool vertex_promote,
112  bool convexed) override;
113 
114  void buildPrimTransforms(RE_Render *r,
115  const GR_UpdateParms &p,
116  const GT_DataArrayHandle &ptr);
117  void buildPrimVisibility(RE_Render *r,
118  const GR_UpdateParms &p,
119  const GT_DataArrayHandle &prv);
120 
122  const GT_PrimPolygonMesh *pmesh) override;
123 
124  void drawAsPoints(RE_Render *r,
125  GR_DrawParms dp);
126  void drawAllGeometry(RE_Render *r,
128  GR_DrawParms dp,
129  RE_OverrideList *override_list,
130  bool use_displacement);
131 
132  void drawLayered(RE_Render *r,
133  int mat_index,
134  int nlayers,
135  UT_StringHolder & current_layer,
136  const RE_MaterialPtr &mat,
137  int instances,
139  bool use_displacement);
140 
141  bool getUVSetForLayer(const RE_Material *material,
142  const int layer,
143  UT_UniquePtr<RE_OverrideList>&override_list,
144  bool &has_overrides,
145  int &uv_override_idx,
146  UT_StringHolder *uvset_override = nullptr);
147  void checkForUVs(const UT_StringHolder &uvset_name);
148  void clearCachedDrawData();
149  void buildLopSelection(RE_Render *r,
150  const GR_UpdateParms &p,
151  RE_Geometry &geo,
153  int64 data_id);
154 
155 #ifdef USE_SHADER_ATLAS
156  static void initShaders();
157 #else
158  static void initShaders();
159  static RE_ShaderRegistry theShaders;
160 #endif
161  static bool theShadersAreRegistered;
162 
163  bool myPrimSelectionInit;
164  bool myVertexSelectionInit;
165  RE_VertexArray *myPrimSelection;
166  RE_VertexArray *myVertexSelection;
167  RE_VertexArray *myBoneTransforms;
168  RE_VertexArray *myBlendWeights;
169  void *myLastShader;
170  UT_String myMatGroup;
171  int myNumBoneTransforms;
172  int myNumBlendTargetShapes;
173  RE_CacheVersion myTopConnectID;
174  unsigned myHasCd : 1,
175  myHasTangents : 1,
176  myLastCd:1,
177  myLastPrimVert:2,
178  myWindingOrder:1,
179  myAutoGenNml:1,
180  myConsolidatedMesh:1,
181  myLastNeedsUV:1;
182 
183  bool myMultiMaterialFlag;
184  bool myLastShowSelections;
185  bool myHasPrimTransform;
186  bool myHasPrimVisibility;
187 
188  UT_IntArray myMaterialMap;
189 };
190 
191 #endif
bool getWindingOrder() const
GT_API const UT_StringHolder selection
GLbitfield flags
Definition: glcorearb.h:1596
virtual void draw(RE_RenderContext r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms draw_parms)=0
Normal drawing method. Only issue rendering commands.
A mesh of polygons.
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
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
Temporary container for either a RV_Render and an RE_Render.
virtual bool canFrustumCull()
Definition: GR_GeoRender.h:139
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
set of parameters sent to GR_Primitive::update()
GR_RenderMode
Definition: GR_Defines.h:48
#define GR_API
Definition: GR_API.h:10
long long int64
Definition: SYS_Types.h:116
virtual bool updateBoneTransforms(RE_Render *r, const GT_DataArrayHandle &a)=0
virtual int buildVertexAttributes(RE_Render *r, const GT_PrimPolygonMesh *pmesh, const GR_UpdateParms &p, bool needs_normal, bool needs_uv, bool needs_tangent, bool new_geo, bool &vertex_promote)=0
const char * className() const override
GR_RenderFlags
Definition: GR_Defines.h:86
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual GT_PrimitiveHandle convexSurface(const GT_PrimPolygonMesh *pmesh)=0
GLenum mode
Definition: glcorearb.h:99
bool supportsInstances() const override
By default, no instanced drawing support.
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
int numMaterials() const override
auto ptr(T p) -> const void *
Definition: format.h:2448
virtual bool updateBlendShapeWeights(RE_Render *r, const GT_DataArrayHandle &weights_attr)=0
Simple class for a mutli-integer cache tag.
GLboolean r
Definition: glcorearb.h:1222
bool isConvexed() const override