mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0026790: Visualization, TKOpenGl - apply view resolution to the line width in OpenGl_Context::SetLineWidth()
Add ResolutionRatio() method in the Graphic3d_RenderingParams. Add SetResolutionRatio() method in the OpenGl_Context.
This commit is contained in:
parent
ad77956498
commit
75c262a97a
@ -79,6 +79,12 @@ public:
|
|||||||
AnaglyphRight.SetRow (3, aZero);
|
AnaglyphRight.SetRow (3, aZero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns resolution ratio.
|
||||||
|
Standard_ShortReal ResolutionRatio() const
|
||||||
|
{
|
||||||
|
return Resolution / static_cast<Standard_ShortReal> (THE_DEFAULT_RESOLUTION);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
|
Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
|
||||||
|
@ -140,7 +140,8 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
|||||||
myReadBuffer (0),
|
myReadBuffer (0),
|
||||||
myDrawBuffer (0),
|
myDrawBuffer (0),
|
||||||
myDefaultVao (0),
|
myDefaultVao (0),
|
||||||
myIsGlDebugCtx (Standard_False)
|
myIsGlDebugCtx (Standard_False),
|
||||||
|
myResolutionRatio (1.0f)
|
||||||
{
|
{
|
||||||
// system-dependent fields
|
// system-dependent fields
|
||||||
#if defined(HAVE_EGL)
|
#if defined(HAVE_EGL)
|
||||||
@ -2607,7 +2608,7 @@ void OpenGl_Context::SetLineWidth (const Standard_ShortReal theWidth)
|
|||||||
if (core11 != NULL)
|
if (core11 != NULL)
|
||||||
{
|
{
|
||||||
// glLineWidth() is still defined within Core Profile, but has no effect with values != 1.0f
|
// 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
|
#ifdef HAVE_GL2PS
|
||||||
if (IsFeedback())
|
if (IsFeedback())
|
||||||
|
@ -583,6 +583,13 @@ public: //! @name methods to alter or retrieve current state
|
|||||||
|
|
||||||
Standard_EXPORT void DisableFeatures() const;
|
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:
|
private:
|
||||||
|
|
||||||
//! Wrapper to system function to retrieve GL function pointer by name.
|
//! Wrapper to system function to retrieve GL function pointer by name.
|
||||||
@ -695,16 +702,18 @@ private: // context info
|
|||||||
|
|
||||||
private: //! @name fields tracking current state
|
private: //! @name fields tracking current state
|
||||||
|
|
||||||
Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program
|
Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program
|
||||||
Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object
|
Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object
|
||||||
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
|
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
|
||||||
Standard_Integer myRenderMode; //!< value for active rendering mode
|
Standard_Integer myRenderMode; //!< value for active rendering mode
|
||||||
Standard_Integer myReadBuffer; //!< current read buffer
|
Standard_Integer myReadBuffer; //!< current read buffer
|
||||||
Standard_Integer myDrawBuffer; //!< current draw buffer
|
Standard_Integer myDrawBuffer; //!< current draw buffer
|
||||||
unsigned int myDefaultVao; //!< default Vertex Array Object
|
unsigned int myDefaultVao; //!< default Vertex Array Object
|
||||||
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
||||||
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
|
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)
|
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:
|
public:
|
||||||
|
|
||||||
|
@ -281,6 +281,9 @@ void OpenGl_View::Redraw()
|
|||||||
// fetch OpenGl context state
|
// fetch OpenGl context state
|
||||||
aCtx->FetchState();
|
aCtx->FetchState();
|
||||||
|
|
||||||
|
// set resolution ratio
|
||||||
|
aCtx->SetResolutionRatio (RenderingParams().ResolutionRatio());
|
||||||
|
|
||||||
OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )myFBO;
|
OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )myFBO;
|
||||||
bool toSwap = aCtx->IsRender()
|
bool toSwap = aCtx->IsRender()
|
||||||
&& !aCtx->caps->buffersNoSwap
|
&& !aCtx->caps->buffersNoSwap
|
||||||
|
21
tests/bugs/vis/bug26790
Normal file
21
tests/bugs/vis/bug26790
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user