1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Compare commits

...

1 Commits

Author SHA1 Message Date
isk
b9b37c1d45 0026791: Visualization, TKOpenGl - apply view resolution to built-in markers
Add ResolutionRatio() method in the Graphic3d_RenderingParams.
Add SetResolutionRatio() method in the OpenGl_Context.
2015-11-11 10:46:48 +03:00
5 changed files with 57 additions and 13 deletions

View File

@@ -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

View File

@@ -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)
@@ -2672,7 +2673,7 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize)
{ {
if (!myActiveProgram.IsNull()) if (!myActiveProgram.IsNull())
{ {
myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_POINT_SIZE), theSize); myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_POINT_SIZE), theSize * myResolutionRatio);
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
//myContext->core11fwd->glEnable (GL_VERTEX_PROGRAM_POINT_SIZE); //myContext->core11fwd->glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
#endif #endif
@@ -2680,7 +2681,7 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize)
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
//else //else
{ {
core11fwd->glPointSize (theSize); core11fwd->glPointSize (theSize * myResolutionRatio);
if (core20fwd != NULL) if (core20fwd != NULL)
{ {
//myContext->core11fwd->glDisable (GL_VERTEX_PROGRAM_POINT_SIZE); //myContext->core11fwd->glDisable (GL_VERTEX_PROGRAM_POINT_SIZE);

View File

@@ -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.
@@ -705,6 +712,8 @@ private: //! @name fields tracking current state
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:

View File

@@ -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

25
tests/bugs/vis/bug26791 Normal file
View File

@@ -0,0 +1,25 @@
puts "============"
puts "OCC26790 apply view resolution to built-in markers"
puts "============"
puts ""
pload VISUALIZATION
vclear
vclose all
vinit View1
for { set aMarkerType 0 } { $aMarkerType < 13 } { incr aMarkerType } {
set aRow [expr $aMarkerType - 7]
set aCol 5
vmarkerstest m${aMarkerType} $aCol $aRow 0 MarkerType=$aMarkerType PointsOnSide=1
}
vright
vfit
vdump $imagedir/${casename}_1.png
vrenderparams -resolution 144
vdump $imagedir/${casename}_2.png