# HG changeset patch # User Sebastien Jodogne # Date 1682080763 -7200 # Node ID 8bb8d9c0cfd027d610160529a65be1e6fd70e817 # Parent 66c130af0d3c0d71c7d39562b000ba3b6753c520 added "checkStatus" argument to OpenGLProgram::Use() diff -r 66c130af0d3c -r 8bb8d9c0cfd0 OrthancStone/Sources/OpenGL/OpenGLProgram.cpp --- 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"); diff -r 66c130af0d3c -r 8bb8d9c0cfd0 OrthancStone/Sources/OpenGL/OpenGLProgram.h --- 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, diff -r 66c130af0d3c -r 8bb8d9c0cfd0 OrthancStone/Sources/Scene2D/Internals/OpenGLLinesProgram.cpp --- 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"); diff -r 66c130af0d3c -r 8bb8d9c0cfd0 OrthancStone/Sources/Scene2D/Internals/OpenGLTextProgram.cpp --- 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(), diff -r 66c130af0d3c -r 8bb8d9c0cfd0 OrthancStone/Sources/Scene2D/Internals/OpenGLTextureProgram.cpp --- 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());