AGL
A graphics library
agl::Torus Class Reference

Draw a torus mesh. More...

#include <torus.h>

Public Member Functions

 Torus (GLfloat outerRadius, GLfloat innerRadius, GLuint nsides, GLuint nrings)
 Create a torus mesh. More...
 
- Public Member Functions inherited from agl::TriangleMesh
virtual void render () const
 Draw this mesh. More...
 
- Public Member Functions inherited from agl::Mesh
GLuint vao () const
 Return the vertex array object corresponding to this mesh.
 
bool hasUV () const
 Return whether this mesh has UV coordinates defined.
 
bool isDynamic () const
 Query whether or not this is a dynamic mesh. More...
 

Protected Member Functions

void init () override
 Override init to specifiy vertex data for the mesh. More...
 
- Protected Member Functions inherited from agl::TriangleMesh
void initBuffers (std::vector< GLuint > *indices, std::vector< GLfloat > *points, std::vector< GLfloat > *normals, std::vector< GLfloat > *texCoords=nullptr, std::vector< GLfloat > *tangents=nullptr)
 Call initBuffers from init() to set the data for this mesh. More...
 
- Protected Member Functions inherited from agl::Mesh
int numVertices () const
 Get the number of vertices.
 
void setVertexData (VertexAttribute type, int vertexId, const glm::vec4 &data)
 Set vertex properties. More...
 
glm::vec4 vertexData (VertexAttribute type, int vertexId) const
 Get vertex properties. More...
 
virtual void setIsDynamic (bool on)
 Set whether or not this is a dynamic mesh. More...
 
void initBuffers (std::vector< GLfloat > *points, std::vector< GLfloat > *normals, std::vector< GLfloat > *texCoords=nullptr, std::vector< GLfloat > *tangents=nullptr)
 Call initBuffers from init() to set the data for this mesh. More...
 
virtual void deleteBuffers ()
 

Additional Inherited Members

- Protected Types inherited from agl::Mesh
enum  VertexAttribute {
  INDEX = 0, POSITION, NORMAL, UV,
  TANGENT, NUM_ATTRIBUTES
}
 
- Protected Attributes inherited from agl::TriangleMesh
GLuint _nIndices = 0
 
- Protected Attributes inherited from agl::Mesh
GLuint _nVerts = 0
 
GLuint _vao = 0
 
bool _hasUV = false
 
bool _isDynamic = false
 
bool _initialized = false
 
std::vector< GLuint > _buffers
 
std::vector< GLfloat > _data [5]
 

Detailed Description

Draw a torus mesh.

Constructor & Destructor Documentation

◆ Torus()

agl::Torus::Torus ( GLfloat  outerRadius,
GLfloat  innerRadius,
GLuint  nsides,
GLuint  nrings 
)

Create a torus mesh.

Parameters
outerRadiusThe size of the torus (distance from the center)
innerRadiusThe size of the hole (distance from the center)
nsidesThe number of latitude edges for mesh generation
nringsThe number longitude rings for mesh generation

Use the renderer to draw a torus with default settings. Create a new torus to create torus with different settings.

 
See also
Renderer::torus()

Member Function Documentation

◆ init()

void agl::Torus::init ( )
overrideprotectedvirtual

Override init to specifiy vertex data for the mesh.

init() will be called automatically the first time render() is called. Overridden implementations of init() should call initBuffers.

See also
initBuffers(std::vector<GLuint>*, std::vector<GLfloat>*, std::vector<GLfloat>*, std::vector<GLfloat>*, std::vector<GLfloat>*)

Implements agl::Mesh.


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