From e3573bb9eca113b619f4358b45e912caa9ecb4b6 Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 31 Oct 2014 15:33:12 +0300 Subject: [PATCH] 0025438: Visualization, TKOpenGl - always setup viewport within OpenGl_Workspace::Redraw() --- .../InterfaceGraphic_Aspect.hxx | 17 +---------------- src/OpenGl/OpenGl_View_2.cxx | 14 ++++++-------- src/OpenGl/OpenGl_Window.cxx | 14 +++++++------- src/OpenGl/OpenGl_Workspace.cxx | 8 +++++--- src/Visual3d/Visual3d_View.cxx | 10 +++++----- 5 files changed, 24 insertions(+), 39 deletions(-) diff --git a/src/InterfaceGraphic/InterfaceGraphic_Aspect.hxx b/src/InterfaceGraphic/InterfaceGraphic_Aspect.hxx index 0e9261ca4d..3c8c8384bf 100644 --- a/src/InterfaceGraphic/InterfaceGraphic_Aspect.hxx +++ b/src/InterfaceGraphic/InterfaceGraphic_Aspect.hxx @@ -15,18 +15,6 @@ #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 #include @@ -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; diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index 4cced5d3d7..010ea9e9ad 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -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 diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index f7c9b58664..d17a0ac865 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -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 } diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index fe150d3f6b..2bfcd3b3a6 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -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) diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index d7b6c1dd65..29710e9d0b 100644 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -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); -- 2.20.1