Mercurial > hg > orthanc-stone
changeset 2057:8bb8d9c0cfd0 deep-learning
added "checkStatus" argument to OpenGLProgram::Use()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 21 Apr 2023 14:39:23 +0200 |
parents | 66c130af0d3c |
children | c0627145b441 |
files | OrthancStone/Sources/OpenGL/OpenGLProgram.cpp OrthancStone/Sources/OpenGL/OpenGLProgram.h OrthancStone/Sources/Scene2D/Internals/OpenGLLinesProgram.cpp OrthancStone/Sources/Scene2D/Internals/OpenGLTextProgram.cpp OrthancStone/Sources/Scene2D/Internals/OpenGLTextureProgram.cpp |
diffstat | 5 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/OpenGL/OpenGLProgram.cpp Tue Apr 18 15:18:36 2023 +0200 +++ b/OrthancStone/Sources/OpenGL/OpenGLProgram.cpp Fri Apr 21 14:39:23 2023 +0200 @@ -82,11 +82,15 @@ } } - void OpenGLProgram::Use() + void OpenGLProgram::Use(bool checkStatus) { //ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT("About to call glUseProgram"); + ORTHANC_OPENGL_CHECK("About to call glUseProgram()"); + glUseProgram(program_); - if (glGetError() != GL_NO_ERROR) + + if (checkStatus && + glGetError() != GL_NO_ERROR) { throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Cannot use successfully compiled OpenGL shader");
--- a/OrthancStone/Sources/OpenGL/OpenGLProgram.h Tue Apr 18 15:18:36 2023 +0200 +++ b/OrthancStone/Sources/OpenGL/OpenGLProgram.h Fri Apr 21 14:39:23 2023 +0200 @@ -48,7 +48,9 @@ ~OpenGLProgram(); - void Use(); + // WARNING: Setting "checkStatus" to "true" impacts performance: + // Calling "glGetError()" seems like a costly operation in WebGL + void Use(bool checkStatus); // WARNING: A global OpenGL context must be active to run this method! void CompileShaders(const std::string& vertexCode,
--- a/OrthancStone/Sources/Scene2D/Internals/OpenGLLinesProgram.cpp Tue Apr 18 15:18:36 2023 +0200 +++ b/OrthancStone/Sources/Scene2D/Internals/OpenGLLinesProgram.cpp Fri Apr 21 14:39:23 2023 +0200 @@ -426,7 +426,7 @@ if (!context_.IsContextLost() && !data.IsEmpty()) { context_.MakeCurrent(); - program_->Use(); + program_->Use(true); GLint locationPosition = program_->GetAttributeLocation("a_position"); GLint locationMiterDirection = program_->GetAttributeLocation("a_miter_direction");
--- a/OrthancStone/Sources/Scene2D/Internals/OpenGLTextProgram.cpp Tue Apr 18 15:18:36 2023 +0200 +++ b/OrthancStone/Sources/Scene2D/Internals/OpenGLTextProgram.cpp Fri Apr 21 14:39:23 2023 +0200 @@ -191,7 +191,7 @@ if (!context_.IsContextLost() && !data.IsEmpty()) { context_.MakeCurrent(); - program_->Use(); + program_->Use(true); double dx, dy; // In pixels ComputeAnchorTranslation(dx, dy, data.GetAnchor(),
--- a/OrthancStone/Sources/Scene2D/Internals/OpenGLTextureProgram.cpp Tue Apr 18 15:18:36 2023 +0200 +++ b/OrthancStone/Sources/Scene2D/Internals/OpenGLTextureProgram.cpp Fri Apr 21 14:39:23 2023 +0200 @@ -54,7 +54,7 @@ if (!context_.IsContextLost()) { context_.MakeCurrent(); - program_->Use(); + program_->Use(true); AffineTransform2D scale = AffineTransform2D::CreateScaling (texture.GetWidth(), texture.GetHeight());