comparison OrthancStone/Sources/Scene2D/Internals/OpenGLTextProgram.h @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Scene2D/Internals/OpenGLTextProgram.h@30deba7bc8e2
children 85e117739eca
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
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-2020 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 "../../Fonts/GlyphTextureAlphabet.h"
25 #include "../../OpenGL/IOpenGLContext.h"
26 #include "../../OpenGL/OpenGLProgram.h"
27 #include "../../OpenGL/OpenGLTexture.h"
28 #include "../../Toolbox/AffineTransform2D.h"
29 #include "../TextSceneLayer.h"
30
31 #include <Compatibility.h>
32
33 namespace OrthancStone
34 {
35 namespace Internals
36 {
37 class OpenGLTextProgram : public boost::noncopyable
38 {
39 public:
40 class Data : public boost::noncopyable
41 {
42 private:
43 OpenGL::IOpenGLContext& context_;
44 size_t coordinatesCount_;
45 GLuint buffers_[2];
46 float red_;
47 float green_;
48 float blue_;
49 double x_;
50 double y_;
51 double border_;
52 unsigned int textWidth_;
53 unsigned int textHeight_;
54 BitmapAnchor anchor_;
55
56 public:
57 Data(OpenGL::IOpenGLContext& context,
58 const GlyphTextureAlphabet& alphabet,
59 const TextSceneLayer& layer);
60
61 ~Data();
62
63 bool IsEmpty() const
64 {
65 return coordinatesCount_ == 0;
66 }
67
68 size_t GetCoordinatesCount() const
69 {
70 return coordinatesCount_;
71 }
72
73 GLuint GetSceneLocationsBuffer() const;
74
75 GLuint GetTextureLocationsBuffer() const;
76
77 float GetRed() const
78 {
79 return red_;
80 }
81
82 float GetGreen() const
83 {
84 return green_;
85 }
86
87 float GetBlue() const
88 {
89 return blue_;
90 }
91
92 double GetX() const
93 {
94 return x_;
95 }
96
97 double GetY() const
98 {
99 return y_;
100 }
101
102 double GetBorder() const
103 {
104 return border_;
105 }
106
107 unsigned int GetTextWidth() const
108 {
109 return textWidth_;
110 }
111
112 unsigned int GetTextHeight() const
113 {
114 return textHeight_;
115 }
116
117 BitmapAnchor GetAnchor() const
118 {
119 return anchor_;
120 }
121 };
122
123 private:
124 OpenGL::IOpenGLContext& context_;
125 std::unique_ptr<OpenGL::OpenGLProgram> program_;
126 GLint positionLocation_;
127 GLint textureLocation_;
128
129 public:
130 OpenGLTextProgram(OpenGL::IOpenGLContext& context);
131
132 void Apply(OpenGL::OpenGLTexture& fontTexture,
133 const Data& data,
134 const AffineTransform2D& transform);
135 };
136 }
137 }