OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Torus.h
Go to the documentation of this file.
1 /* Copyright (c) 2012-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef TORUS_H
22 #define TORUS_H
23 
24 #include <GLES3/gl3.h>
25 #include <GLES3/gl3ext.h>
26 
27 #include <string>
28 
29 #include "Matrix.h"
30 
39 class Torus
40 {
41 protected:
45  static std::string resourceDirectory;
49  static const unsigned int vertexComponentsCount = 4;
53  static const unsigned int circlesCount = 12;
57  static const unsigned int pointsPerCircleCount = 12;
61  static const unsigned int torusVerticesCount = pointsPerCircleCount * circlesCount;
66 
70  float torusRadius;
74  float circleRadius;
75 
84 
88  Torus(void);
89 
95  virtual bool initializeVertexAttribs() = 0;
96 
105  void setColor(float red, float green, float blue, float alpha);
106 
113  void setupGraphics(const std::string vertexShaderPath, const std::string fragmentShaderPath);
114 
115 public:
116 
120  virtual ~Torus(void);
121 
127  virtual void draw(float* rotationVector) = 0;
128 
135 
141  void static setResourceDirectory(std::string requiredResourceDirectory);
142 };
143 
144 #endif /* TORUS_H */
static const unsigned int vertexComponentsCount
Number of coordinates for one vertex.
Definition: Torus.h:49
virtual ~Torus(void)
Frees allocated memory.
Definition: Torus.cpp:43
float projectionMatrix[16]
Definition: Native.cpp:156
void setProjectionMatrix(MaliSDK::Matrix *projectionMatrix)
Pass the correctly defined projection matrix to the program related to the torus model.
Definition: Torus.cpp:67
Functions for manipulating matrices.
Definition: Matrix.h:31
GLuint programID
ID of a program linked to the torus model.
Definition: Torus.h:79
static const unsigned int pointsPerCircleCount
Number of points in one circle.
Definition: Torus.h:57
Torus(void)
Protected constructor used to do intialization general to all torus objects.
Definition: Torus.cpp:35
float torusRadius
Distance between the center of torus and the center of its tube.
Definition: Torus.h:70
virtual bool initializeVertexAttribs()=0
Initialize vertex attribute arrays and buffer objects coresponding to them. Make sure that programID ...
void setColor(float red, float green, float blue, float alpha)
Sets the uniform color of the drawn torus.
Definition: Torus.cpp:49
static void setResourceDirectory(std::string requiredResourceDirectory)
Set the resource directory for all tori.
Definition: Torus.cpp:105
static const unsigned int circlesCount
Number of circles in torus model.
Definition: Torus.h:53
float circleRadius
Radius of circles that model the tube.
Definition: Torus.h:74
Abstract class that draws torus on the screen. It stores generic data describing the drawn torus: ...
Definition: Torus.h:39
GLuint vaoID
ID of a vertex array object that stores pointers to vertex data sources used to rasterize given mesh...
Definition: Torus.h:83
virtual void draw(float *rotationVector)=0
Draw the torus model.
static const unsigned int torusVerticesCount
Total number of vertices in torus model.
Definition: Torus.h:61
void setupGraphics(const std::string vertexShaderPath, const std::string fragmentShaderPath)
Initialize constant OpenGL components such as program, shaders and constant matrices.
Definition: Torus.cpp:75
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
static const unsigned int componentsCount
Total number of components in torus model, needed to determine the size of vertex arrays...
Definition: Torus.h:65
static std::string resourceDirectory
Definition: Torus.h:45