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 
75  virtual void updateBoneTransforms(RE_Render *r,const GT_DataArrayHandle &a);
76  virtual int numMaterials() const { return myMatGroups.getNumGroups(); }
77 
78 
79 private:
80  virtual int buildVertexAttributes(RE_Render *r,
81  const GT_PrimPolygonMesh *pmesh,
82  const GR_UpdateParms &parms,
83  bool needs_normal, bool needs_uv,
84  bool new_geometry,
85  bool &vertex_promote);
86 
87  virtual void buildConnectivity(RE_Render *r,
88  const GT_PrimPolygonMesh *pmesh,
89  const char *cache_name,
90  RE_CacheVersion top_version,
91  const RE_MaterialAtlas &mats,
92  int npoints,
93  bool wireframe,
94  bool vertex_promote,
95  bool convexed);
96 
97  void buildPrimTransforms(RE_Render *r,
98  const GR_UpdateParms &p,
99  const GT_DataArrayHandle &ptr);
100  void buildPrimVisibility(RE_Render *r,
101  const GR_UpdateParms &p,
102  const GT_DataArrayHandle &prv);
103 
105 
106  void drawAsPoints(RE_Render *r,
107  GR_DrawParms dp);
108  void drawAllGeometry(RE_Render *r,
110  GR_DrawParms dp,
111  RE_OverrideList *override_list,
112  bool use_displacement);
113 
114  void drawLayered(RE_Render *r,
115  int mat_index,
116  int nlayers,
117  UT_StringHolder & current_layer,
118  const RE_MaterialPtr &mat,
119  int instances,
121  bool use_displacement);
122 
123  bool getUVSetForLayer(const RE_Material *material,
124  const int layer,
125  UT_UniquePtr<RE_OverrideList>&override_list,
126  bool &has_overrides,
127  int &uv_override_idx,
128  UT_StringHolder *uvset_override = nullptr);
129  void checkForUVs(const UT_StringHolder &uvset_name);
130  void clearCachedDrawData();
131 
132  static RE_ShaderRegistry &getShaders();
133  static RE_ShaderRegistry theShaders;
134  static bool theShadersAreRegistered;
135 
136  bool myPrimSelectionInit;
137  bool myVertexSelectionInit;
138  RE_VertexArray *myPrimSelection;
139  RE_VertexArray *myVertexSelection;
140  RE_VertexArray *myBoneTransforms;
141  void *myLastShader;
142  UT_String myMatGroup;
143  int myNumBoneTransforms;
144  RE_CacheVersion myTopConnectID;
145  unsigned myHasCd : 1,
146  myLastCd:1,
147  myLastPrimVert:2,
148  myLastNeedsUV:1;
149 
150  bool myMultiMaterialFlag;
151  bool myLastShowSelections;
152  bool myHasPrimTransform;
153  bool myHasPrimVisibility;
154 
155  UT_IntArray myMaterialMap;
156 };
157 
158 #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
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1298
A mesh of polygons.
png_voidp ptr
Definition: png.h:2145
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:1221
GLbitfield flags
Definition: glcorearb.h:1595
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:79
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
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
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
Simple class for a mutli-integer cache tag.
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.