OGLplus (0.52.0) a C++ wrapper for OpenGL

output_data.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_OUTPUT_DATA_1310102147_HPP
14 #define OGLPLUS_OUTPUT_DATA_1310102147_HPP
15 
16 #include <oglplus/buffer_size.hpp>
17 #include <oglplus/data_type.hpp>
18 
19 namespace oglplus {
20 
23 {
24 public:
25  typedef OneOf<
26  GLenum,
27  std::tuple<
28  DataType,
30  >
31  > PixDataType;
32 private:
33  PixDataType _type;
34  BufferSize _size;
35  GLvoid* _addr;
36 
37  OutputData(const OutputData&);
38 public:
39 
41  OutputData(BufferSize size, GLvoid* addr)
42  : _type(DataType::UnsignedByte)
43  , _size(size)
44  , _addr(addr)
45  { }
46 
48  OutputData(PixDataType type, BufferSize size, GLvoid* addr)
49  : _type(type)
50  , _size(size)
51  , _addr(addr)
52  { }
53 
55  template <typename T>
56  OutputData(GLsizei count, T* addr)
57  : _type(GetDataType<T>())
58  , _size(count, addr)
59  , _addr(addr)
60  { }
61 
63  template <typename T, std::size_t N>
64  OutputData(T (&addr)[N])
65  : _type(GetDataType<T>())
66  , _size(addr)
67  , _addr(addr)
68  { }
69 
71  template <typename T, std::size_t N>
72  OutputData(std::array<T, N>& a)
73  : _type(GetDataType<T>())
74  , _size(a)
75  , _addr(a.data())
76  { }
77 
79  template <typename T>
80  OutputData(std::vector<T>& v)
81  : _type(GetDataType<T>())
82  , _size(v)
83  , _addr(v.data())
84  { }
85 
86  PixDataType Type(void) const
87  {
88  return _type;
89  }
90 
91  GLsizeiptr Size(void) const
92  {
93  return _size.Get();
94  }
95 
96  GLvoid* Addr(void) const
97  {
98  return _addr;
99  }
100 };
101 
102 } // namespace oglplus
103 
104 #endif // include guard
DataType
OpenGL data type enumeration.
Definition: data_type.hpp:34
Class used for passing the address and size of a writable buffer to functions.
Definition: output_data.hpp:22
This class represents the size of a GPU buffer in bytes.
Definition: buffer_size.hpp:22
OutputData(std::array< T, N > &a)
Construction from a std::array.
Definition: output_data.hpp:72
PixelDataType
OpenGL pixel data type enumeration.
Definition: pixel_data.hpp:29
Object representing Buffer's storage size in bytes.
Data type-related declarations.
GLsizeiptr Get(void) const
Gets the size in bytes.
Definition: buffer_size.hpp:58
OutputData(BufferSize size, GLvoid *addr)
Construction from size in bytes and pointer to addr.
Definition: output_data.hpp:41
Stores a value having one of the listed types in a common representation.
Definition: one_of.hpp:60
OutputData(std::vector< T > &v)
Construction from a std::vector.
Definition: output_data.hpp:80
OutputData(T(&addr)[N])
Construction from an array with known size.
Definition: output_data.hpp:64
OutputData(PixDataType type, BufferSize size, GLvoid *addr)
Construction from type, size in bytes and pointer to addr.
Definition: output_data.hpp:48
DataType GetDataType(void)
Returns the DataType for the specified type T.
Definition: data_type.hpp:94
OutputData(GLsizei count, T *addr)
Construction from count of instances of type T at addr.
Definition: output_data.hpp:56

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