OGLplus (0.52.0) a C++ wrapper for OpenGL

glsl_source.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_GLSL_SOURCE_1207111232_HPP
14 #define OGLPLUS_GLSL_SOURCE_1207111232_HPP
15 
16 #include <oglplus/glsl_string.hpp>
17 #include <oglplus/detail/glsl_source.hpp>
18 
19 namespace oglplus {
20 
23 {
24 private:
25  aux::GLSLSourceWrapper* _impl;
26 
27  template <typename Impl, typename P1>
28  static aux::GLSLSourceWrapper* make_impl(P1&& p1)
29  {
30  return new Impl(std::forward<P1>(p1));
31  }
32 
33  template <typename Impl, typename P1, typename P2>
34  static aux::GLSLSourceWrapper* make_impl(P1&& p1, P2&& p2)
35  {
36  return new Impl(
37  std::forward<P1>(p1),
38  std::forward<P2>(p2)
39  );
40  }
41 
42  GLSLSource(const GLSLSource&);
43 public:
44  ~GLSLSource(void)
45  {
46  if(_impl) delete _impl;
47  }
48 
49  GLSLSource(GLSLSource&& tmp)
50  : _impl(tmp._impl)
51  {
52  tmp._impl = nullptr;
53  }
54 
55  explicit GLSLSource(const StrCRef& source)
56  : _impl(make_impl<aux::StrCRefGLSLSrcWrap>(source))
57  { }
58 
59  GLSLSource(const std::vector<StrCRef>& lits)
60  : _impl(make_impl<aux::StrCRefsGLSLSrcWrap>(
61  lits.begin(),
62  lits.end()
63  ))
64  { }
65 
66  template <size_t N>
67  GLSLSource(const StrCRef (&lits)[N])
68  : _impl(make_impl<aux::StrCRefsGLSLSrcWrap>(
69  lits,
70  lits+N
71  ))
72  { }
73 
74  GLSLSource(const std::vector<String>& strs)
75  : _impl(make_impl<aux::StrsGLSLSrcWrap>(
76  strs.begin(),
77  strs.end()
78  ))
79  { }
80 
81 #if !OGLPLUS_NO_INITIALIZER_LISTS
82  GLSLSource(std::initializer_list<StrCRef> lits)
83  : _impl(make_impl<aux::StrCRefsGLSLSrcWrap>(
84  lits.begin(),
85  lits.end()
86  ))
87  { }
88 
89  GLSLSource(std::initializer_list<String> strs)
90  : _impl(make_impl<aux::StrsGLSLSrcWrap>(
91  strs.begin(),
92  strs.end()
93  ))
94  { }
95 #endif
96 
97  template <typename Head, typename Tail>
98  GLSLSource(const StrCRefChainTpl<GLchar, Head, Tail>& source)
99  : _impl(make_impl<aux::StrGLSLSrcWrap>(source.str()))
100  { }
101 
102  explicit GLSLSource(const String& source)
103  : _impl(make_impl<aux::StrGLSLSrcWrap>(source))
104  { }
105 
106  explicit GLSLSource(String&& source)
107  : _impl(make_impl<aux::StrGLSLSrcWrap>(std::move(source)))
108  { }
109 
110  struct FromStream_ { };
111 
112  GLSLSource(std::istream& input, FromStream_)
113  : _impl(make_impl<aux::InputStreamGLSLSrcWrap>(input))
114  { }
115 
116  static GLSLSource FromStream(std::istream& input)
117  {
118  return GLSLSource(input, FromStream_());
119  }
120 
121  struct FromFile_ { };
122 
123  GLSLSource(const char* path, FromFile_)
124  : _impl(make_impl<aux::FileGLSLSrcWrap>(path))
125  { }
126 
127  static GLSLSource FromFile(const char* path)
128  {
129  return GLSLSource(path, FromFile_());
130  }
131 
132  static GLSLSource FromFile(const String& path)
133  {
134  return GLSLSource(path.c_str(), FromFile_());
135  }
136 
138  GLsizei Count(void) const
139  OGLPLUS_NOEXCEPT(true)
140  {
141  assert(_impl);
142  return _impl->Count();
143  }
144 
146  const GLchar* const* Parts(void) const
147  OGLPLUS_NOEXCEPT(true)
148  {
149  assert(_impl);
150  return _impl->Parts();
151  }
152 
154  GLint const * Lengths(void) const
155  OGLPLUS_NOEXCEPT(true)
156  {
157  assert(_impl);
158  return _impl->Lengths();
159  }
160 };
161 
162 } // namespace oglplus
163 
164 #endif // include guard
const GLchar *const * Parts(void) const
Pointers to the individual parts of the source.
Definition: glsl_source.hpp:146
Class storing source code in GLSL.
Definition: glsl_source.hpp:22
Helper classes for passing source code in GLSL as parameters.
String const reference wrapper template.
Definition: ref_tpl.hpp:72
::std::basic_string< GLchar > String
String class.
Definition: def.hpp:36
GLsizei Count(void) const
Count of buffers storing the individual parts of the source.
Definition: glsl_source.hpp:138
GLint const * Lengths(void) const
Pointer to the lengths of the individual parts of the source.
Definition: glsl_source.hpp:154

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