1 /**
2  * Copyright:       Copyright (C) 2018 Gabriel Gheorghe, All Rights Reserved
3  * Authors:         $(Gabriel Gheorghe)
4  * License:         $(LINK2 https://www.gnu.org/licenses/gpl-3.0.txt, GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007)
5  * Source:          $(LINK2 https://github.com/GabyForceQ/LibertyEngine/blob/master/source/liberty/text/renderer.d)
6  * Documentation:
7  * Coverage:
8 **/
9 module liberty.text.renderer;
10 
11 import liberty.scene.impl;
12 import liberty.scene.services;
13 import liberty.text.impl;
14 import liberty.text.shader;
15 import liberty.text.system;
16 
17 /**
18  * Class holding basic text rendering methods.
19  * It contains references to the $(D TextSystem) and $(D Scene).
20  * It implements $(D IRenderable) service.
21 **/
22 final class TextRenderer : IRenderable {
23   private {
24     TextSystem system;
25     Scene scene;
26   }
27 
28   /**
29    * Create and initialize text renderer using a $(D TextSystem) reference and a $(D Scene) reference.
30   **/
31   this(TextSystem system, Scene scene) {
32     this.system = system;
33     this.scene = scene;
34   }
35 
36   /**
37    * Render all text elements to the screen.
38   **/
39   void render(Scene scene) {
40     //system
41     //  .getShader()
42     //  .bind();
43     
44     foreach (text; system.getMap())
45       //if (text.visibility() == Visibility.Visible)
46         render(text);
47 
48     //system
49     //  .getShader()
50     //  .unbind();
51   }
52 
53   /**
54    * Render a text entity by its reference.
55    * Returns reference to this so it can be used in a stream.
56   **/
57   typeof(this) render(Text text) {
58     
59     return this;
60   }
61 }