]> OCCT Git - occt-copy.git/commitdiff
0026791: Visualization, TKOpenGl - apply view resolution to built-in markers CR26791
authorisk <isk@opencascade.com>
Wed, 11 Nov 2015 07:46:48 +0000 (10:46 +0300)
committerisk <isk@opencascade.com>
Wed, 11 Nov 2015 07:46:48 +0000 (10:46 +0300)
Add ResolutionRatio() method in the Graphic3d_RenderingParams.
Add SetResolutionRatio() method in the OpenGl_Context.

src/Graphic3d/Graphic3d_RenderingParams.hxx
src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_Context.hxx
src/OpenGl/OpenGl_View_Redraw.cxx
tests/bugs/vis/bug26791 [new file with mode: 0644]

index c9330902be4b5dfe818fa9c7b75ebe641e081cd8..8e0f2313325da91c2932bf79348c03e1f0f9941b 100644 (file)
@@ -79,6 +79,12 @@ public:
     AnaglyphRight.SetRow (3, aZero);
   }
 
+  //! Returns resolution ratio.
+  Standard_ShortReal ResolutionRatio() const
+  {
+    return Resolution / static_cast<Standard_ShortReal> (THE_DEFAULT_RESOLUTION);
+  }
+
 public:
 
   Graphic3d_RenderingMode Method;                      //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
index f7052ff07b2bb010da03710dcc928e76c17d8dcf..1f47f601c1c2c0a6c7aaf2370557b43a72bc445f 100644 (file)
@@ -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)
@@ -2672,7 +2673,7 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize)
 {
   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)
     //myContext->core11fwd->glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
   #endif
@@ -2680,7 +2681,7 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize)
 #if !defined(GL_ES_VERSION_2_0)
   //else
   {
-    core11fwd->glPointSize (theSize);
+    core11fwd->glPointSize (theSize * myResolutionRatio);
     if (core20fwd != NULL)
     {
       //myContext->core11fwd->glDisable (GL_VERTEX_PROGRAM_POINT_SIZE);
index 163265dcbe2c402b76ace23b3a65abce7dd13cc3..90b151b5926d297cd9d9896e26834a3b3fd9c1d0 100644 (file)
@@ -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:
 
index 7a84bb86e4c659b753617d9532e59fe77c3e4055..82734bc2b57464e6ed5517d0bc5e38d13eb61ad9 100644 (file)
@@ -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/bug26791 b/tests/bugs/vis/bug26791
new file mode 100644 (file)
index 0000000..b676e1e
--- /dev/null
@@ -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