comparison Framework/OpenGL/TextOpenGLProgram.h @ 585:b9ce24c606ae

TextSceneLayer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Apr 2019 17:57:58 +0200
parents
children
comparison
equal deleted inserted replaced
584:434ceeb0bcab 585:b9ce24c606ae
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #pragma once
23
24 #include "IOpenGLContext.h"
25 #include "OpenGLProgram.h"
26 #include "OpenGLTexture.h"
27
28 #include "../Fonts/GlyphTextureAlphabet.h"
29 #include "../Scene2D/TextSceneLayer.h"
30 #include "../Toolbox/AffineTransform2D.h"
31
32 namespace OrthancStone
33 {
34 namespace OpenGL
35 {
36 class TextOpenGLProgram : public boost::noncopyable
37 {
38 public:
39 class Data : public boost::noncopyable
40 {
41 private:
42 IOpenGLContext& context_;
43 size_t coordinatesCount_;
44 GLuint buffers_[2];
45 float red_;
46 float green_;
47 float blue_;
48 double x_;
49 double y_;
50 double border_;
51 unsigned int textWidth_;
52 unsigned int textHeight_;
53 BitmapAnchor anchor_;
54
55 public:
56 Data(IOpenGLContext& context,
57 const GlyphTextureAlphabet& alphabet,
58 const TextSceneLayer& layer);
59
60 ~Data();
61
62 bool IsEmpty() const
63 {
64 return coordinatesCount_ == 0;
65 }
66
67 size_t GetCoordinatesCount() const
68 {
69 return coordinatesCount_;
70 }
71
72 GLuint GetSceneLocationsBuffer() const;
73
74 GLuint GetTextureLocationsBuffer() const;
75
76 float GetRed() const
77 {
78 return red_;
79 }
80
81 float GetGreen() const
82 {
83 return green_;
84 }
85
86 float GetBlue() const
87 {
88 return blue_;
89 }
90
91 double GetX() const
92 {
93 return x_;
94 }
95
96 double GetY() const
97 {
98 return y_;
99 }
100
101 double GetBorder() const
102 {
103 return border_;
104 }
105
106 unsigned int GetTextWidth() const
107 {
108 return textWidth_;
109 }
110
111 unsigned int GetTextHeight() const
112 {
113 return textHeight_;
114 }
115
116 BitmapAnchor GetAnchor() const
117 {
118 return anchor_;
119 }
120 };
121
122 private:
123 static const unsigned int COMPONENTS = 2;
124
125 IOpenGLContext& context_;
126 std::auto_ptr<OpenGLProgram> program_;
127 GLint positionLocation_;
128 GLint textureLocation_;
129
130 public:
131 TextOpenGLProgram(IOpenGLContext& context);
132
133 void Apply(OpenGLTexture& fontTexture,
134 const Data& data,
135 const AffineTransform2D& transform);
136 };
137 }
138 }