0025438: Visualization, TKOpenGl - always setup viewport within OpenGl_Workspace...
authorkgv <kgv@opencascade.com>
Fri, 31 Oct 2014 12:33:12 +0000 (15:33 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 5 Nov 2014 14:54:49 +0000 (17:54 +0300)
src/InterfaceGraphic/InterfaceGraphic_Aspect.hxx
src/OpenGl/OpenGl_View_2.cxx
src/OpenGl/OpenGl_Window.cxx
src/OpenGl/OpenGl_Workspace.cxx
src/Visual3d/Visual3d_View.cxx

index 0e9261c..3c8c838 100644 (file)
 #ifndef InterfaceGraphic_AspectHeader
 #define InterfaceGraphic_AspectHeader
 
-#ifndef IMP100701
-#define IMP100701 /* GG Add depth field in the bitmap structure */
-#endif
-
-#ifndef RIC120302
-#define RIC120302       /*GG Add NEW field in CALL_DEF_WINDOW structure
-//      to registred parent window ID 
-//      Change Aspect_Handle to Aspect_Drawable for
-//      a more correct understanding.
-*/
-#endif
-
 #include <Aspect_Drawable.hxx>
 #include <Aspect_RenderingContext.hxx>
 
@@ -41,10 +29,7 @@ typedef struct {
   int IsDefined;
 
   Aspect_Drawable XWindow;
-
-#ifdef RIC120302
   Aspect_Drawable XParentWindow;
-#endif
 
   EXT_WINDOW *ext_data;
 
@@ -52,7 +37,7 @@ typedef struct {
     float xm, ym, xM, yM;
   } Position;
 
-  float dx, dy;
+  int dx, dy;
 
   char *Title;
 
index 4cced5d..010ea9e 100644 (file)
@@ -754,7 +754,7 @@ void OpenGl_View::RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintCo
   aContext->ApplyProjectionMatrix();
 
   if (!ACLayer.sizeDependent)
-    glViewport (0, 0, dispWidth, dispHeight);
+    aContext->core11fwd->glViewport (0, 0, dispWidth, dispHeight);
 
   float left = ACLayer.ortho[0];
   float right = ACLayer.ortho[1];
@@ -763,11 +763,9 @@ void OpenGl_View::RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintCo
 
   int attach = ACLayer.attach;
 
-  float ratio;
-  if (!ACLayer.sizeDependent)
-    ratio = (float) dispWidth/dispHeight;
-  else
-    ratio = ACView.DefWindow.dx/ACView.DefWindow.dy;
+  const float ratio = !ACLayer.sizeDependent
+                    ? float(dispWidth) / float(dispHeight)
+                    : float(theWorkspace->Width()) / float(theWorkspace->Height());
 
   float delta;
   if (ratio >= 1.0) {
@@ -827,7 +825,7 @@ void OpenGl_View::RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintCo
     GLsizei anViewportY = 0;
     thePrintContext->GetLayerViewport (anViewportX, anViewportY);
     if (anViewportX != 0 && anViewportY != 0)
-      glViewport (0, 0, anViewportX, anViewportY);
+      aContext->core11fwd->glViewport (0, 0, anViewportX, anViewportY);
   }
 #endif
 
@@ -862,7 +860,7 @@ void OpenGl_View::RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintCo
   aContext->ApplyWorldViewMatrix();
 
   if (!ACLayer.sizeDependent)
-    glViewport (0, 0, (GLsizei) ACView.DefWindow.dx, (GLsizei) ACView.DefWindow.dy);
+    aContext->core11fwd->glViewport (0, 0, theWorkspace->Width(), theWorkspace->Height());
 
   glFlush ();
 #endif
index f7c9b58..d17a0ac 100644 (file)
@@ -139,8 +139,8 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
                               const Handle(OpenGl_Context)& theShareCtx)
 : myGlContext (new OpenGl_Context (theCaps)),
   myOwnGContext (theGContext == 0),
-  myWidth ((Standard_Integer )theCWindow.dx),
-  myHeight ((Standard_Integer )theCWindow.dy),
+  myWidth   (theCWindow.dx),
+  myHeight  (theCWindow.dy),
   myBgColor (THE_DEFAULT_BG_COLOR)
 {
   myBgColor.rgb[0] = theCWindow.Background.r;
@@ -665,8 +665,8 @@ void OpenGl_Window::Resize (const CALL_DEF_WINDOW& theCWindow)
   if ((myWidth == theCWindow.dx) && (myHeight == theCWindow.dy))
     return;
 
-  myWidth  = (Standard_Integer )theCWindow.dx;
-  myHeight = (Standard_Integer )theCWindow.dy;
+  myWidth  = theCWindow.dx;
+  myHeight = theCWindow.dy;
 
 #if !defined(_WIN32) && !defined(HAVE_EGL) && !defined(__ANDROID__)
   XResizeWindow (aDisp, myGlContext->myWindow, (unsigned int )myWidth, (unsigned int )myHeight);
@@ -740,8 +740,8 @@ void OpenGl_Window::Init()
     return;
 
 #if defined(HAVE_EGL) || defined(__ANDROID__)
- eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_WIDTH,  &myWidth);
- eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_HEIGHT, &myHeight);
 eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_WIDTH,  &myWidth);
 eglQuerySurface ((EGLDisplay )myGlContext->myDisplay, (EGLSurface )myGlContext->myWindow, EGL_HEIGHT, &myHeight);
 #elif defined(_WIN32)
   RECT cr;
   GetClientRect ((HWND )myGlContext->myWindow, &cr);
@@ -760,9 +760,9 @@ void OpenGl_Window::Init()
 #endif
 
   glDisable (GL_SCISSOR_TEST);
+  glViewport (0, 0, myWidth, myHeight);
 #if !defined(GL_ES_VERSION_2_0)
   glMatrixMode (GL_MODELVIEW);
-  glViewport (0, 0, myWidth, myHeight);
   glDrawBuffer (GL_BACK);
 #endif
 }
index fe150d3..2bfcd3b 100644 (file)
@@ -640,14 +640,16 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
   aGlCtx->FetchState();
 
   Tint toSwap = (aGlCtx->IsRender() && !aGlCtx->caps->buffersNoSwap) ? 1 : 0; // swap buffers
-  GLint aViewPortBack[4];
   OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )theCView.ptrFBO;
   if (aFrameBuffer != NULL)
   {
-    glGetIntegerv (GL_VIEWPORT, aViewPortBack);
     aFrameBuffer->SetupViewport (aGlCtx);
     toSwap = 0; // no need to swap buffers
   }
+  else
+  {
+    aGlCtx->core11fwd->glViewport (0, 0, myWidth, myHeight);
+  }
 
   myToRedrawGL = Standard_True;
   if (theCView.RenderParams.Method == Graphic3d_RM_RAYTRACING
@@ -721,7 +723,7 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
   {
     aFrameBuffer->UnbindBuffer (aGlCtx);
     // move back original viewport
-    glViewport (aViewPortBack[0], aViewPortBack[1], aViewPortBack[2], aViewPortBack[3]);
+    aGlCtx->core11fwd->glViewport (0, 0, myWidth, myHeight);
   }
 
 #if defined(_WIN32) && defined(HAVE_VIDEOCAPTURE)
index d7b6c1d..29710e9 100644 (file)
@@ -111,8 +111,8 @@ void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
 
   Standard_Integer Width, Height;
   theWindow->Size (Width, Height);
-  MyCView.DefWindow.dx = float(Width);
-  MyCView.DefWindow.dy = float(Height);
+  MyCView.DefWindow.dx = Width;
+  MyCView.DefWindow.dy = Height;
 
   Standard_Real R, G, B;
   MyBackground = MyWindow->Background ();
@@ -274,10 +274,10 @@ void Visual3d_View::SetRatio()
   MyWindow->Size (aWidth, aHeight);
   if (aWidth > 0 && aHeight > 0)
   {
-    Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight; 
+    Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight;
 
-    MyCView.DefWindow.dx = Standard_ShortReal (aWidth);
-    MyCView.DefWindow.dy = Standard_ShortReal (aHeight);
+    MyCView.DefWindow.dx = aWidth;
+    MyCView.DefWindow.dy = aHeight;
 
     myGraphicDriver->RatioWindow (MyCView);