OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Torus Class Referenceabstract

Abstract class that draws torus on the screen. It stores generic data describing the drawn torus: More...

#include <Torus.h>

Inheritance diagram for Torus:
InstancedSolidTorus WireframeTorus

Public Member Functions

virtual ~Torus (void)
 Frees allocated memory. More...
 
virtual void draw (float *rotationVector)=0
 Draw the torus model. More...
 
void setProjectionMatrix (MaliSDK::Matrix *projectionMatrix)
 Pass the correctly defined projection matrix to the program related to the torus model. More...
 

Static Public Member Functions

static void setResourceDirectory (std::string requiredResourceDirectory)
 Set the resource directory for all tori. More...
 

Protected Member Functions

 Torus (void)
 Protected constructor used to do intialization general to all torus objects. More...
 
virtual bool initializeVertexAttribs ()=0
 Initialize vertex attribute arrays and buffer objects coresponding to them. Make sure that programID has been set before this function is called. More...
 
void setColor (float red, float green, float blue, float alpha)
 Sets the uniform color of the drawn torus. More...
 
void setupGraphics (const std::string vertexShaderPath, const std::string fragmentShaderPath)
 Initialize constant OpenGL components such as program, shaders and constant matrices. More...
 

Protected Attributes

float torusRadius
 Distance between the center of torus and the center of its tube. More...
 
float circleRadius
 Radius of circles that model the tube. More...
 
GLuint programID
 ID of a program linked to the torus model. More...
 
GLuint vaoID
 ID of a vertex array object that stores pointers to vertex data sources used to rasterize given mesh. More...
 

Static Protected Attributes

static std::string resourceDirectory
 
static const unsigned int vertexComponentsCount = 4
 Number of coordinates for one vertex. More...
 
static const unsigned int circlesCount = 12
 Number of circles in torus model. More...
 
static const unsigned int pointsPerCircleCount = 12
 Number of points in one circle. More...
 
static const unsigned int torusVerticesCount = pointsPerCircleCount * circlesCount
 Total number of vertices in torus model. More...
 
static const unsigned int componentsCount = torusVerticesCount * vertexComponentsCount
 Total number of components in torus model, needed to determine the size of vertex arrays. More...
 

Detailed Description

Abstract class that draws torus on the screen. It stores generic data describing the drawn torus:

  • its radii,
  • number of points used to model it,
  • ID of a program associated with it,
  • ID of a vertex array object in which pointers to the corrresponding data are stored. Derived classes must determine a way of initializing vertex attribute arrays and drawing the torus model.

Definition at line 39 of file Torus.h.

Constructor & Destructor Documentation

Torus::Torus ( void  )
protected

Protected constructor used to do intialization general to all torus objects.

Definition at line 35 of file Torus.cpp.

Torus::~Torus ( void  )
virtual

Frees allocated memory.

Definition at line 43 of file Torus.cpp.

Member Function Documentation

virtual void Torus::draw ( float rotationVector)
pure virtual

Draw the torus model.

Parameters
rotationVectorVector with rotation parameters to be passed to the vertex shader.

Implemented in InstancedSolidTorus, and WireframeTorus.

virtual bool Torus::initializeVertexAttribs ( )
protectedpure virtual

Initialize vertex attribute arrays and buffer objects coresponding to them. Make sure that programID has been set before this function is called.

Returns
false if error reported, true otherwise.

Implemented in InstancedSolidTorus, and WireframeTorus.

void Torus::setColor ( float  red,
float  green,
float  blue,
float  alpha 
)
protected

Sets the uniform color of the drawn torus.

Parameters
red[in] Value for red channel.
green[in] Value for green channel.
blue[in] Value for blue channel.
alpha[in] Vlaue for alpha channel.

Definition at line 49 of file Torus.cpp.

void Torus::setProjectionMatrix ( MaliSDK::Matrix projectionMatrix)

Pass the correctly defined projection matrix to the program related to the torus model.

Parameters
projectionMatrix[in] Projection matrix which will be passed to the vertex shader.

Definition at line 67 of file Torus.cpp.

void Torus::setResourceDirectory ( std::string  requiredResourceDirectory)
static

Set the resource directory for all tori.

Parameters
requiredResourceDirectory[in] The required resource directory.

Definition at line 105 of file Torus.cpp.

void Torus::setupGraphics ( const std::string  vertexShaderPath,
const std::string  fragmentShaderPath 
)
protected

Initialize constant OpenGL components such as program, shaders and constant matrices.

Parameters
vertexShaderPath[in] Path of the file containing vertex shader source.
fragmentShaderPath[in] Path of the file containing fragment shader source.

Definition at line 75 of file Torus.cpp.

Member Data Documentation

float Torus::circleRadius
protected

Radius of circles that model the tube.

Definition at line 74 of file Torus.h.

const unsigned int Torus::circlesCount = 12
staticprotected

Number of circles in torus model.

Definition at line 53 of file Torus.h.

const unsigned int Torus::componentsCount = torusVerticesCount * vertexComponentsCount
staticprotected

Total number of components in torus model, needed to determine the size of vertex arrays.

Definition at line 65 of file Torus.h.

const unsigned int Torus::pointsPerCircleCount = 12
staticprotected

Number of points in one circle.

Definition at line 57 of file Torus.h.

GLuint Torus::programID
protected

ID of a program linked to the torus model.

Definition at line 79 of file Torus.h.

string Torus::resourceDirectory
staticprotected

Path to the directory containing shaders and textures.

Definition at line 45 of file Torus.h.

float Torus::torusRadius
protected

Distance between the center of torus and the center of its tube.

Definition at line 70 of file Torus.h.

const unsigned int Torus::torusVerticesCount = pointsPerCircleCount * circlesCount
staticprotected

Total number of vertices in torus model.

Definition at line 61 of file Torus.h.

GLuint Torus::vaoID
protected

ID of a vertex array object that stores pointers to vertex data sources used to rasterize given mesh.

Definition at line 83 of file Torus.h.

const unsigned int Torus::vertexComponentsCount = 4
staticprotected

Number of coordinates for one vertex.

Definition at line 49 of file Torus.h.


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