annotate OrthancStone/Sources/OpenGL/OpenGLTextureArray.h @ 2068:22a83fb9dd23 deep-learning

added AlignedMatrix and TimerLogger
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 May 2023 17:30:52 +0200
parents 15f2e52835a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2060
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "OpenGLIncludes.h"
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "IOpenGLContext.h"
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <Images/ImageAccessor.h>
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace OpenGL
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class OpenGLTextureArray : public boost::noncopyable
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 friend class OpenGLFramebuffer;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 private:
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 OpenGL::IOpenGLContext& context_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 GLuint texture_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 unsigned int width_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 unsigned int height_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 unsigned int depth_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 Orthanc::PixelFormat format_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 bool isLinearInterpolation_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 /**
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 * Returns the low-level OpenGL handle of the texture
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 * array. Beware to never change the size of the texture using
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 * this handle!
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 **/
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 GLuint GetId() const
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 return texture_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 public:
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 OpenGLTextureArray(IOpenGLContext& context);
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ~OpenGLTextureArray();
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 unsigned int GetWidth() const
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 return width_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 unsigned int GetHeight() const
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 return height_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 unsigned int GetDepth() const
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 return depth_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 Orthanc::PixelFormat GetFormat() const
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 return format_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 bool IsLinearInterpolation() const
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 return isLinearInterpolation_;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 void Setup(Orthanc::PixelFormat format,
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 unsigned int width,
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 unsigned int height,
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 unsigned int depth,
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 bool isLinearInterpolation);
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 /**
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 * By default, textures are mirrored at the borders. This
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 * function will set out-of-image access to zero.
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 **/
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 void SetClampingToZero();
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 void Bind(GLint location) const;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 void BindAsTextureUnit(GLint location,
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 unsigned int unit) const;
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 void Upload(const Orthanc::ImageAccessor& image,
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 unsigned int layer);
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
2065
15f2e52835a1 removed OpenGLTextureArray::DownloadedArray()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2063
diff changeset
108 size_t GetMemoryBufferSize() const;
2060
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
2065
15f2e52835a1 removed OpenGLTextureArray::DownloadedArray()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2063
diff changeset
110 // "targetSize" must be equal to "GetMemoryBufferSize()"
15f2e52835a1 removed OpenGLTextureArray::DownloadedArray()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2063
diff changeset
111 void Download(void* targetBuffer,
15f2e52835a1 removed OpenGLTextureArray::DownloadedArray()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2063
diff changeset
112 size_t targetSize) const;
2060
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
2065
15f2e52835a1 removed OpenGLTextureArray::DownloadedArray()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2063
diff changeset
114 void Download(std::string& target) const;
2060
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 };
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }
86e0e92a2e0d added OpenGLTextureArray and OpenGLFramebuffer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }