Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/OpenGL/OpenGLTexture.cpp @ 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 | c0627145b441 |
children | 6ea5f40ea0e9 |
comparison
equal
deleted
inserted
replaced
2059:f7cbc58ff44d | 2060:86e0e92a2e0d |
---|---|
20 * <http://www.gnu.org/licenses/>. | 20 * <http://www.gnu.org/licenses/>. |
21 **/ | 21 **/ |
22 | 22 |
23 | 23 |
24 #include "OpenGLTexture.h" | 24 #include "OpenGLTexture.h" |
25 #include "IOpenGLContext.h" | |
26 | |
27 #include <Images/Image.h> | |
28 #include <Logging.h> | |
29 #include <OrthancException.h> | |
30 | 25 |
31 #if defined(__EMSCRIPTEN__) | 26 #if defined(__EMSCRIPTEN__) |
32 # if !defined(ORTHANC_WEBGL2_HEAP_COMPAT) | 27 # if !defined(ORTHANC_WEBGL2_HEAP_COMPAT) |
33 # error The macro ORTHANC_WEBGL2_HEAP_COMPAT must be defined | 28 # error The macro ORTHANC_WEBGL2_HEAP_COMPAT must be defined |
34 # endif | 29 # endif |
35 #endif | 30 #endif |
31 | |
32 #include <Images/Image.h> | |
33 #include <Logging.h> | |
34 #include <OrthancException.h> | |
36 | 35 |
37 namespace OrthancStone | 36 namespace OrthancStone |
38 { | 37 { |
39 namespace OpenGL | 38 namespace OpenGL |
40 { | 39 { |
41 OpenGLTexture::OpenGLTexture(OpenGL::IOpenGLContext& context) : | 40 OpenGLTexture::OpenGLTexture(OpenGL::IOpenGLContext& context) : |
41 context_(context), | |
42 texture_(0), | 42 texture_(0), |
43 width_(0), | 43 width_(0), |
44 height_(0), | 44 height_(0), |
45 format_(Orthanc::PixelFormat_Grayscale8), | 45 format_(Orthanc::PixelFormat_Grayscale8), |
46 context_(context), | |
47 isLinearInterpolation_(false) | 46 isLinearInterpolation_(false) |
48 { | 47 { |
49 if (!context_.IsContextLost()) | 48 if (!context_.IsContextLost()) |
50 { | 49 { |
51 // Generate a texture object | 50 // Generate a texture object |
273 } | 272 } |
274 | 273 |
275 | 274 |
276 void OpenGLTexture::SetClampingToZero() | 275 void OpenGLTexture::SetClampingToZero() |
277 { | 276 { |
278 ORTHANC_OPENGL_CHECK("Entering OpenGLTexture::SetClampingToZero()"); | |
279 | |
280 #if defined(__EMSCRIPTEN__) | 277 #if defined(__EMSCRIPTEN__) |
281 /** | 278 /** |
282 * This is because WebGL 2 derives from OpenGL ES 3.0, which | 279 * This is because WebGL 2 derives from OpenGL ES 3.0, which |
283 * doesn't support GL_CLAMP_TO_BORDER, as can be seen here: | 280 * doesn't support GL_CLAMP_TO_BORDER, as can be seen here: |
284 * https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexParameter.xhtml | 281 * https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexParameter.xhtml |
285 **/ | 282 **/ |
286 LOG(WARNING) << "OpenGLTexture::SetClampingToZero() is not available in WebGL 2"; | 283 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
284 "OpenGLTextureArray::SetClampingToZero() is not available in WebGL 2"); | |
287 #else | 285 #else |
286 ORTHANC_OPENGL_CHECK("Entering OpenGLTexture::SetClampingToZero()"); | |
287 | |
288 glBindTexture(GL_TEXTURE_2D, texture_); | 288 glBindTexture(GL_TEXTURE_2D, texture_); |
289 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); | 289 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); |
290 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); | 290 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); |
291 | 291 |
292 GLfloat colorfv[4] = { 0, 0, 0, 0 }; | 292 GLfloat colorfv[4] = { 0, 0, 0, 0 }; |
293 glTextureParameterfv(texture_, GL_TEXTURE_BORDER_COLOR, colorfv); | 293 glTextureParameterfv(texture_, GL_TEXTURE_BORDER_COLOR, colorfv); |
294 #endif | 294 |
295 | |
296 ORTHANC_OPENGL_CHECK("Exiting OpenGLTexture::SetClampingToZero()"); | 295 ORTHANC_OPENGL_CHECK("Exiting OpenGLTexture::SetClampingToZero()"); |
296 #endif | |
297 } | 297 } |
298 | 298 |
299 | 299 |
300 void OpenGLTexture::ConvertToOpenGLFormats(GLenum& sourceFormat, | 300 void OpenGLTexture::ConvertToOpenGLFormats(GLenum& sourceFormat, |
301 GLenum& internalFormat, | 301 GLenum& internalFormat, |