OGLplus (0.52.0) a C++ wrapper for OpenGL

transform_feedback.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_TRANSFORM_FEEDBACK_1107121519_HPP
14 #define OGLPLUS_TRANSFORM_FEEDBACK_1107121519_HPP
15 
16 #include <oglplus/config/compiler.hpp>
17 #include <oglplus/glfunc.hpp>
19 #include <oglplus/error/object.hpp>
23 #include <cassert>
24 
25 namespace oglplus {
26 
27 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_transform_feedback2
28 
30 
37 template <>
38 class ObjGenDelOps<tag::TransformFeedback>
39 {
40 protected:
41  static void Gen(tag::Generate, GLsizei count, GLuint* names)
42  {
43  assert(names != nullptr);
44  OGLPLUS_GLFUNC(GenTransformFeedbacks)(count, names);
45  OGLPLUS_CHECK_SIMPLE(GenTransformFeedbacks);
46  }
47 #if GL_VERSION_4_5 || GL_ARB_direct_state_access
48  static void Gen(tag::Create, GLsizei count, GLuint* names)
49  {
50  assert(names != nullptr);
51  OGLPLUS_GLFUNC(CreateTransformFeedbacks)(count, names);
52  OGLPLUS_CHECK_SIMPLE(CreateTransformFeedbacks);
53  }
54 #endif
55 
56  static void Delete(GLsizei count, GLuint* names)
57  {
58  assert(names != nullptr);
59  OGLPLUS_GLFUNC(DeleteTransformFeedbacks)(count, names);
60  OGLPLUS_VERIFY_SIMPLE(DeleteTransformFeedbacks);
61  }
62 
63  static GLboolean IsA(GLuint name)
64  {
65  assert(name != 0);
66  GLboolean result = OGLPLUS_GLFUNC(IsTransformFeedback)(name);
67  OGLPLUS_VERIFY_SIMPLE(IsTransformFeedback);
68  return result;
69  }
70 };
71 
73 template <>
74 class ObjBindingOps<tag::TransformFeedback>
75 {
76 private:
77  static GLenum _binding_query(TransformFeedbackTarget target);
78 protected:
79  static GLuint _binding(TransformFeedbackTarget target);
80 public:
83 
85 
90  {
91  return TransformFeedbackName(_binding(target));
92  }
93 
95 
99  static void Bind(
100  Target target,
102  )
103  {
104  OGLPLUS_GLFUNC(BindTransformFeedback)(
105  GLenum(target),
106  GetGLName(tfb)
107  );
108  OGLPLUS_VERIFY(
109  BindTransformFeedback,
110  ObjectError,
111  Object(tfb).
112  BindTarget(target)
113  );
114  }
115 };
116 
117 #endif // GL_VERSION_4_0
118 
119 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0
120 
122 
125 template <>
127  : public TransformFeedbackName
128 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_transform_feedback2
129  , public ObjBindingOps<tag::TransformFeedback>
130 #endif
131 {
132 protected:
133  ObjCommonOps(void){ }
134 public:
135 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_transform_feedback2
137 
139 
143  void Bind(Target target = Target::TransformFeedback) const
144  {
145  Bind(target, *this);
146  }
147 #endif
148 
150 
160  {
161  OGLPLUS_GLFUNC(BeginTransformFeedback)(GLenum(mode));
162  OGLPLUS_VERIFY(
163  BeginTransformFeedback,
164  Error,
165  EnumParam(mode)
166  );
167  }
168 
170  static void BeginPoints(void)
171  {
173  }
174 
176  static void BeginLines(void)
177  {
179  }
180 
182  static void BeginTriangles(void)
183  {
185  }
186 
188 
197  static void End(void)
198  {
199  OGLPLUS_GLFUNC(EndTransformFeedback)();
200  OGLPLUS_VERIFY_SIMPLE(EndTransformFeedback);
201  }
202 
204 
213  static void Pause(void)
214  {
215  OGLPLUS_GLFUNC(PauseTransformFeedback)();
216  OGLPLUS_VERIFY_SIMPLE(PauseTransformFeedback);
217  }
218 
220 
229  static void Resume(void)
230  {
231  OGLPLUS_GLFUNC(ResumeTransformFeedback)();
232  OGLPLUS_VERIFY_SIMPLE(ResumeTransformFeedback);
233  }
234 
236 
247  class Activator
248  {
249  private:
250  bool _active;
251  public:
253 
258  : _active(true)
259  {
260  OGLPLUS_GLFUNC(BeginTransformFeedback)(GLenum(mode));
261  OGLPLUS_VERIFY(
262  BeginTransformFeedback,
263  Error,
264  EnumParam(mode)
265  );
266  }
267 
268 #if !OGLPLUS_NO_DELETED_FUNCTIONS
269  Activator(const Activator&) = delete;
271 #else
272  private:
273  Activator(const Activator&);
274  public:
275 #endif
276 
277  Activator(Activator&& tmp)
278  : _active(tmp._active)
279  {
280  tmp._active = false;
281  }
282 
283  void Finish(void)
284  {
285  if(_active)
286  {
287  OGLPLUS_GLFUNC(EndTransformFeedback)();
288  OGLPLUS_VERIFY_SIMPLE(EndTransformFeedback);
289  _active = false;
290  }
291  }
292 
294 
299  {
300  try { Finish(); }
301  catch(...){ }
302  }
303  };
304 
306 
317  class Pauser
318  {
319  private:
320  bool _paused;
321  public:
323 
327  Pauser(void)
328  : _paused(true)
329  {
330  OGLPLUS_GLFUNC(PauseTransformFeedback)();
331  OGLPLUS_VERIFY_SIMPLE(PauseTransformFeedback);
332  }
333 
334 #if !OGLPLUS_NO_DELETED_FUNCTIONS
335  Pauser(const Pauser&) = delete;
336 #else
337  private:
338  Pauser(const Pauser&);
339  public:
340 #endif
341 
342  Pauser(Pauser&& tmp)
343  : _paused(tmp._paused)
344  {
345  tmp._paused = false;
346  }
347 
349 
353  void Resume(void)
354  {
355  if(_paused)
356  {
357  OGLPLUS_GLFUNC(ResumeTransformFeedback)();
358  OGLPLUS_VERIFY_SIMPLE(ResumeTransformFeedback);
359  _paused = false;
360  }
361  }
362 
364 
368  ~Pauser(void)
369  {
370  try{ Resume(); }
371  catch(...){ }
372  }
373  };
374 };
375 
377 
382 typedef ObjectZero<ObjZeroOps<tag::ImplicitSel, tag::TransformFeedback>>
384 
385 #endif // GL_VERSION_3_0
386 
387 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0 || GL_ARB_transform_feedback2
388 
390 
392 template <typename OpsTag>
393 class ObjectOps<OpsTag, tag::TransformFeedback>
394  : public ObjZeroOps<OpsTag, tag::TransformFeedback>
395 {
396 protected:
397  ObjectOps(void){ }
398 };
399 
403 
405 
408 typedef Object<TransformFeedbackOps> TransformFeedback;
409 
410 #endif // GL_VERSION_4_0 || transform feedback 2
411 
412 } // namespace oglplus
413 
414 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
415 #include <oglplus/transform_feedback.ipp>
416 #endif // OGLPLUS_LINK_LIBRARY
417 
418 #endif // include guard
~Activator(void)
Ends transform feedback.
Definition: transform_feedback.hpp:298
static void BeginTriangles(void)
Begin the transform feedback mode with TRIANGLES.
Definition: transform_feedback.hpp:182
static void BeginPoints(void)
Begin the transform feedback mode with POINTS.
Definition: transform_feedback.hpp:170
ObjectOps< tag::ImplicitSel, tag::TransformFeedback > TransformFeedbackOps
TransformFeedback operations with explicit selector.
Definition: transform_feedback.hpp:402
Object< TransformFeedbackOps > TransformFeedback
An oglplus_object encapsulating the OpenGL transform feedback functionality.
Definition: transform_feedback.hpp:408
static void BeginLines(void)
Begin the transform feedback mode with LINES.
Definition: transform_feedback.hpp:176
static void Bind(Target target, TransformFeedbackName tfb)
Binds the specified transform feedback to the specified target.
Definition: transform_feedback.hpp:99
Pauser(void)
Pauses transform feedback.
Definition: transform_feedback.hpp:327
Declaration of OGLplus object-related error.
Generic OpenGL object wrapper.
TransformFeedbackPrimitiveType
Transform feedback primitive modes.
Definition: transform_feedback_type.hpp:25
static TransformFeedbackName Binding(Target target)
Returns the current TransformFeedback bound to specified target.
Definition: transform_feedback.hpp:89
TRANSFORM_FEEDBACK_BUFFER.
void Resume(void)
Explicitly resumes transform feedback.
Definition: transform_feedback.hpp:353
Implements operations applicable to named (non-zero) objects.
Definition: wrap_tpl.hpp:45
GLuint GetGLName(ObjectName< ObjTag > named)
Returns the GLuint OpenGL name assigned to named object.
Definition: name.hpp:38
TransformFeedbackType enumeration.
static void Begin(TransformFeedbackPrimitiveType mode)
Begin the transform feedback mode.
Definition: transform_feedback.hpp:159
static void End(void)
End the transform feedback mode.
Definition: transform_feedback.hpp:197
TransformFeedbackTarget
Transform feedback bind targets.
Definition: transform_feedback_target.hpp:27
ObjectZero< ObjZeroOps< tag::ImplicitSel, tag::TransformFeedback > > DefaultTransformFeedback
Wrapper for default feedback operations.
Definition: transform_feedback.hpp:383
Helper macro for optional checking of availability of GL function.
Implements operations applicable to any object including object 0 (zero)
Definition: fwd.hpp:157
TransformFeedbackMode enumeration.
static void Pause(void)
Pause the transform feedback mode.
Definition: transform_feedback.hpp:213
TransformFeedbackTarget enumeration.
void Bind(Target target=Target::TransformFeedback) const
Binds this transform feedback to the specified target.
Definition: transform_feedback.hpp:143
Activator(TransformFeedbackPrimitiveType mode)
Begins transform feedback.
Definition: transform_feedback.hpp:257
Exception class for general OpenGL errors.
Definition: basic.hpp:43
Exception class for GL object-related errors.
Definition: object.hpp:24
~Pauser(void)
Resumes transform feedback.
Definition: transform_feedback.hpp:368
static void Resume(void)
Resume the transform feedback mode.
Definition: transform_feedback.hpp:229
TransformFeedbackTarget Target
TransformFeedback bind targets.
Definition: transform_feedback.hpp:82
Implements operations applicable to any object and any operation kind.
Definition: fwd.hpp:151
A common template for "named" objects like textures, buffers, etc.
Definition: fwd.hpp:136

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