comparison OrthancStone/Sources/OpenGL/OpenGLTextureArray.h @ 2060:86e0e92a2e0d deep-learning

added OpenGLTextureArray and OpenGLFramebuffer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 May 2023 16:15:50 +0200
parents
children b6b5e1ca1cc2
comparison
equal deleted inserted replaced
2059:f7cbc58ff44d 2060:86e0e92a2e0d
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-2022 Osimis S.A., Belgium
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
7 *
8 * This program is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 **/
22
23
24 #pragma once
25
26 #include "OpenGLIncludes.h"
27 #include "IOpenGLContext.h"
28
29 #include <Images/ImageAccessor.h>
30
31 namespace OrthancStone
32 {
33 namespace OpenGL
34 {
35 class OpenGLTextureArray : public boost::noncopyable
36 {
37 friend class OpenGLFramebuffer;
38
39 private:
40 OpenGL::IOpenGLContext& context_;
41 GLuint texture_;
42 unsigned int width_;
43 unsigned int height_;
44 unsigned int depth_;
45 Orthanc::PixelFormat format_;
46 bool isLinearInterpolation_;
47
48 /**
49 * Returns the low-level OpenGL handle of the texture
50 * array. Beware to never change the size of the texture using
51 * this handle!
52 **/
53 GLuint GetId() const
54 {
55 return texture_;
56 }
57
58 public:
59 OpenGLTextureArray(IOpenGLContext& context);
60
61 ~OpenGLTextureArray();
62
63 unsigned int GetWidth() const
64 {
65 return width_;
66 }
67
68 unsigned int GetHeight() const
69 {
70 return height_;
71 }
72
73 unsigned int GetDepth() const
74 {
75 return depth_;
76 }
77
78 Orthanc::PixelFormat GetFormat() const
79 {
80 return format_;
81 }
82
83 bool IsLinearInterpolation() const
84 {
85 return isLinearInterpolation_;
86 }
87
88 void Setup(Orthanc::PixelFormat format,
89 unsigned int width,
90 unsigned int height,
91 unsigned int depth,
92 bool isLinearInterpolation);
93
94 /**
95 * By default, textures are mirrored at the borders. This
96 * function will set out-of-image access to zero.
97 **/
98 void SetClampingToZero();
99
100 void Bind(GLint location) const;
101
102 void BindAsTextureUnit(GLint location,
103 unsigned int unit) const;
104
105 void Upload(const Orthanc::ImageAccessor& image,
106 unsigned int layer);
107
108 class DownloadedVolume : public boost::noncopyable
109 {
110 private:
111 std::string buffer_;
112 Orthanc::PixelFormat format_;
113 unsigned int width_;
114 unsigned int height_;
115 unsigned int depth_;
116
117 public:
118 DownloadedVolume(const OpenGLTextureArray& texture);
119
120 Orthanc::PixelFormat GetFormat() const
121 {
122 return format_;
123 }
124
125 unsigned int GetWidth() const
126 {
127 return width_;
128 }
129
130 unsigned int GetHeight() const
131 {
132 return height_;
133 }
134
135 unsigned int GetDepth() const
136 {
137 return depth_;
138 }
139
140 Orthanc::ImageAccessor* GetLayer(unsigned int layer) const;
141 };
142 };
143 }
144 }