OGLplus (0.52.0) a C++ wrapper for OpenGL

vector.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_SHAPES_VECTOR_1107121519_HPP
14 #define OGLPLUS_SHAPES_VECTOR_1107121519_HPP
15 
16 #include <oglplus/face_mode.hpp>
17 #include <oglplus/shapes/draw.hpp>
18 
20 
22 #include <oglplus/math/sphere.hpp>
23 
24 namespace oglplus {
25 namespace shapes {
26 
29  : public DrawingInstructionWriter
30  , public DrawMode
31 {
32 private:
33  GLdouble _x, _y, _z;
34 public:
37  : _x(1)
38  , _y(0)
39  , _z(0)
40  { }
41 
43  PointAndVector(GLdouble x, GLdouble y, GLdouble z)
44  : _x(x)
45  , _y(y)
46  , _z(z)
47  { }
48 
51  {
52  return FaceOrientation::CW;
53  }
54 
55  typedef GLuint (PointAndVector::*VertexAttribFunc)(std::vector<GLfloat>&) const;
56 
58  template <typename T>
59  GLuint Positions(std::vector<T>& dest) const
60  {
61  T _positions[3] = {T(0), T(0), T(0)};
62  dest.assign(_positions, _positions+3);
63  return 3;
64  }
65 
67  template <typename T>
68  GLuint Normals(std::vector<T>& dest) const
69  {
70  T _normals[3] = {T(_x), T(_y), T(_z)};
71  dest.assign(_normals, _normals+3);
72  return 3;
73  }
74 
75 #if OGLPLUS_DOCUMENTATION_ONLY
76 
82  typedef VertexAttribsInfo<PointAndVector> VertexAttribs;
83 #else
84  typedef VertexAttribsInfo<
86  std::tuple<
87  VertexPositionsTag,
88  VertexNormalsTag
89  >
90  > VertexAttribs;
91 #endif
92 
94  template <typename T>
95  void BoundingSphere(oglplus::Sphere<T>& bounding_sphere) const
96  {
97  bounding_sphere = oglplus::Sphere<T>(
98  T(0),
99  T(0),
100  T(0),
101  T(std::sqrt(_x*_x + _y*_y + _z*_z))
102  );
103  }
104 
106  typedef std::vector<GLushort> IndexArray;
107 
109  IndexArray Indices(Default = Default()) const
110  {
111  return IndexArray();
112  }
113 
116  {
117  DrawOperation operation;
118  operation.method = DrawOperation::Method::DrawArrays;
119  operation.mode = PrimitiveType::Points;
120  operation.first = 0;
121  operation.count = 1;
123  operation.phase = 0;
124 
125  return this->MakeInstructions(operation);
126  }
127 };
128 
129 } // shapes
130 } // oglplus
131 
132 #endif // include guard
Implementation of shape draw instructions.
std::vector< GLushort > IndexArray
The type of the index container returned by Indices()
Definition: vector.hpp:106
GLuint Normals(std::vector< T > &dest) const
Makes the normals and returns the number of values per vertex.
Definition: vector.hpp:68
IndexArray Indices(Default=Default()) const
Returns element indices that are used with the drawing instructions.
Definition: vector.hpp:109
DrawingInstructions Instructions(Default=Default()) const
Returns the instructions for rendering of faces.
Definition: vector.hpp:115
Sphere utility class.
PointAndVector(GLdouble x, GLdouble y, GLdouble z)
Constructs a vector with x,y,z coordinates.
Definition: vector.hpp:43
GLuint first
The first element.
Definition: draw.hpp:111
FaceOrientation
Face orientation enumeration.
Definition: face_mode.hpp:62
OpenGL face type-related enumeration.
Class providing vertex attributes and instructions for rendering of a vector.
Definition: vector.hpp:28
PrimitiveType mode
The primitive type to be used to draw.
Definition: draw.hpp:108
GLuint restart_index
Primitive restart index.
Definition: draw.hpp:126
static GLuint NoRestartIndex(void)
Special constant for disabling primitive restart.
Definition: draw.hpp:117
VertexAttribsInfo< PointAndVector > VertexAttribs
Vertex attribute information for this shape builder.
Definition: vector.hpp:82
Structure containing information about how to draw a part of a shape.
Definition: draw.hpp:100
GLuint count
Count of elements.
Definition: draw.hpp:114
Method method
The method to be used to draw.
Definition: draw.hpp:106
Classes providing additional information about the shape builders.
Math constants.
GLuint phase
The phase of the drawing process.
Definition: draw.hpp:135
Class encapsulating the instructions for drawing of a shape.
Definition: draw.hpp:219
FaceOrientation FaceWinding(void) const
Returns the winding direction of faces.
Definition: vector.hpp:50
Class implementing sphere-related functionality.
Definition: sphere.hpp:29
GLuint Positions(std::vector< T > &dest) const
Makes the vertices and returns the number of values per vertex.
Definition: vector.hpp:59
void BoundingSphere(oglplus::Sphere< T > &bounding_sphere) const
Queries the bounding sphere coordinates and dimensions.
Definition: vector.hpp:95
PointAndVector(void)
Constructs an unit vector pointing in the x-axis direction.
Definition: vector.hpp:36

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).