annotate OrthancStone/Sources/OpenGL/OpenGLProgram.cpp @ 2115:de049fd88697 deep-learning

integration mainline->deep-learning
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Jan 2024 16:44:40 +0100
parents fdb012c86a75 c23eef785569
children 2e050ec85379
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
2114
c23eef785569 update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2077
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
c23eef785569 update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2077
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * the License, or (at your option) any later version.
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
17 *
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
18 * 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
19 * 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
20 * <http://www.gnu.org/licenses/>.
579
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
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "OpenGLProgram.h"
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "OpenGLShader.h"
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
27 #include "IOpenGLContext.h"
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
1624
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
29 #include <Logging.h>
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
30 #include <OrthancException.h>
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
1624
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
32 #include <cassert>
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
33
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace OrthancStone
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 namespace OpenGL
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
38 OpenGLProgram::OpenGLProgram(OpenGL::IOpenGLContext& context) :
1639
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
39 context_(context),
5cdc5b98f14d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
40 program_(glCreateProgram())
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
42 ORTHANC_OPENGL_CHECK("glCreateProgram");
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
43
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 if (program_ == 0)
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 "Cannot create an OpenGL program");
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
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 OpenGLProgram::~OpenGLProgram()
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
54 try
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
55 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
56 if (!context_.IsContextLost())
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
57 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
58 ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT("About to call glDeleteProgram");
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
59 assert(program_ != 0);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
60 glDeleteProgram(program_);
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
61 ORTHANC_OPENGL_CHECK("glDeleteProgram");
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
62 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
63 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
64 catch (const Orthanc::OrthancException& e)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
65 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
66 if (e.HasDetails())
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
67 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
68 LOG(ERROR) << "OrthancException in ~OpenGLProgram: " << e.What() << " Details: " << e.GetDetails();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
69 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
70 else
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
71 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
72 LOG(ERROR) << "OrthancException in ~OpenGLProgram: " << e.What();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
73 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
74 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
75 catch (const std::exception& e)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
76 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
77 LOG(ERROR) << "std::exception in ~OpenGLProgram: " << e.what();
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
78 }
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
79 catch (...)
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
80 {
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
81 LOG(ERROR) << "Unknown exception in ~OpenGLProgram";
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
82 }
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
2057
8bb8d9c0cfd0 added "checkStatus" argument to OpenGLProgram::Use()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2041
diff changeset
85 void OpenGLProgram::Use(bool checkStatus)
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: 579
diff changeset
87 //ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT("About to call glUseProgram");
2057
8bb8d9c0cfd0 added "checkStatus" argument to OpenGLProgram::Use()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2041
diff changeset
88 ORTHANC_OPENGL_CHECK("About to call glUseProgram()");
8bb8d9c0cfd0 added "checkStatus" argument to OpenGLProgram::Use()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2041
diff changeset
89
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 glUseProgram(program_);
2057
8bb8d9c0cfd0 added "checkStatus" argument to OpenGLProgram::Use()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2041
diff changeset
91
8bb8d9c0cfd0 added "checkStatus" argument to OpenGLProgram::Use()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2041
diff changeset
92 if (checkStatus &&
8bb8d9c0cfd0 added "checkStatus" argument to OpenGLProgram::Use()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2041
diff changeset
93 glGetError() != GL_NO_ERROR)
2041
85a20cbfcc04 check glUseProgram()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
94 {
85a20cbfcc04 check glUseProgram()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
95 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
85a20cbfcc04 check glUseProgram()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
96 "Cannot use successfully compiled OpenGL shader");
85a20cbfcc04 check glUseProgram()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
97 }
85a20cbfcc04 check glUseProgram()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1871
diff changeset
98
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
99 ORTHANC_OPENGL_CHECK("glUseProgram");
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 }
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
101
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 void OpenGLProgram::CompileShaders(const std::string& vertexCode,
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 const std::string& fragmentCode)
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 assert(program_ != 0);
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 OpenGLShader vertexShader(GL_VERTEX_SHADER, vertexCode);
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 OpenGLShader fragmentShader(GL_FRAGMENT_SHADER, fragmentCode);
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 glAttachShader(program_, vertexShader.Release());
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
111 ORTHANC_OPENGL_CHECK("glAttachShader");
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 glAttachShader(program_, fragmentShader.Release());
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
113 ORTHANC_OPENGL_CHECK("glAttachShader");
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 glLinkProgram(program_);
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
115 ORTHANC_OPENGL_CHECK("glLinkProgram");
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 glValidateProgram(program_);
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
117 ORTHANC_OPENGL_CHECK("glValidateProgram");
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 GLint OpenGLProgram::GetUniformLocation(const std::string& name)
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 GLint location = glGetUniformLocation(program_, name.c_str());
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
123 ORTHANC_OPENGL_CHECK("glGetUniformLocation");
579
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 if (location == -1)
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem,
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 "Inexistent uniform variable in shader: " + name);
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 else
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 return location;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 GLint OpenGLProgram::GetAttributeLocation(const std::string& name)
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 GLint location = glGetAttribLocation(program_, name.c_str());
947
1091b2adeb5a Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents: 579
diff changeset
140 ORTHANC_OPENGL_CHECK("glGetAttribLocation");
579
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 if (location == -1)
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem,
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 "Inexistent attribute in shader: " + name);
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 else
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 {
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 return location;
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
fadacfbf5538 OpenGL programs and textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }