OGLplus (0.52.0) a C++ wrapper for OpenGL

sky_box.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_SHAPES_SKY_CUBE_1206011111_HPP
14 #define OGLPLUS_SHAPES_SKY_CUBE_1206011111_HPP
15 
16 #include <oglplus/face_mode.hpp>
17 #include <oglplus/shapes/draw.hpp>
18 #include <oglplus/math/sphere.hpp>
19 
21 
22 namespace oglplus {
23 namespace shapes {
24 
26 class SkyBox
27  : public DrawingInstructionWriter
28  , public DrawMode
29 {
30 private:
31 public:
34  {
35  return FaceOrientation::CW;
36  }
37 
38  typedef GLuint (SkyBox::*VertexAttribFunc)(std::vector<GLfloat>&) const;
39 
41  template <typename T>
42  GLuint Positions(std::vector<T>& dest) const
43  {
44  const T _positions[8*3] = {
45  T(-1), T(-1), T(-1),
46  T(+1), T(-1), T(-1),
47  T(-1), T(+1), T(-1),
48  T(+1), T(+1), T(-1),
49  T(-1), T(-1), T(+1),
50  T(+1), T(-1), T(+1),
51  T(-1), T(+1), T(+1),
52  T(+1), T(+1), T(+1)
53  };
54  dest.assign(_positions, _positions+8*3);
55  return 3;
56  }
57 
58 #if OGLPLUS_DOCUMENTATION_ONLY
59 
64  typedef VertexAttribsInfo<SkyBox> VertexAttribs;
65 #else
66  typedef VertexAttribsInfo<
67  SkyBox,
68  std::tuple<
69  VertexPositionsTag
70  >
71  > VertexAttribs;
72 #endif
73 
75  template <typename T>
76  void BoundingSphere(oglplus::Sphere<T>& bounding_sphere) const
77  {
78  bounding_sphere = oglplus::Sphere<T>(T(0), T(0), T(0), T(1));
79  }
80 
82  typedef std::vector<GLushort> IndexArray;
83 
85  IndexArray Indices(Default = Default()) const
86  {
87  const GLushort _indices[6*5] = {
88  1, 3, 5, 7, 9,
89  4, 6, 0, 2, 9,
90  2, 6, 3, 7, 9,
91  4, 0, 5, 1, 9,
92  5, 7, 4, 6, 9,
93  0, 2, 1, 3, 9
94  };
95  return IndexArray(_indices, _indices+6*5);
96  }
97 
100  {
101  DrawOperation operation;
102  operation.method = DrawOperation::Method::DrawElements;
104  operation.first = 0;
105  operation.count = 6*5;
106  operation.restart_index = 9;
107  operation.phase = 0;
108 
109  return this->MakeInstructions(operation);
110  }
111 };
112 
113 } // shapes
114 } // oglplus
115 
116 #endif // include guard
Implementation of shape draw instructions.
void BoundingSphere(oglplus::Sphere< T > &bounding_sphere) const
Queries the bounding sphere coordinates and dimensions.
Definition: sky_box.hpp:76
FaceOrientation FaceWinding(void) const
Returns the winding direction of faces.
Definition: sky_box.hpp:33
GLuint Positions(std::vector< T > &dest) const
Makes the vertices and returns the number of values per vertex.
Definition: sky_box.hpp:42
DrawingInstructions Instructions(Default=Default()) const
Returns the instructions for rendering of faces.
Definition: sky_box.hpp:99
Sphere utility class.
GLuint first
The first element.
Definition: draw.hpp:111
VertexAttribsInfo< SkyBox > VertexAttribs
Vertex attribute information for this shape builder.
Definition: sky_box.hpp:64
FaceOrientation
Face orientation enumeration.
Definition: face_mode.hpp:62
OpenGL face type-related enumeration.
PrimitiveType mode
The primitive type to be used to draw.
Definition: draw.hpp:108
std::vector< GLushort > IndexArray
The type of the index container returned by Indices()
Definition: sky_box.hpp:82
GLuint restart_index
Primitive restart index.
Definition: draw.hpp:126
Structure containing information about how to draw a part of a shape.
Definition: draw.hpp:100
IndexArray Indices(Default=Default()) const
Returns element indices that are used with the drawing instructions.
Definition: sky_box.hpp:85
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.
Class providing vertex attributes and instructions for drawing of a sky box.
Definition: sky_box.hpp:26
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
Class implementing sphere-related functionality.
Definition: sphere.hpp:29

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).