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  ~GR_PolySurfaceGL3() override;
27 
28  const char *className() const override { return "GR_PolySurfaceGL3"; }
29 
30  void draw(RE_Render *r,
33  GR_DrawParms dp) override;
34 
35  bool supportsInstances() const override { return true; }
36  bool isConvexed() const override { return (myConvexFlag &&
37  !myMultiMaterialFlag); }
38  bool canFrustumCull() override;
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,
60  bool needs_uv,
61  bool needs_tangent);
62 
63  bool getGeometryHasColor() const;
64 
65  RE_Shader *getMaterialShader(RE_Render *r,
68  int nlights,
69  int prim_vertex,
70  bool has_color_attrib,
71  bool draw_textures,
72  bool needs_displacement,
73  bool multi_material,
74  bool fill_selections,
75  bool has_prim_transforms,
76  bool is_lops,
77  bool need_tangent);
78 
80  RE_Render *r,
81  const GT_DataArrayHandle &a) override;
82  int numMaterials() const override
83  { return myMatGroups.getNumGroups(); }
84 
85 
86 private:
88  const GT_PrimPolygonMesh *pmesh,
89  const GR_UpdateParms &parms,
90  bool needs_normal,
91  bool needs_uv,
92  bool needs_tangent,
93  bool new_geometry,
94  bool &vertex_promote) override;
95 
97  const GT_PrimPolygonMesh *pmesh,
98  const char *cache_name,
99  RE_CacheVersion top_version,
100  const RE_MaterialAtlas &mats,
101  int npoints,
102  bool wireframe,
103  bool vertex_promote,
104  bool convexed) override;
105 
106  void buildPrimTransforms(RE_Render *r,
107  const GR_UpdateParms &p,
108  const GT_DataArrayHandle &ptr);
109  void buildPrimVisibility(RE_Render *r,
110  const GR_UpdateParms &p,
111  const GT_DataArrayHandle &prv);
112 
114  const GT_PrimPolygonMesh *pmesh) override;
115 
116  void drawAsPoints(RE_Render *r,
117  GR_DrawParms dp);
118  void drawAllGeometry(RE_Render *r,
120  GR_DrawParms dp,
121  RE_OverrideList *override_list,
122  bool use_displacement);
123 
124  void drawLayered(RE_Render *r,
125  int mat_index,
126  int nlayers,
127  UT_StringHolder & current_layer,
128  const RE_MaterialPtr &mat,
129  int instances,
131  bool use_displacement);
132 
133  bool getUVSetForLayer(const RE_Material *material,
134  const int layer,
135  UT_UniquePtr<RE_OverrideList>&override_list,
136  bool &has_overrides,
137  int &uv_override_idx,
138  UT_StringHolder *uvset_override = nullptr);
139  void checkForUVs(const UT_StringHolder &uvset_name);
140  void clearCachedDrawData();
141  void buildLopSelection(RE_Render *r,
142  const GR_UpdateParms &p,
143  RE_Geometry &geo,
145  int64 data_id);
146 
147  static RE_ShaderRegistry &getShaders();
148  static RE_ShaderRegistry theShaders;
149  static bool theShadersAreRegistered;
150 
151  bool myPrimSelectionInit;
152  bool myVertexSelectionInit;
153  RE_VertexArray *myPrimSelection;
154  RE_VertexArray *myVertexSelection;
155  RE_VertexArray *myBoneTransforms;
156  void *myLastShader;
157  UT_String myMatGroup;
158  int myNumBoneTransforms;
159  RE_CacheVersion myTopConnectID;
160  unsigned myHasCd : 1,
161  myHasTangents : 1,
162  myLastCd:1,
163  myLastPrimVert:2,
164  myWindingOrder:1,
165  myAutoGenNml:1,
166  myConsolidatedMesh:1,
167  myLastNeedsUV:1;
168 
169  bool myMultiMaterialFlag;
170  bool myLastShowSelections;
171  bool myHasPrimTransform;
172  bool myHasPrimVisibility;
173 
174  UT_IntArray myMaterialMap;
175 };
176 
177 #endif
GT_API const UT_StringHolder selection
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1298
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
virtual void updateBoneTransforms(RE_Render *r, const GT_DataArrayHandle &a)=0
virtual bool canFrustumCull()
Definition: GR_GeoRender.h:105
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
set of parameters sent to GR_Primitive::update()
GR_RenderMode
Definition: GR_Defines.h:46
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
#define GR_API
Definition: GR_API.h:10
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
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:84
GLbitfield flags
Definition: glcorearb.h:1595
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:98
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
const void * ptr(const T *p)
Definition: format.h:3603
int numMaterials() const override
Simple class for a mutli-integer cache tag.
bool isConvexed() const override
GLboolean r
Definition: glcorearb.h:1221
virtual void draw(RE_Render *r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms draw_parms)=0
Normal drawing method. Only issue rendering commands.