diff --git a/src/Graphic3d/Graphic3d_RenderingParams.hxx b/src/Graphic3d/Graphic3d_RenderingParams.hxx index c9330902be..8e0f231332 100644 --- a/src/Graphic3d/Graphic3d_RenderingParams.hxx +++ b/src/Graphic3d/Graphic3d_RenderingParams.hxx @@ -79,6 +79,12 @@ public: AnaglyphRight.SetRow (3, aZero); } + //! Returns resolution ratio. + Standard_ShortReal ResolutionRatio() const + { + return Resolution / static_cast (THE_DEFAULT_RESOLUTION); + } + public: Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index f7052ff07b..06f4d1891a 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -140,7 +140,8 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) myReadBuffer (0), myDrawBuffer (0), myDefaultVao (0), - myIsGlDebugCtx (Standard_False) + myIsGlDebugCtx (Standard_False), + myResolutionRatio (1.0f) { // system-dependent fields #if defined(HAVE_EGL) @@ -2607,7 +2608,7 @@ void OpenGl_Context::SetLineWidth (const Standard_ShortReal theWidth) if (core11 != NULL) { // glLineWidth() is still defined within Core Profile, but has no effect with values != 1.0f - core11fwd->glLineWidth (theWidth); + core11fwd->glLineWidth (theWidth * myResolutionRatio); } #ifdef HAVE_GL2PS if (IsFeedback()) diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index 163265dcbe..90b151b592 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -583,6 +583,13 @@ public: //! @name methods to alter or retrieve current state Standard_EXPORT void DisableFeatures() const; + //! Set resolution ratio. + //! Note that this method rounds @theRatio to nearest integer. + void SetResolutionRatio (const Standard_ShortReal theRatio) + { + myResolutionRatio = Max (1.0f, std::floor (theRatio + 0.5f)); + } + private: //! Wrapper to system function to retrieve GL function pointer by name. @@ -695,16 +702,18 @@ private: // context info private: //! @name fields tracking current state - Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program - Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object - Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object - Standard_Integer myRenderMode; //!< value for active rendering mode - Standard_Integer myReadBuffer; //!< current read buffer - Standard_Integer myDrawBuffer; //!< current draw buffer - unsigned int myDefaultVao; //!< default Vertex Array Object - Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state - TCollection_AsciiString myVendor; //!< Graphics Driver's vendor - TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB) + Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program + Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object + Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object + Standard_Integer myRenderMode; //!< value for active rendering mode + Standard_Integer myReadBuffer; //!< current read buffer + Standard_Integer myDrawBuffer; //!< current draw buffer + unsigned int myDefaultVao; //!< default Vertex Array Object + Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state + TCollection_AsciiString myVendor; //!< Graphics Driver's vendor + TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB) + Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size + //!< to be properly displayed on device (screen / printer) public: diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index 7a84bb86e4..82734bc2b5 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -281,6 +281,9 @@ void OpenGl_View::Redraw() // fetch OpenGl context state aCtx->FetchState(); + // set resolution ratio + aCtx->SetResolutionRatio (RenderingParams().ResolutionRatio()); + OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )myFBO; bool toSwap = aCtx->IsRender() && !aCtx->caps->buffersNoSwap diff --git a/tests/bugs/vis/bug26790 b/tests/bugs/vis/bug26790 new file mode 100644 index 0000000000..7256be4ca1 --- /dev/null +++ b/tests/bugs/vis/bug26790 @@ -0,0 +1,21 @@ +puts "============" +puts "OCC26790 apply view resolution to the line width" +puts "============" +puts "" +pload VISUALIZATION + +vclear +vclose all + +vinit View1 + +box b0 1 2 3 + +vdisplay b0 +vfit + +vdump $imagedir/${casename}_1.png + +vrenderparams -resolution 144 + +vdump $imagedir/${casename}_2.png