vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
Text.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2020 Robert Osfield
6
7Permission 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
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE 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/nodes/Node.h>
16#include <vsg/text/Font.h>
17#include <vsg/text/TextLayout.h>
18#include <vsg/text/TextTechnique.h>
19#include <vsg/utils/ShaderSet.h>
20
21namespace vsg
22{
23
29 class VSG_DECLSPEC Text : public Inherit<Node, Text>
30 {
31 public:
32 template<class N, class V>
33 static void t_traverse(N& node, V& visitor)
34 {
35 if (node.technique) node.technique->accept(visitor);
36 }
37
38 void traverse(Visitor& visitor) override { t_traverse(*this, visitor); }
39 void traverse(ConstVisitor& visitor) const override { t_traverse(*this, visitor); }
40 void traverse(RecordTraversal& visitor) const override { t_traverse(*this, visitor); }
41
42 void read(Input& input) override;
43 void write(Output& output) const override;
44
47 ref_ptr<ShaderSet> shaderSet;
48 ref_ptr<TextTechnique> technique;
50 ref_ptr<Data> text;
51
54 virtual void setup(uint32_t minimumAllocation = 0, ref_ptr<const Options> options = {});
55
56 protected:
57 };
58 VSG_type_name(vsg::Text);
59
61 extern VSG_DECLSPEC ref_ptr<ShaderSet> createTextShaderSet(ref_ptr<const Options> options = {});
62
64 struct VSG_DECLSPEC CountGlyphs : public ConstVisitor
65 {
66 size_t count = 0;
67
68 void apply(const stringValue& text) override;
69 void apply(const wstringValue& text) override;
70 void apply(const ubyteArray& text) override;
71 void apply(const ushortArray& text) override;
72 void apply(const uintArray& text) override;
73 };
74 VSG_type_name(vsg::CountGlyphs);
75
76} // namespace vsg
Definition ConstVisitor.h:172
Definition Inherit.h:28
Definition Input.h:44
Definition Output.h:41
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition RecordTraversal.h:69
Definition Text.h:30
ref_ptr< Font > font
settings
Definition Text.h:46
virtual void setup(uint32_t minimumAllocation=0, ref_ptr< const Options > options={})
Definition Visitor.h:172
Definition ref_ptr.h:22
convenience class for counting the number of text glyphs
Definition Text.h:65