Basic Shape Creation and Rendering  2.0
Tools to create and render common shapes like blocks, cylinders, cones, and spheres
Public Member Functions | Static Public Member Functions | List of all members
BasicShapeRenderer Class Reference

Public Member Functions

 BasicShapeRenderer (ShaderIF *sIF, BasicShape *shapeIn)
 
virtual ~BasicShapeRenderer ()
 
void getMCBoundingBox (double *xyzLimits) const
 
void renderShape (FacePrepFcn prepareForFace=nullptr, void *caller=nullptr)
 
void setTexCoordsForBlock (int faceIndex, float sMin=0.0, float sMax=1.0, float tMin=0.0, float tMax=1.0)
 

Static Public Member Functions

static void setGLSLVariableNames (const std::string &mcPositionNameIn, const std::string &mcNormalNameIn, const std::string &texCoordsNameIn)
 
static void setUseEBOs (bool b)
 

Constructor & Destructor Documentation

◆ BasicShapeRenderer()

BasicShapeRenderer::BasicShapeRenderer ( ShaderIF *  sIF,
BasicShape shapeIn 
)

Create a BasicShapeRenderer using the given GLSL shader program and BasicShape instance.

Parameters
sIFthe GLSL shader program to use when rendering
shapeInthe BasicShape instance to be rendered

◆ ~BasicShapeRenderer()

BasicShapeRenderer::~BasicShapeRenderer ( )
virtual

The destructor

Member Function Documentation

◆ getMCBoundingBox()

void BasicShapeRenderer::getMCBoundingBox ( double *  xyzLimits) const

Return the MC bounding box for the BasicShape being rendered

Parameters
xyzLimitsthe (xmin, xmax, ymin, ymax, zmin,zmax) limits

◆ renderShape()

void BasicShapeRenderer::renderShape ( FacePrepFcn  prepareForFace = nullptr,
void *  caller = nullptr 
)

Draw the BasicShape with the optional prepareForFace callback function and caller

Parameters
prepareForFacean optional callback function that will be invoked at the start of each real face of the BasicShape. For cylinder, cone, and sphere basic shapes, this will be called only for face ID=0, the curved face. For block BasicShape instances, it will be called for each of the 6 faces of the block.
callerthe object (typically a ModelView descendent class) that is using this BasicShapeRenderer

◆ setGLSLVariableNames()

void BasicShapeRenderer::setGLSLVariableNames ( const std::string &  mcPositionNameIn,
const std::string &  mcNormalNameIn,
const std::string &  texCoordsNameIn 
)
static

Set the GLSL variable names for the three required PVAs: position, normal, and texture coordinates. These are used when the renderer needs to access and/or fill the VBOs and/or enable flags associated with these variables. They default to the conventional: "mcPosition", "mcNormal", and "texCoords".

Parameters
mcPositionNameInthe GLSL variable name for the model coordinate position (assumed to be a GLSL vec3)
mcNormalNameInthe GLSL variable name for the model coordinate normal vector (assumed to be a GLSL vec3)
texCoordsNameInthe GLSL variable name for the texture coordinates (assumed to be a GLSL vec2)

◆ setTexCoordsForBlock()

void BasicShapeRenderer::setTexCoordsForBlock ( int  faceIndex,
float  sMin = 0.0,
float  sMax = 1.0,
float  tMin = 0.0,
float  tMax = 1.0 
)

A method that can be used to establish texture coordinates for a specific face of a BasicShape created using BasicShape::makeBlock. This routine will typically be called from the "prepareForFace" callback passed to BasicShapeRenderer::renderShape.

Parameters
faceIndexthe face being drawn (0<=faceIndex<=5; See BasicShape::makeBlock for the faceIndex assignments)
sMinthe minimum s texture coordinate desired
sMaxthe maximum s texture coordinate desired
tMinthe minimum t texture coordinate desired
tMaxthe maximum t texture coordinate desired

◆ setUseEBOs()

static void BasicShapeRenderer::setUseEBOs ( bool  b)
inlinestatic

Control whether EBOs are used in glDrawElements calls or whether an array of integers is passed directly to the glDrawElements call. The default is "true" which seems to work best in terms of platform portability (and probably performance).

Parameters
b"true" if EBOs should be used; "false" if directly passing index arrays to glDrawElements is to be done.

The documentation for this class was generated from the following files: