-
Notifications
You must be signed in to change notification settings - Fork 0
/
sphere.h
48 lines (33 loc) · 1.03 KB
/
sphere.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <QtOpenGL>
namespace cs40{
class Sphere {
typedef QVector2D vec2;
typedef QVector3D vec3;
typedef QVector4D vec4;
public:
/* construct a sphere centered at origin with given radius
* by dividing it into vertical slices and horizontal stacks */
Sphere(float radius, int slices, int stacks);
~Sphere();
/* draw the sphere using provided shader program */
void draw(QOpenGLShaderProgram* prog);
/* Set color of Sphere */
inline void setColor(const vec3& color){ m_color=color; m_color.setW(1.); }
/* Get current color of object */
inline vec4 getColor() const { return m_color; }
private:
/* Generate Vertex Buffer Objects, but do not bind/allocate.
* Return true if generate was a success, false otherwise
*/
bool initVBO();
protected:
vec4 m_color;
QOpenGLVertexArrayObject* m_vao;
QOpenGLBuffer* m_vbo;
float m_radius;
int m_slices;
int m_stacks;
int m_stripsize; //num vertices per horizontal strip;
};
} //namespace