vsg  1.1.0
VulkanSceneGraph library
GpuLayoutTechnique.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2020 Robert Osfield
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 
13 </editor-fold> */
14 
15 #include <vsg/commands/BindVertexBuffers.h>
16 #include <vsg/commands/Draw.h>
17 #include <vsg/nodes/StateGroup.h>
18 #include <vsg/state/BindDescriptorSet.h>
19 #include <vsg/state/DescriptorBuffer.h>
20 #include <vsg/text/TextTechnique.h>
21 
22 namespace vsg
23 {
24  struct LayoutStruct
25  {
26  vec3 position = vec3(0.0f, 0.0f, 0.0f);
27  float billboardAutoScaleDistance = 0.0;
28  vec3 horizontal = vec3(1.0f, 0.0f, 0.0f);
29  float horizontalAlignment = 0.0;
30  vec3 vertical = vec3(0.0f, 1.0f, 0.0f);
31  float verticalAlignment = 0.0;
32  vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f);
33  vec4 outlineColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);
34  float outlineWidth = 0.0f;
35  };
36  VSG_value(TextLayoutValue, LayoutStruct);
37 
38  class VSG_DECLSPEC GpuLayoutTechnique : public Inherit<TextTechnique, GpuLayoutTechnique>
39  {
40  public:
41  template<class N, class V>
42  static void t_traverse(N& node, V& visitor)
43  {
44  if (node.scenegraph) node.scenegraph->accept(visitor);
45  }
46 
47  void traverse(Visitor& visitor) override { t_traverse(*this, visitor); }
48  void traverse(ConstVisitor& visitor) const override { t_traverse(*this, visitor); }
49  void traverse(RecordTraversal& visitor) const override { t_traverse(*this, visitor); }
50 
51  void setup(Text* text, uint32_t minimumAllocation = 0, ref_ptr<const Options> options = {}) override;
52  void setup(TextGroup* textGroup, uint32_t minimumAllocation = 0, ref_ptr<const Options> options = {}) override;
53  dbox extents() const override { return textExtents; }
54 
55  // implementation data structure
56  dbox textExtents;
57  ref_ptr<Node> scenegraph;
58 
59  ref_ptr<vec3Array> vertices;
60  ref_ptr<Draw> draw;
61 
62  ref_ptr<uintArray> textArray;
63  ref_ptr<TextLayoutValue> layoutValue;
64  ref_ptr<BindVertexBuffers> bindVertexBuffers;
65  };
66  VSG_type_name(vsg::GpuLayoutTechnique);
67 
68 } // namespace vsg
Definition: ConstVisitor.h:147
Definition: GpuLayoutTechnique.h:39
Definition: Inherit.h:28
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition: RecordTraversal.h:61
Definition: TextGroup.h:27
Definition: Text.h:30
Definition: Visitor.h:147
Definition: ref_ptr.h:22
Definition: GpuLayoutTechnique.h:25