Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/OpenGL/OpenGLTextureVolume.h @ 2066:cf3d85eb291c deep-learning
added class OpenGLTextureVolume
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 May 2023 17:18:14 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2065:15f2e52835a1 | 2066:cf3d85eb291c |
---|---|
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 | |
32 namespace OrthancStone | |
33 { | |
34 namespace OpenGL | |
35 { | |
36 class OpenGLTextureVolume : public boost::noncopyable | |
37 { | |
38 friend class OpenGLFramebuffer; | |
39 | |
40 private: | |
41 OpenGL::IOpenGLContext& context_; | |
42 GLuint texture_; | |
43 unsigned int width_; | |
44 unsigned int height_; | |
45 unsigned int depth_; | |
46 Orthanc::PixelFormat format_; | |
47 bool isLinearInterpolation_; | |
48 | |
49 /** | |
50 * Returns the low-level OpenGL handle of the texture | |
51 * array. Beware to never change the size of the texture using | |
52 * this handle! | |
53 **/ | |
54 GLuint GetId() const | |
55 { | |
56 return texture_; | |
57 } | |
58 | |
59 public: | |
60 OpenGLTextureVolume(IOpenGLContext& context); | |
61 | |
62 ~OpenGLTextureVolume(); | |
63 | |
64 unsigned int GetWidth() const | |
65 { | |
66 return width_; | |
67 } | |
68 | |
69 unsigned int GetHeight() const | |
70 { | |
71 return height_; | |
72 } | |
73 | |
74 unsigned int GetDepth() const | |
75 { | |
76 return depth_; | |
77 } | |
78 | |
79 Orthanc::PixelFormat GetFormat() const | |
80 { | |
81 return format_; | |
82 } | |
83 | |
84 bool IsLinearInterpolation() const | |
85 { | |
86 return isLinearInterpolation_; | |
87 } | |
88 | |
89 void Setup(Orthanc::PixelFormat format, | |
90 unsigned int width, | |
91 unsigned int height, | |
92 unsigned int depth, | |
93 bool isLinearInterpolation); | |
94 | |
95 /** | |
96 * By default, textures are mirrored at the borders. This | |
97 * function will set out-of-image access to zero. | |
98 **/ | |
99 void SetClampingToZero(); | |
100 | |
101 void Bind(GLint location) const; | |
102 | |
103 void BindAsTextureUnit(GLint location, | |
104 unsigned int unit) const; | |
105 | |
106 void Upload(const Orthanc::ImageAccessor& image, | |
107 unsigned int z); | |
108 | |
109 size_t GetMemoryBufferSize() const; | |
110 | |
111 // "targetSize" must be equal to "GetMemoryBufferSize()" | |
112 void Download(void* targetBuffer, | |
113 size_t targetSize) const; | |
114 | |
115 void Download(std::string& target) const; | |
116 }; | |
117 } | |
118 } |