Basic Shape Creation and Rendering  2.0
Tools to create and render common shapes like blocks, cylinders, cones, and spheres
BasicShapeRenderer.h
Go to the documentation of this file.
1 
6 #ifndef BASICSHAPERENDERER_H
7 #define BASICSHAPERENDERER_H
8 
9 #include <string>
10 
11 #include "BasicShape.h"
12 #include "ShaderIF.h"
13 
14 typedef void (*FacePrepFcn)(void* caller, int faceIndex);
15 
17 {
18 public:
24  BasicShapeRenderer(ShaderIF* sIF, BasicShape* shapeIn);
25 
27  virtual ~BasicShapeRenderer();
28 
32  void getMCBoundingBox(double* xyzLimits) const;
33 
43  void renderShape(FacePrepFcn prepareForFace = nullptr, void* caller = nullptr);
44 
56  static void setGLSLVariableNames(
57  const std::string& mcPositionNameIn, // Must be a GLSL vec3
58  const std::string& mcNormalNameIn, // Must be a GLSL vec3
59  const std::string& texCoordsNameIn); // Must be a GLSL vec2
60 
71  void setTexCoordsForBlock(int faceIndex,
72  float sMin=0.0, float sMax=1.0, float tMin=0.0, float tMax=1.0);
73 
80  static void setUseEBOs(bool b) { useEBOs = b; }
81 
82 private:
83  void defineGeometry();
84 
85  ShaderIF* shaderIF;
86  BasicShape* theShape;
87  GLuint vao, vertexBuffer, normalBuffer, textureCoordBuffer, *ebo;
88  GLuint texCoordBufferForBlock;
89  int nEBOs;
90 
91  static std::string mcPositionName; // Default: "mcPosition"
92  static std::string mcNormalName; // Default: "mcNormal"
93  static std::string texCoordsName; // Default: "texCoords"
94  // Use element buffer instead of local index arrays?
95  static bool useEBOs;
96 
97  // To support setTexCoordsForBlock:
98  static float texCoordsForBlock[8][2];
99 };
100 
101 #endif
virtual ~BasicShapeRenderer()
Definition: BasicShapeRenderer.c++:22
BasicShapeRenderer(ShaderIF *sIF, BasicShape *shapeIn)
Definition: BasicShapeRenderer.c++:12
static void setGLSLVariableNames(const std::string &mcPositionNameIn, const std::string &mcNormalNameIn, const std::string &texCoordsNameIn)
Definition: BasicShapeRenderer.c++:183
static void setUseEBOs(bool b)
Definition: BasicShapeRenderer.h:80
void getMCBoundingBox(double *xyzLimits) const
Definition: BasicShapeRenderer.c++:113
Definition: BasicShape.h:25
void setTexCoordsForBlock(int faceIndex, float sMin=0.0, float sMax=1.0, float tMin=0.0, float tMax=1.0)
Definition: BasicShapeRenderer.c++:191
Definition: BasicShapeRenderer.h:16
void renderShape(FacePrepFcn prepareForFace=nullptr, void *caller=nullptr)
Definition: BasicShapeRenderer.c++:118