Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/Internals/OpenGLTextProgram.h @ 1810:b05d5f0d014f
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 20 May 2021 19:11:44 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
592 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
592 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
592 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
592 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "../../Fonts/GlyphTextureAlphabet.h" | |
26 #include "../../OpenGL/IOpenGLContext.h" | |
27 #include "../../OpenGL/OpenGLProgram.h" | |
28 #include "../../OpenGL/OpenGLTexture.h" | |
29 #include "../../Toolbox/AffineTransform2D.h" | |
30 #include "../TextSceneLayer.h" | |
31 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1301
diff
changeset
|
32 #include <Compatibility.h> |
1301 | 33 |
592 | 34 namespace OrthancStone |
35 { | |
36 namespace Internals | |
37 { | |
38 class OpenGLTextProgram : public boost::noncopyable | |
39 { | |
40 public: | |
41 class Data : public boost::noncopyable | |
42 { | |
43 private: | |
44 OpenGL::IOpenGLContext& context_; | |
45 size_t coordinatesCount_; | |
46 GLuint buffers_[2]; | |
47 float red_; | |
48 float green_; | |
49 float blue_; | |
50 double x_; | |
51 double y_; | |
52 double border_; | |
53 unsigned int textWidth_; | |
54 unsigned int textHeight_; | |
55 BitmapAnchor anchor_; | |
56 | |
57 public: | |
58 Data(OpenGL::IOpenGLContext& context, | |
59 const GlyphTextureAlphabet& alphabet, | |
60 const TextSceneLayer& layer); | |
61 | |
62 ~Data(); | |
63 | |
64 bool IsEmpty() const | |
65 { | |
66 return coordinatesCount_ == 0; | |
67 } | |
68 | |
69 size_t GetCoordinatesCount() const | |
70 { | |
71 return coordinatesCount_; | |
72 } | |
73 | |
74 GLuint GetSceneLocationsBuffer() const; | |
75 | |
76 GLuint GetTextureLocationsBuffer() const; | |
77 | |
78 float GetRed() const | |
79 { | |
80 return red_; | |
81 } | |
82 | |
83 float GetGreen() const | |
84 { | |
85 return green_; | |
86 } | |
87 | |
88 float GetBlue() const | |
89 { | |
90 return blue_; | |
91 } | |
92 | |
93 double GetX() const | |
94 { | |
95 return x_; | |
96 } | |
97 | |
98 double GetY() const | |
99 { | |
100 return y_; | |
101 } | |
102 | |
103 double GetBorder() const | |
104 { | |
105 return border_; | |
106 } | |
107 | |
108 unsigned int GetTextWidth() const | |
109 { | |
110 return textWidth_; | |
111 } | |
112 | |
113 unsigned int GetTextHeight() const | |
114 { | |
115 return textHeight_; | |
116 } | |
117 | |
118 BitmapAnchor GetAnchor() const | |
119 { | |
120 return anchor_; | |
121 } | |
122 }; | |
123 | |
124 private: | |
1571 | 125 OpenGL::IOpenGLContext& context_; |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
126 std::unique_ptr<OpenGL::OpenGLProgram> program_; |
1571 | 127 GLint positionLocation_; |
128 GLint textureLocation_; | |
592 | 129 |
130 public: | |
1571 | 131 explicit OpenGLTextProgram(OpenGL::IOpenGLContext& context); |
592 | 132 |
133 void Apply(OpenGL::OpenGLTexture& fontTexture, | |
134 const Data& data, | |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
135 const AffineTransform2D& transform, |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
136 unsigned int canvasWidth, |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
137 unsigned int canvasHeight); |
592 | 138 }; |
139 } | |
140 } |