OGLplus (0.52.0) a C++ wrapper for OpenGL

path_spec.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_EXT_NV_PATH_RENDERING_PATH_SPEC_1203031902_HPP
14 #define OGLPLUS_EXT_NV_PATH_RENDERING_PATH_SPEC_1203031902_HPP
15 
16 #if OGLPLUS_DOCUMENTATION_ONLY || GL_NV_path_rendering
17 
19 
20 #include <vector>
21 
22 namespace oglplus {
23 
25 
31 template <typename PathCoordType>
33 {
34 private:
35  friend class ObjectOps<tag::DirectState, tag::PathNV>;
36 
37  std::vector<PathNVCommand> _commands;
38  std::vector<PathCoordType> _coords;
39 
40  typedef PathCoordType T;
41 
42  PathNVSpec& _append(PathNVCommand command)
43  {
44  _commands.push_back(command);
45 
46  return *this;
47  }
48 
49  PathNVSpec& _append(PathNVCommand command, T coord)
50  {
51  _commands.push_back(command);
52  _coords.push_back(coord);
53 
54  return *this;
55  }
56 
57  template <typename ... C>
58  PathNVSpec& _append(PathNVCommand command, C ... coord)
59  {
60  const std::size_t N = sizeof ... (coord);
61  const T coords[N] = { T(coord)... };
62 
63  _commands.push_back(command);
64  _coords.insert(_coords.end(), coords, coords+N);
65 
66  return *this;
67  }
68 public:
70  PathNVSpec(void) { }
71 
73 
76  PathNVSpec(GLuint command_count_hint, GLuint coord_count_hint)
77  {
78  _commands.reserve(command_count_hint);
79  _coords.reserve(coord_count_hint);
80  }
81 
82  PathNVSpec(PathNVSpec&& tmp)
83  : _commands(std::move(tmp._commands))
84  , _coords(std::move(tmp._coords))
85  { }
86 
94  PathNVSpec& Close(void)
97  {
98  return _append(PathNVCommand::Close);
99  }
100 
103  {
104  return _append(PathNVCommand::Restart);
105  }
106 
108  PathNVSpec& MoveTo(T c0, T c1)
109  {
110  return _append(PathNVCommand::MoveTo, c0, c1);
111  }
112 
115  {
116  return _append(PathNVCommand::RelativeMoveTo, c0, c1);
117  }
118 
120  PathNVSpec& LineTo(T c0, T c1)
121  {
122  return _append(PathNVCommand::LineTo, c0, c1);
123  }
124 
127  {
128  return _append(PathNVCommand::RelativeLineTo, c0, c1);
129  }
130 
133  {
134  return _append(PathNVCommand::HorizontalLineTo, c0);
135  }
136 
139  {
140  return _append(PathNVCommand::RelativeHorizontalLineTo, c0);
141  }
142 
145  {
146  return _append(PathNVCommand::VerticalLineTo, c0);
147  }
148 
151  {
152  return _append(PathNVCommand::RelativeVerticalLineTo, c0);
153  }
154 
156  PathNVSpec& QuadraticCurveTo(T c0, T c1, T c2, T c3)
157  {
158  return _append(
160  c0, c1, c2, c3
161  );
162  }
163 
165  PathNVSpec& RelativeQuadraticCurveTo(T c0, T c1, T c2, T c3)
166  {
167  return _append(
169  c0, c1, c2, c3
170  );
171  }
172 
174  PathNVSpec& CubicCurveTo(T c0, T c1, T c2, T c3, T c4, T c5)
175  {
176  return _append(
178  c0, c1, c2, c3, c4, c5
179  );
180  }
181 
183  PathNVSpec& RelativeCubicCurveTo(T c0, T c1, T c2, T c3, T c4, T c5)
184  {
185  return _append(
187  c0, c1, c2, c3, c4, c5
188  );
189  }
190 
193  {
194  return _append(
196  c0, c1
197  );
198  }
199 
202  {
203  return _append(
205  c0, c1
206  );
207  }
208 
210  PathNVSpec& SmoothCubicCurveTo(T c0, T c1, T c2, T c3)
211  {
212  return _append(
214  c0, c1, c2, c3
215  );
216  }
217 
219  PathNVSpec& RelativeSmoothCubicCurveTo(T c0, T c1, T c2, T c3)
220  {
221  return _append(
223  c0, c1, c2, c3
224  );
225  }
226 
228  PathNVSpec& SmallCCWArcTo(T c0, T c1, T c2, T c3, T c4)
229  {
230  return _append(
232  c0, c1, c2, c3, c4
233  );
234  }
235 
237  PathNVSpec& RelativeSmallCCWArcTo(T c0, T c1, T c2, T c3, T c4)
238  {
239  return _append(
241  c0, c1, c2, c3, c4
242  );
243  }
244 
246  PathNVSpec& SmallCWArcTo(T c0, T c1, T c2, T c3, T c4)
247  {
248  return _append(
250  c0, c1, c2, c3, c4
251  );
252  }
253 
255  PathNVSpec& RelativeSmallCWArcTo(T c0, T c1, T c2, T c3, T c4)
256  {
257  return _append(
259  c0, c1, c2, c3, c4
260  );
261  }
262 
264  PathNVSpec& LargeCCWArcTo(T c0, T c1, T c2, T c3, T c4)
265  {
266  return _append(
268  c0, c1, c2, c3, c4
269  );
270  }
271 
273  PathNVSpec& RelativeLargeCCWArcTo(T c0, T c1, T c2, T c3, T c4)
274  {
275  return _append(
277  c0, c1, c2, c3, c4
278  );
279  }
280 
282  PathNVSpec& LargeCWArcTo(T c0, T c1, T c2, T c3, T c4)
283  {
284  return _append(
286  c0, c1, c2, c3, c4
287  );
288  }
289 
291  PathNVSpec& RelativeLargeCWArcTo(T c0, T c1, T c2, T c3, T c4)
292  {
293  return _append(
295  c0, c1, c2, c3, c4
296  );
297  }
298 
300  PathNVSpec& DupFirstCubicCurveTo(T c0, T c1, T c2, T c3)
301  {
302  return _append(
304  c0, c1, c2, c3
305  );
306  }
307 
309  PathNVSpec& DupLastCubicCurveTo(T c0, T c1, T c2, T c3)
310  {
311  return _append(
313  c0, c1, c2, c3
314  );
315  }
316 
318  PathNVSpec& Rect(T c0, T c1, T c2, T c3)
319  {
320  return _append(PathNVCommand::Rect, c0, c1, c2, c3);
321  }
322 
324  PathNVSpec& CircularCCWArcTo(T c0, T c1, T c2, T c3, T c4)
325  {
326  return _append(
328  c0, c1, c2, c3, c4
329  );
330  }
331 
333  PathNVSpec& CircularCWArcTo(T c0, T c1, T c2, T c3, T c4)
334  {
335  return _append(
337  c0, c1, c2, c3, c4
338  );
339  }
340 
342  PathNVSpec& CircularTangentArcTo(T c0, T c1, T c2, T c3, T c4)
343  {
344  return _append(
346  c0, c1, c2, c3, c4
347  );
348  }
349 
351  PathNVSpec& ArcTo(T c0, T c1, T c2, T c3, T c4, T c5, T c6)
352  {
353  return _append(
355  c0, c1, c2, c3, c4, c5, c6
356  );
357  }
358 
360  PathNVSpec& RelativeArcTo(T c0, T c1, T c2, T c3, T c4, T c5, T c6)
361  {
362  return _append(
364  c0, c1, c2, c3, c4, c5, c6
365  );
366  }
368 };
369 
371 
375 template <typename PathCoordType>
377  : public PathNVSpec<PathCoordType>
378 {
379 private:
381  typedef PathCoordType CT;
382 
383  BriefPathNVSpec& self(Base& base)
384  {
385  return static_cast<BriefPathNVSpec&>(base);
386  }
387 public:
388  BriefPathNVSpec(void) { }
389 
390  BriefPathNVSpec(GLuint command_count_hint, GLuint coord_count_hint)
391  : Base(command_count_hint, coord_count_hint)
392  { }
393 
396  {
397  return self(this->Close());
398  }
399 
401  BriefPathNVSpec& M(CT c0, CT c1)
402  {
403  return self(this->MoveTo(c0, c1));
404  }
405 
407  BriefPathNVSpec& m(CT c0, CT c1)
408  {
409  return self(this->RelativeMoveTo(c0, c1));
410  }
411 
413  BriefPathNVSpec& L(CT c0, CT c1)
414  {
415  return self(this->LineTo(c0, c1));
416  }
417 
419  BriefPathNVSpec& l(CT c0, CT c1)
420  {
421  return self(this->RelativeLineTo(c0, c1));
422  }
423 
426  {
427  return self(this->HorizontalLineTo(c0));
428  }
429 
432  {
433  return self(this->RelativeHorizontalLineTo(c0));
434  }
435 
438  {
439  return self(this->VerticalLineTo(c0));
440  }
441 
444  {
445  return self(this->RelativeVerticalLineTo(c0));
446  }
447 
449  BriefPathNVSpec& Q(CT c0, CT c1, CT c2, CT c3)
450  {
451  return self(this->QuadraticCurveTo(c0, c1, c2, c3));
452  }
453 
455  BriefPathNVSpec& q(CT c0, CT c1, CT c2, CT c3)
456  {
457  return self(this->RelativeQuadraticCurveTo(c0, c1, c2, c3));
458  }
459 
461  BriefPathNVSpec& C(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5)
462  {
463  return self(this->CubicCurveTo(c0, c1, c2, c3, c4, c5));
464  }
465 
467  BriefPathNVSpec& c(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5)
468  {
469  return self(this->RelativeCubicCurveTo(c0, c1, c2, c3, c4, c5));
470  }
471 
473  BriefPathNVSpec& T(CT c0, CT c1)
474  {
475  return self(this->SmoothQuadraticCurveTo(c0, c1));
476  }
477 
479  BriefPathNVSpec& t(CT c0, CT c1)
480  {
481  return self(this->RelativeSmoothQuadraticCurveTo(c0, c1));
482  }
483 
485  BriefPathNVSpec& S(CT c0, CT c1, CT c2, CT c3)
486  {
487  return self(this->SmoothCubicCurveTo(c0, c1, c2, c3));
488  }
489 
491  BriefPathNVSpec& s(CT c0, CT c1, CT c2, CT c3)
492  {
493  return self(this->RelativeSmoothCubicCurveTo(c0, c1, c2, c3));
494  }
495 
497  BriefPathNVSpec& A(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5, CT c6)
498  {
499  return self(this->ArcTo(c0, c1, c2, c3, c4, c5, c6));
500  }
501 
503  BriefPathNVSpec& a(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5, CT c6)
504  {
505  return self(this->RelativeArcTo(c0, c1, c2, c3, c4, c5, c6));
506  }
507 };
508 
509 } // namespace oglplus
510 
511 #endif // NV_path_rendering
512 
513 #endif // include guard
BriefPathNVSpec & L(CT c0, CT c1)
LineTo.
Definition: path_spec.hpp:413
PathNVSpec & RelativeSmoothCubicCurveTo(T c0, T c1, T c2, T c3)
Draw a smooth cubic curve with specified relative control points.
Definition: path_spec.hpp:219
PathNVSpec & CubicCurveTo(T c0, T c1, T c2, T c3, T c4, T c5)
Draw a cubic curve with the specified absolute control points.
Definition: path_spec.hpp:174
PathNVSpec & LargeCCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a large-sweep CCW elliptical arc with absolute parameters.
Definition: path_spec.hpp:264
BriefPathNVSpec & c(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5)
RelativeCubicCurveTo.
Definition: path_spec.hpp:467
PathNVCommand
Path specification command enumeration.
Definition: command.hpp:27
PathNVSpec & RelativeQuadraticCurveTo(T c0, T c1, T c2, T c3)
Draw a quadratic curve with the specified relative control points.
Definition: path_spec.hpp:165
BriefPathNVSpec & A(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5, CT c6)
ArcTo.
Definition: path_spec.hpp:497
PathNVSpec & RelativeSmoothQuadraticCurveTo(T c0, T c1)
Draw a smooth quadratic curve with specified relative control points.
Definition: path_spec.hpp:201
RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV.
PathNVSpec & MoveTo(T c0, T c1)
Move to absolute coordinates.
Definition: path_spec.hpp:108
BriefPathNVSpec & C(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5)
CubicCurveTo.
Definition: path_spec.hpp:461
PathNVSpec & RelativeCubicCurveTo(T c0, T c1, T c2, T c3, T c4, T c5)
Draw a cubic curve with the specified relative control points.
Definition: path_spec.hpp:183
RELATIVE_HORIZONTAL_LINE_TO_NV.
PathNVSpec & CircularCCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a circular CCW arc with the specified absolute coordinates.
Definition: path_spec.hpp:324
BriefPathNVSpec & s(CT c0, CT c1, CT c2, CT c3)
RelativeSmoothCubicCurveTo.
Definition: path_spec.hpp:491
BriefPathNVSpec & q(CT c0, CT c1, CT c2, CT c3)
RelativeQuadraticCurveTo.
Definition: path_spec.hpp:455
PathNVSpec & RelativeLineTo(T c0, T c1)
Draw a line in the specified direction.
Definition: path_spec.hpp:126
PathNVSpec & DupLastCubicCurveTo(T c0, T c1, T c2, T c3)
Draw a cubic curve segment duplicating last control point.
Definition: path_spec.hpp:309
PathNVSpec & VerticalLineTo(T c0)
Draw a vertical line to the specified horizontal coordinate.
Definition: path_spec.hpp:144
PathNVSpec(void)
Creates an empty path specification.
Definition: path_spec.hpp:70
BriefPathNVSpec & T(CT c0, CT c1)
SmoothQuadraticCurveTo.
Definition: path_spec.hpp:473
PathNVSpec(GLuint command_count_hint, GLuint coord_count_hint)
Creates an empty path specification with storage size hints.
Definition: path_spec.hpp:76
PathNVSpec & CircularCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a circular CW arc with the specified absolute coordinates.
Definition: path_spec.hpp:333
PathNVSpec & SmallCCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a small-sweep CCW elliptical arc with absolute parameters.
Definition: path_spec.hpp:228
Implements operations applicable to named (non-zero) objects.
Definition: wrap_tpl.hpp:45
PathNVSpec & Rect(T c0, T c1, T c2, T c3)
Draw a rectangle with the specified absolute coordinates.
Definition: path_spec.hpp:318
BriefPathNVSpec & S(CT c0, CT c1, CT c2, CT c3)
SmoothCubicCurveTo.
Definition: path_spec.hpp:485
BriefPathNVSpec & t(CT c0, CT c1)
RelativeSmoothQuadraticCurveTo.
Definition: path_spec.hpp:479
BriefPathNVSpec & a(CT c0, CT c1, CT c2, CT c3, CT c4, CT c5, CT c6)
RelativeArcTo.
Definition: path_spec.hpp:503
PathNVSpec & HorizontalLineTo(T c0)
Draw a horizontal line to the specified vertical coordinate.
Definition: path_spec.hpp:132
PathNVSpec & RelativeSmallCCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a small-sweep CCW elliptical arc with relative parameters.
Definition: path_spec.hpp:237
PathNVSpec & RelativeLargeCCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a large-sweep CCW elliptical arc with relative parameters.
Definition: path_spec.hpp:273
PathNVSpec & SmallCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a small-sweep CW elliptical arc with absolute parameters.
Definition: path_spec.hpp:246
PathNVSpec & RelativeArcTo(T c0, T c1, T c2, T c3, T c4, T c5, T c6)
Draw a general elliptical arc with specified relative coordinates.
Definition: path_spec.hpp:360
BriefPathNVSpec & Q(CT c0, CT c1, CT c2, CT c3)
QuadraticCurveTo.
Definition: path_spec.hpp:449
Template class for convenient specifying of path commands and coordinates.
Definition: path_spec.hpp:32
Wrapper for the NV_path_rendering command enumeration.
BriefPathNVSpec & l(CT c0, CT c1)
RelativeLineTo.
Definition: path_spec.hpp:419
BriefPathNVSpec & m(CT c0, CT c1)
RelativeMoveTo.
Definition: path_spec.hpp:407
BriefPathNVSpec & H(CT c0)
HorizontalLineTo.
Definition: path_spec.hpp:425
RELATIVE_SMALL_CCW_ARC_TO_NV.
BriefPathNVSpec & h(CT c0)
RelativeHorizontalLineTo.
Definition: path_spec.hpp:431
PathNVSpec & RelativeVerticalLineTo(T c0)
Draw a vertical line in the specified direction.
Definition: path_spec.hpp:150
RELATIVE_QUADRATIC_CURVE_TO_NV.
PathNVSpec & SmoothCubicCurveTo(T c0, T c1, T c2, T c3)
Draw a smooth cubic curve with specified absolute control points.
Definition: path_spec.hpp:210
PathNVSpec & RelativeSmallCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a small-sweep CW elliptical arc with relative parameters.
Definition: path_spec.hpp:255
PathNVSpec & RelativeMoveTo(T c0, T c1)
Move by specified amount.
Definition: path_spec.hpp:114
PathNVSpec & RelativeHorizontalLineTo(T c0)
Draw a horizontal line in the specified direction.
Definition: path_spec.hpp:138
PathNVSpec & LargeCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a large-sweep CW elliptical arc with absolute parameters.
Definition: path_spec.hpp:282
RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV.
BriefPathNVSpec & v(CT c0)
RelativeVerticalLineTo.
Definition: path_spec.hpp:443
PathNVSpec & LineTo(T c0, T c1)
Draw a line to absolute coordinates.
Definition: path_spec.hpp:120
PathNVSpec & QuadraticCurveTo(T c0, T c1, T c2, T c3)
Draw a quadratic curve with the specified absolute control points.
Definition: path_spec.hpp:156
RELATIVE_LARGE_CCW_ARC_TO_NV.
PathNVSpec & RelativeLargeCWArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a large-sweep CW elliptical arc with relative parameters.
Definition: path_spec.hpp:291
PathNVSpec & DupFirstCubicCurveTo(T c0, T c1, T c2, T c3)
Draw a cubic curve segment duplicating first control point.
Definition: path_spec.hpp:300
PathNVSpec & CircularTangentArcTo(T c0, T c1, T c2, T c3, T c4)
Draw a circular tangential arc with specified absolute coordinates.
Definition: path_spec.hpp:342
PathNVSpec & Close(void)
Definition: path_spec.hpp:96
PathNVSpec & SmoothQuadraticCurveTo(T c0, T c1)
Draw a smooth quadratic curve with specified absolute control points.
Definition: path_spec.hpp:192
PathNVSpec & Restart(void)
Restart path.
Definition: path_spec.hpp:102
Object< PathNVOps > PathNV
An oglplus_object encapsulating the nVidia path functionality.
Definition: path.hpp:1019
Facade over PathNVSpec for even more convenient path specification.
Definition: path_spec.hpp:376
BriefPathNVSpec & V(CT c0)
VerticalLineTo.
Definition: path_spec.hpp:437
PathNVSpec & ArcTo(T c0, T c1, T c2, T c3, T c4, T c5, T c6)
Draw a general elliptical arc with specified absolute coordinates.
Definition: path_spec.hpp:351
BriefPathNVSpec & Z(void)
Close.
Definition: path_spec.hpp:395
BriefPathNVSpec & M(CT c0, CT c1)
MoveTo.
Definition: path_spec.hpp:401

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