annotate OrthancStone/Sources/OpenGL/OpenGLTexture.cpp @ 1624:59f95b9ea858

fix build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Nov 2020 17:30:36 +0100
parents 8563ea5d8ae4
children 9ac2a65d4172
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1045
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1564
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * <http://www.gnu.org/licenses/>.
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "OpenGLTexture.h"
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
24 #include "IOpenGLContext.h"
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
1624
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
26 #include <Logging.h>
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
27 #include <OrthancException.h>
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OpenGL
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
33 OpenGLTexture::OpenGLTexture(OpenGL::IOpenGLContext& context)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
34 : width_(0)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
35 , height_(0)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
36 , context_(context)
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
38 if (!context_.IsContextLost())
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
40 // Generate a texture object
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
41 glGenTextures(1, &texture_);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
42 if (texture_ == 0)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
43 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
44 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
45 "Cannot create an OpenGL program");
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
46 }
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 OpenGLTexture::~OpenGLTexture()
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
52 try
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
53 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
54 if (!context_.IsContextLost())
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
55 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
56 assert(texture_ != 0);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
57 ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT("About to call glDeleteTextures");
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
58 glDeleteTextures(1, &texture_);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
59 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
60 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
61 catch (const Orthanc::OrthancException& e)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
62 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
63 if (e.HasDetails())
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
64 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
65 LOG(ERROR) << "OrthancException in ~OpenGLTexture: " << e.What() << " Details: " << e.GetDetails();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
66 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
67 else
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
68 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
69 LOG(ERROR) << "OrthancException in ~OpenGLTexture: " << e.What();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
70 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
71 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
72 catch (const std::exception& e)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
73 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
74 LOG(ERROR) << "std::exception in ~OpenGLTexture: " << e.what();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
75 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
76 catch (...)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
77 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
78 LOG(ERROR) << "Unknown exception in ~OpenGLTexture";
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
79 }
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 void OpenGLTexture::Load(const Orthanc::ImageAccessor& image,
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 bool isLinearInterpolation)
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
85 if (!context_.IsContextLost())
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
87 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Disable byte-alignment restriction
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
89 if (image.GetPitch() != image.GetBytesPerPixel() * image.GetWidth())
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
90 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
91 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented,
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
92 "Unsupported non-zero padding");
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
93 }
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
95 // Bind it
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
96 glActiveTexture(GL_TEXTURE0);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
97 glBindTexture(GL_TEXTURE_2D, texture_);
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
99 GLenum sourceFormat, internalFormat;
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
100
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
101 switch (image.GetFormat())
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
102 {
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 case Orthanc::PixelFormat_Grayscale8:
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 sourceFormat = GL_RED;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 internalFormat = GL_RED;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 break;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 case Orthanc::PixelFormat_RGB24:
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 sourceFormat = GL_RGB;
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 579
diff changeset
110 internalFormat = GL_RGB;
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 break;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 case Orthanc::PixelFormat_RGBA32:
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 sourceFormat = GL_RGBA;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 internalFormat = GL_RGBA;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 break;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 default:
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented,
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
120 "No support for this format in OpenGL textures: " +
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
121 std::string(EnumerationToString(image.GetFormat())));
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
122 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
123
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
124 width_ = image.GetWidth();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
125 height_ = image.GetHeight();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
126
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
127 GLint interpolation = (isLinearInterpolation ? GL_LINEAR : GL_NEAREST);
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
129 // Load the texture from the image buffer
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
130 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, image.GetWidth(), image.GetHeight(),
1564
e731e62692a9 upgrading Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
131 0, sourceFormat, GL_UNSIGNED_BYTE, image.GetConstBuffer());
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
132 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, interpolation);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
133 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, interpolation);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
134 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
135 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 616
diff changeset
136 }
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 void OpenGLTexture::Bind(GLint location)
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 glActiveTexture(GL_TEXTURE0);
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 glBindTexture(GL_TEXTURE_2D, texture_);
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 glUniform1i(location, 0 /* texture unit */);
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }