annotate Framework/Scene2D/Internals/OpenGLTextProgram.h @ 656:002d9562c8f5

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