From 83da37b115600652726fe934212b0590eabb66f2 Mon Sep 17 00:00:00 2001 From: isk Date: Tue, 29 Mar 2016 07:22:42 +0300 Subject: [PATCH] 0026434: Visualization - Textured objects should have priority over the environment mapping. Add handle on environment texture in OpenGl_Workspace. Add a new parameter UseEnvironmentTexture to the Graphic3d_ZLayerSettings. OSD layers don't use environment texture by default. zbuffertrihedron doesn't use environment texture. vzlayer can enable/disable environment texture mappping. Delete unnecessary files Graphic3d_TypeOfSurfaceDetail.hxx and V3d_TypeOfSurface.hxx. Delete functions SurfaceDetailType and SetSurfaceDetailType functions from Graphic3d_CView. Delete functions SurfaceDetailState and UpdateSurfaceDetailStateTo from OpenGl_ShaderManager. Delete class OpenGl_SurfaceDetailState. Delete functions SurfaceDetailType and SetSurfaceDetailType from OpenGl_View. Delete functions SetSurfaceDetail and SurfaceDetail() from V3d_View. Delete functions SetDefaultSurfaceDetail and DefaultSurfaceDetail from V3d_Viewer. Delete draw command VSetTextureMode. Add description in dox. --- dox/dev_guides/upgrade/upgrade.md | 6 + .../Textures/Textures_Presentation.cpp | 7 +- .../TexturesExt/TexturesExt_Presentation.cpp | 7 +- .../src/TexturesExt_Presentation.cpp | 7 +- samples/mfc/standard/Common/OCC_2dView.cpp | 1 - samples/qt/Common/src/DocumentCommon.cxx | 3 +- samples/qt/Common/src/View.cxx | 3 +- samples/tcl/dimensions.tcl | 1 - src/Graphic3d/FILES | 1 - src/Graphic3d/Graphic3d_CView.cxx | 1 - src/Graphic3d/Graphic3d_CView.hxx | 7 - .../Graphic3d_TypeOfSurfaceDetail.hxx | 32 ----- src/Graphic3d/Graphic3d_ZLayerSettings.hxx | 12 +- src/OpenGl/OpenGl_GraphicDriver.cxx | 2 + src/OpenGl/OpenGl_Layer.cxx | 13 ++ src/OpenGl/OpenGl_NamedStatus.hxx | 3 +- src/OpenGl/OpenGl_PrimitiveArray.cxx | 8 +- src/OpenGl/OpenGl_ShaderManager.cxx | 19 --- src/OpenGl/OpenGl_ShaderManager.hxx | 15 +-- src/OpenGl/OpenGl_ShaderStates.hxx | 25 ---- src/OpenGl/OpenGl_View.cxx | 1 - src/OpenGl/OpenGl_View.hxx | 12 -- src/OpenGl/OpenGl_View_Raytrace.cxx | 2 +- src/OpenGl/OpenGl_View_Redraw.cxx | 121 +++++++----------- src/OpenGl/OpenGl_Workspace.cxx | 15 ++- src/OpenGl/OpenGl_Workspace.hxx | 14 ++ src/QABugs/QABugs_17.cxx | 4 - src/V3d/FILES | 1 - src/V3d/V3d_TypeOfSurfaceDetail.hxx | 31 ----- src/V3d/V3d_View.cxx | 19 --- src/V3d/V3d_View.hxx | 6 - src/V3d/V3d_Viewer.cxx | 13 +- src/V3d/V3d_Viewer.hxx | 10 +- src/ViewerTest/ViewerTest.cxx | 2 - src/ViewerTest/ViewerTest_ViewerCommands.cxx | 69 ++-------- src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx | 5 - tests/bugs/vis/bug24622 | 2 - tests/bugs/vis/bug26434 | 42 ++++++ 38 files changed, 174 insertions(+), 368 deletions(-) delete mode 100644 src/Graphic3d/Graphic3d_TypeOfSurfaceDetail.hxx delete mode 100644 src/V3d/V3d_TypeOfSurfaceDetail.hxx create mode 100644 tests/bugs/vis/bug26434 diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 4a9f48d8db..0a817715f7 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -971,3 +971,9 @@ Zoom persistent selection introduces a new structure *Graphic3d_TransformPers* f * Transformation matrix utilities from *OpenGl_Utils* namespace have been moved to *Graphic3d_TransformUtils* and *Graphic3d_TransformUtils.hxx* header respectively. * Matrix stack utilities from *OpenGl_Utils* namespace have been moved to *OpenGl_MatrixStack* class and *OpenGl_MatrixStack.hxx* header respectively. * *OpenGl_View* methods *Begin/EndTransformPersistence* have been removed. Please, use *Graphic3d_TransformPers::Apply()* instead to apply persistence to perspective and world-view projection matrices. + +@subsection Correction of texture mapping of objects + +Interaction of texture and environment texture is fixed. Textured objects have priority over the environment mapping. +Redundant enumerations V3d_TypeOfSurface and Graphic3d_TypeOfSurface, class OpenGl_SurfaceDetailState, corresponding methods from Graphic3d_CView, OpenGl_ShaderManager, OpenGl_View, V3d_View, V3d_Viewer are deleted. +Draw command VSetTextureMode is deleted. diff --git a/samples/mfc/occtdemo/Textures/Textures_Presentation.cpp b/samples/mfc/occtdemo/Textures/Textures_Presentation.cpp index c43f9e1232..cf5b1e65b6 100755 --- a/samples/mfc/occtdemo/Textures/Textures_Presentation.cpp +++ b/samples/mfc/occtdemo/Textures/Textures_Presentation.cpp @@ -84,7 +84,6 @@ void Textures_Presentation::Init() // initialize v3d_view so it displays textures well getViewer()->InitActiveViews(); Handle(V3d_View) aView = getViewer()->ActiveView(); - aView->SetSurfaceDetail(V3d_TEX_ALL); aView->SetSize(ZVIEW_SIZE); setResultTitle("Textured Shape"); @@ -120,11 +119,7 @@ void Textures_Presentation::Init() " // mode 3 is \"textured\" mode of AIS_TexturedShape, " EOL " // other modes will display the \"normal\", non-textured shape," EOL " // in wireframe(1) or shaded(2) modes correspondingly" EOL - " aTShape->SetDisplayMode(3); " EOL - "" EOL - " // V3d_TEX_ALL constant must be set as surface detail" EOL - " // for current view to see AIS_TexturedShape" EOL - " myCurrentView->SetSurfaceDetail(V3d_TEX_ALL);" EOL); + " aTShape->SetDisplayMode(3); " EOL); } ////////////////////////////////////////////////////////////////////// diff --git a/samples/mfc/occtdemo/TexturesExt/TexturesExt_Presentation.cpp b/samples/mfc/occtdemo/TexturesExt/TexturesExt_Presentation.cpp index d9dcf5504b..1a548b53d9 100755 --- a/samples/mfc/occtdemo/TexturesExt/TexturesExt_Presentation.cpp +++ b/samples/mfc/occtdemo/TexturesExt/TexturesExt_Presentation.cpp @@ -71,7 +71,6 @@ void TexturesExt_Presentation::Init() // initialize v3d_view so it displays TexturesExt well getViewer()->InitActiveViews(); Handle(V3d_View) aView = getViewer()->ActiveView(); - aView->SetSurfaceDetail(V3d_TEX_ALL); aView->SetSize(ZVIEW_SIZE); setResultTitle("Textured Shape"); @@ -107,11 +106,7 @@ void TexturesExt_Presentation::Init() " // mode 3 is \"textured\" mode of AIS_TexturedShape, " EOL " // other modes will display the \"normal\", non-textured shape," EOL " // in wireframe(1) or shaded(2) modes correspondingly" EOL - " aTShape->SetDisplayMode(3); " EOL - "" EOL - " // V3d_TEX_ALL constant must be set as surface detail" EOL - " // for current view to see AIS_TexturedShape" EOL - " myCurrentView->SetSurfaceDetail(V3d_TEX_ALL);" EOL); + " aTShape->SetDisplayMode(3); " EOL); } ////////////////////////////////////////////////////////////////////// diff --git a/samples/mfc/standard/04_Viewer3d/src/TexturesExt_Presentation.cpp b/samples/mfc/standard/04_Viewer3d/src/TexturesExt_Presentation.cpp index 94990219ee..f98463e4c1 100755 --- a/samples/mfc/standard/04_Viewer3d/src/TexturesExt_Presentation.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/TexturesExt_Presentation.cpp @@ -70,7 +70,6 @@ void TexturesExt_Presentation::Init() // initialize v3d_view so it displays TexturesExt well getViewer()->InitActiveViews(); Handle(V3d_View) aView = getViewer()->ActiveView(); - aView->SetSurfaceDetail(V3d_TEX_ALL); aView->SetSize(ZVIEW_SIZE); // getDocument()->UpdateResultMessageDlg("Textured Shape", @@ -106,11 +105,7 @@ void TexturesExt_Presentation::Init() " // mode 3 is \"textured\" mode of AIS_TexturedShape, " EOL " // other modes will display the \"normal\", non-textured shape," EOL " // in wireframe(1) or shaded(2) modes correspondingly" EOL - " aTShape->SetDisplayMode(3); " EOL - "" EOL - " // V3d_TEX_ALL constant must be set as surface detail" EOL - " // for current view to see AIS_TexturedShape" EOL - " myCurrentView->SetSurfaceDetail(V3d_TEX_ALL);" EOL); + " aTShape->SetDisplayMode(3); " EOL); // CString text(Message.ToCString()); getDocument()->ClearDialog(); getDocument()->SetDialogTitle("Change face color"); diff --git a/samples/mfc/standard/Common/OCC_2dView.cpp b/samples/mfc/standard/Common/OCC_2dView.cpp index c8bf3516ab..a0b4290da4 100755 --- a/samples/mfc/standard/Common/OCC_2dView.cpp +++ b/samples/mfc/standard/Common/OCC_2dView.cpp @@ -100,7 +100,6 @@ void OCC_2dView::OnInitialUpdate() myV2dView =((OCC_2dDoc*)GetDocument())->GetViewer2D()->CreateView(); myV2dView->SetWindow(aWNTWindow); myV2dView->SetZClippingType(V3d_OFF); - myV2dView->SetSurfaceDetail(V3d_TEX_ALL); // initialize the grids dialogs TheRectangularGridDialog.Create(CRectangularGrid::IDD, NULL); TheCircularGridDialog.Create(CCircularGrid::IDD, NULL); diff --git a/samples/qt/Common/src/DocumentCommon.cxx b/samples/qt/Common/src/DocumentCommon.cxx index 34783086dd..512d4bb4e0 100755 --- a/samples/qt/Common/src/DocumentCommon.cxx +++ b/samples/qt/Common/src/DocumentCommon.cxx @@ -47,8 +47,7 @@ Handle(V3d_Viewer) DocumentCommon::Viewer (const Standard_ExtString theName, V3d_GOURAUD, V3d_WAIT, theComputedMode, - theDefaultComputedMode, - V3d_TEX_NONE); + theDefaultComputedMode); } DocumentCommon::DocumentCommon( const int theIndex, ApplicationCommonWindow* app ) diff --git a/samples/qt/Common/src/View.cxx b/samples/qt/Common/src/View.cxx index 4ba33bf220..3447fbf4e6 100755 --- a/samples/qt/Common/src/View.cxx +++ b/samples/qt/Common/src/View.cxx @@ -1015,11 +1015,10 @@ void View::onEnvironmentMap() Handle(Graphic3d_TextureEnv) aTexture = new Graphic3d_TextureEnv( fileName.toLatin1().data() ); myView->SetTextureEnv (aTexture); - myView->SetSurfaceDetail (V3d_TEX_ENVIRONMENT); } else { - myView->SetSurfaceDetail (V3d_TEX_NONE); + myView->SetTextureEnv (Handle(Graphic3d_TextureEnv)()); } myView->Redraw(); diff --git a/samples/tcl/dimensions.tcl b/samples/tcl/dimensions.tcl index 56ec899add..b56fdcc23b 100644 --- a/samples/tcl/dimensions.tcl +++ b/samples/tcl/dimensions.tcl @@ -86,7 +86,6 @@ vclipplane change pb capping on vclipplane change pb capping color 1.0 0.8 0.0 vclipplane set pb object b -vsettexturemode Driver1/Viewer1/View1 2 vclipplane change pa capping texname $aHatch vclipplane change pa capping texscale 0.05 -0.05 vclipplane change pb capping texname $aHatch diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 770c6f9ea7..8e77ea0f46 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -160,7 +160,6 @@ Graphic3d_TypeOfReflection.hxx Graphic3d_TypeOfShaderObject.hxx Graphic3d_TypeOfShadingModel.hxx Graphic3d_TypeOfStructure.hxx -Graphic3d_TypeOfSurfaceDetail.hxx Graphic3d_TypeOfTexture.hxx Graphic3d_TypeOfTextureFilter.hxx Graphic3d_TypeOfTextureMode.hxx diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index f2868ee97e..6b8617ec97 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -1068,7 +1068,6 @@ void Graphic3d_CView::CopySettings (const Handle(Graphic3d_CView)& theOther) SetTextureEnv (theOther->TextureEnv()); SetCullingEnabled (theOther->IsCullingEnabled()); SetShadingModel (theOther->ShadingModel()); - SetSurfaceDetailType (theOther->SurfaceDetailType()); SetBackfacingModel (theOther->BackfacingModel()); SetCamera (new Graphic3d_Camera (theOther->Camera())); SetBackZClippingOn (theOther->BackZClippingIsOn()); diff --git a/src/Graphic3d/Graphic3d_CView.hxx b/src/Graphic3d/Graphic3d_CView.hxx index 8eaefed26e..451b9c3002 100644 --- a/src/Graphic3d/Graphic3d_CView.hxx +++ b/src/Graphic3d/Graphic3d_CView.hxx @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -434,12 +433,6 @@ public: //! Sets shading model of the view. virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) = 0; - //! Returns surface detail type of the view. - virtual Graphic3d_TypeOfSurfaceDetail SurfaceDetailType() const = 0; - - //! Sets surface detail type of the view. - virtual void SetSurfaceDetailType (const Graphic3d_TypeOfSurfaceDetail theType) = 0; - //! Return backfacing model used for the view. virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const = 0; diff --git a/src/Graphic3d/Graphic3d_TypeOfSurfaceDetail.hxx b/src/Graphic3d/Graphic3d_TypeOfSurfaceDetail.hxx deleted file mode 100644 index 7e965dc52c..0000000000 --- a/src/Graphic3d/Graphic3d_TypeOfSurfaceDetail.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// Created on: 1991-10-07 -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Graphic3d_TypeOfSurfaceDetail_HeaderFile -#define _Graphic3d_TypeOfSurfaceDetail_HeaderFile - -//! Modes of visualisation of objects in a view -//! -//! TOD_NONE no texture mapping -//! TOD_ENVIRONMENT only environnement mapping -//! TOD_ALL environnement + texture mapping -enum Graphic3d_TypeOfSurfaceDetail -{ - Graphic3d_TOD_NONE, - Graphic3d_TOD_ENVIRONMENT, - Graphic3d_TOD_ALL -}; - -#endif // _Graphic3d_TypeOfSurfaceDetail_HeaderFile diff --git a/src/Graphic3d/Graphic3d_ZLayerSettings.hxx b/src/Graphic3d/Graphic3d_ZLayerSettings.hxx index b5fb3986bf..305f91205f 100644 --- a/src/Graphic3d/Graphic3d_ZLayerSettings.hxx +++ b/src/Graphic3d/Graphic3d_ZLayerSettings.hxx @@ -35,7 +35,8 @@ struct Graphic3d_ZLayerSettings Flags (Graphic3d_ZLayerDepthTest | Graphic3d_ZLayerDepthWrite | Graphic3d_ZLayerDepthClear), - IsImmediate (false) + IsImmediate (false), + UseEnvironmentTexture (true) {} //! Returns true if theSetting is enabled. @@ -76,10 +77,11 @@ struct Graphic3d_ZLayerSettings public: - Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function - Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function - Standard_Integer Flags; //!< storage field for settings - bool IsImmediate; //!< immediate layer will be drawn after all normal layers + Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function + Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function + Standard_Integer Flags; //!< storage field for settings + bool IsImmediate; //!< immediate layer will be drawn after all normal layers + bool UseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer }; diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index f195173112..604d455b24 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -101,6 +101,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio Graphic3d_ZLayerSettings anUnderlaySettings; anUnderlaySettings.Flags = 0; anUnderlaySettings.IsImmediate = false; + anUnderlaySettings.UseEnvironmentTexture = false; myLayerIds.Add (Graphic3d_ZLayerId_BotOSD); myLayerSeq.Append (Graphic3d_ZLayerId_BotOSD); myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_BotOSD, anUnderlaySettings); @@ -133,6 +134,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio Graphic3d_ZLayerSettings anOsdSettings; anOsdSettings.Flags = 0; anOsdSettings.IsImmediate = true; + anOsdSettings.UseEnvironmentTexture = false; myLayerIds.Add (Graphic3d_ZLayerId_TopOSD); myLayerSeq.Append (Graphic3d_ZLayerId_TopOSD); myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_TopOSD, anOsdSettings); diff --git a/src/OpenGl/OpenGl_Layer.cxx b/src/OpenGl/OpenGl_Layer.cxx index f873314531..55a51b8158 100644 --- a/src/OpenGl/OpenGl_Layer.cxx +++ b/src/OpenGl/OpenGl_Layer.cxx @@ -365,6 +365,13 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace, glDepthFunc (GL_ALWAYS); } + // save environment texture + Handle(OpenGl_Texture) anEnvironmentTexture = theWorkspace->EnvironmentTexture(); + if (!myLayerSettings.UseEnvironmentTexture) + { + theWorkspace->SetEnvironmentTexture (Handle(OpenGl_Texture)()); + } + // handle depth offset if (IsSettingEnabled (Graphic3d_ZLayerDepthOffset)) { @@ -390,4 +397,10 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace, theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode, anAppliedOffsetParams.factor, anAppliedOffsetParams.units); + + // restore environment texture + if (!myLayerSettings.UseEnvironmentTexture) + { + theWorkspace->SetEnvironmentTexture (anEnvironmentTexture); + } } diff --git a/src/OpenGl/OpenGl_NamedStatus.hxx b/src/OpenGl/OpenGl_NamedStatus.hxx index 0064259c35..c6e557891d 100644 --- a/src/OpenGl/OpenGl_NamedStatus.hxx +++ b/src/OpenGl/OpenGl_NamedStatus.hxx @@ -23,7 +23,6 @@ #define OPENGL_NS_ANTIALIASING (1<<5) #define OPENGL_NS_2NDPASSNEED (1<<6) #define OPENGL_NS_2NDPASSDO (1<<7) -#define OPENGL_NS_FORBIDSETTEX (1<<8) -#define OPENGL_NS_WHITEBACK (1<<9) +#define OPENGL_NS_WHITEBACK (1<<8) #endif //_OpenGl_NamedStatus_Header diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index ecb91c4481..9b019492f2 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -791,7 +791,13 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace const Standard_Boolean isLightOnFace = isLightOn && (aTexture.IsNull() || aTexture->GetParams()->IsModulate()); - aCtx->ShaderManager()->BindProgram (anAspectFace, aTexture, isLightOnFace, hasVertColor, anAspectFace->ShaderProgramRes (aCtx)); + const Standard_Boolean toEnableEnvMap = (!aTexture.IsNull() && (aTexture == theWorkspace->EnvironmentTexture())); + aCtx->ShaderManager()->BindProgram (anAspectFace, + aTexture, + isLightOnFace, + hasVertColor, + toEnableEnvMap, + anAspectFace->ShaderProgramRes (aCtx)); break; } } diff --git a/src/OpenGl/OpenGl_ShaderManager.cxx b/src/OpenGl/OpenGl_ShaderManager.cxx index 68e1db0bdd..959faf8ffc 100644 --- a/src/OpenGl/OpenGl_ShaderManager.cxx +++ b/src/OpenGl/OpenGl_ShaderManager.cxx @@ -853,25 +853,6 @@ const OpenGl_MaterialState* OpenGl_ShaderManager::MaterialState (const Handle(Op return &myMaterialStates.Find (theProgram); } -// ======================================================================= -// function : SurfaceDetailState -// purpose : Returns current state of OCCT surface detail -// ======================================================================= -const OpenGl_SurfaceDetailState& OpenGl_ShaderManager::SurfaceDetailState() const -{ - return mySurfaceDetailState; -} - -// ======================================================================= -// function : UpdateSurfaceDetailStateTo -// purpose : Updates state of OCCT surface detail -// ======================================================================= -void OpenGl_ShaderManager::UpdateSurfaceDetailStateTo (const Graphic3d_TypeOfSurfaceDetail theDetail) -{ - mySurfaceDetailState.Set (theDetail); - mySurfaceDetailState.Update(); -} - namespace { diff --git a/src/OpenGl/OpenGl_ShaderManager.hxx b/src/OpenGl/OpenGl_ShaderManager.hxx index 662f094fac..e15aad55a8 100644 --- a/src/OpenGl/OpenGl_ShaderManager.hxx +++ b/src/OpenGl/OpenGl_ShaderManager.hxx @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -84,6 +83,7 @@ public: const Handle(OpenGl_Texture)& theTexture, const Standard_Boolean theToLightOn, const Standard_Boolean theHasVertColor, + const Standard_Boolean theEnableEnvMap, const Handle(OpenGl_ShaderProgram)& theCustomProgram) { if (!theCustomProgram.IsNull() @@ -92,7 +92,7 @@ public: return bindProgramWithState (theCustomProgram, theAspect); } - const Standard_Integer aBits = getProgramBits (theTexture, theHasVertColor, Standard_True); + const Standard_Integer aBits = getProgramBits (theTexture, theHasVertColor, theEnableEnvMap); Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theToLightOn, aBits); return bindProgramWithState (aProgram, theAspect); } @@ -253,14 +253,6 @@ public: //! Returns current state of OCCT material for specified program. Standard_EXPORT const OpenGl_MaterialState* MaterialState (const Handle(OpenGl_ShaderProgram)& theProgram) const; -public: - - //! Returns current state of OCCT surface detail. - Standard_EXPORT const OpenGl_SurfaceDetailState& SurfaceDetailState() const; - - //! Updates state of OCCT surface detail. - Standard_EXPORT void UpdateSurfaceDetailStateTo (const Graphic3d_TypeOfSurfaceDetail theDetail); - public: //! Pushes current state of OCCT graphics parameters to specified program. @@ -309,7 +301,7 @@ protected: { aBits |= OpenGl_PO_ClipPlanes; } - if (theEnableEnvMap && mySurfaceDetailState.Detail() == Graphic3d_TOD_ENVIRONMENT) + if (theEnableEnvMap) { // Environment map overwrites material texture aBits |= OpenGl_PO_TextureEnv; @@ -413,7 +405,6 @@ protected: OpenGl_WorldViewState myWorldViewState; //!< State of OCCT world-view transformation OpenGl_ClippingState myClippingState; //!< State of OCCT clipping planes OpenGl_LightSourceState myLightSourceState; //!< State of OCCT light sources - OpenGl_SurfaceDetailState mySurfaceDetailState; //!< State of OCCT surface detail private: diff --git a/src/OpenGl/OpenGl_ShaderStates.hxx b/src/OpenGl/OpenGl_ShaderStates.hxx index 4df02eb66d..cda068e3f6 100755 --- a/src/OpenGl/OpenGl_ShaderStates.hxx +++ b/src/OpenGl/OpenGl_ShaderStates.hxx @@ -16,7 +16,6 @@ #ifndef _OpenGl_State_HeaderFile #define _OpenGl_State_HeaderFile -#include #include #include #include @@ -183,28 +182,4 @@ protected: }; -//! Defines generic state of OCCT surface detail. -class OpenGl_SurfaceDetailState : public OpenGl_StateInterface -{ -public: - - //! Creates new surface detail state. - OpenGl_SurfaceDetailState (const Graphic3d_TypeOfSurfaceDetail theDetail = Graphic3d_TOD_NONE) - : myDetail (theDetail) - { - // - } - - //! Sets new surface detail. - void Set (const Graphic3d_TypeOfSurfaceDetail theDetail) { myDetail = theDetail; } - - //! Returns surface detail. - Graphic3d_TypeOfSurfaceDetail Detail() const { return myDetail; } - -private: - - Graphic3d_TypeOfSurfaceDetail myDetail; //!< OCCT surface detail - -}; - #endif // _OpenGl_State_HeaderFile diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index d2cc0b99eb..6ec36bb84a 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -66,7 +66,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr, myAntiAliasing (Standard_False), myCulling (Standard_True), myShadingModel (Graphic3d_TOSM_FACET), - mySurfaceDetail (Graphic3d_TOD_ALL), myBackfacing (Graphic3d_TOBM_AUTOMATIC), myBgColor (myDefaultBg), myFog (myDefaultFog), diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 3cc7fb3293..c255f42b2f 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -308,16 +307,6 @@ public: //! Sets shading model of the view. virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) Standard_OVERRIDE { myShadingModel = theModel; } - //! Returns surface detail type of the view. - virtual Graphic3d_TypeOfSurfaceDetail SurfaceDetailType() const Standard_OVERRIDE { return mySurfaceDetail; } - - //! Sets surface detail type of the view. - virtual void SetSurfaceDetailType (const Graphic3d_TypeOfSurfaceDetail theType) Standard_OVERRIDE - { - mySurfaceDetail = theType; - myToUpdateEnvironmentMap = Standard_True; - } - //! Return backfacing model used for the view. virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; } @@ -562,7 +551,6 @@ protected: Standard_Boolean myAntiAliasing; Standard_Boolean myCulling; Graphic3d_TypeOfShadingModel myShadingModel; - Graphic3d_TypeOfSurfaceDetail mySurfaceDetail; Graphic3d_TypeOfBackfacingModel myBackfacing; TEL_COLOUR myBgColor; OPENGL_FOG myFog; diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index 0c7dc0067f..79094e312e 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -2166,7 +2166,7 @@ Standard_Boolean OpenGl_View::updateRaytraceEnvironmentMap (const Handle(OpenGl_ { aResult &= theGlContext->BindProgram (aProgram); - if (!myTextureEnv.IsNull() && mySurfaceDetail != Graphic3d_TOD_NONE) + if (!myTextureEnv.IsNull()) { myTextureEnv->Bind (theGlContext, GL_TEXTURE0 + OpenGl_RT_EnvironmentMapTexture); diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index 068825c9be..ae8fc975c7 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -932,8 +932,13 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, aContext->ProjectionState.SetCurrent (myCamera->ProjectionStereoRightF()); aContext->ApplyProjectionMatrix(); } + + myWorkspace->SetEnvironmentTexture (myTextureEnv); + renderScene (theProjection, theOutputFBO, theToDrawImmediate); + myWorkspace->SetEnvironmentTexture (Handle(OpenGl_Texture)()); + // =============================== // Step 4: Trihedron // =============================== @@ -1136,7 +1141,14 @@ void OpenGl_View::renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace) // display global trihedron if (myToShowTrihedron) { + // disable environment texture + Handle(OpenGl_Texture) anEnvironmentTexture = theWorkspace->EnvironmentTexture(); + theWorkspace->SetEnvironmentTexture (Handle(OpenGl_Texture)()); + myTrihedron.Render (theWorkspace); + + // restore environment texture + theWorkspace->SetEnvironmentTexture (anEnvironmentTexture); } if (myToShowGradTrihedron) { @@ -1283,84 +1295,49 @@ void OpenGl_View::renderScene (Graphic3d_Camera::Projection theProjection, // Clear status bitfields myWorkspace->NamedStatus &= ~(OPENGL_NS_2NDPASSNEED | OPENGL_NS_2NDPASSDO); - // Update state of surface detail level - myWorkspace->GetGlContext()->ShaderManager()->UpdateSurfaceDetailStateTo (mySurfaceDetail); + // First pass + renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate); + myWorkspace->DisableTexture(); - // Added PCT for handling of textures - switch (mySurfaceDetail) + // Second pass + if (myWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) { - case Graphic3d_TOD_NONE: - myWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX; - myWorkspace->DisableTexture(); - // Render the view - renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate); - break; + myWorkspace->NamedStatus |= OPENGL_NS_2NDPASSDO; - case Graphic3d_TOD_ENVIRONMENT: - myWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX; - if (myRenderParams.Method != Graphic3d_RM_RAYTRACING) - { - myWorkspace->EnableTexture (myTextureEnv); - } - // Render the view - renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate); - myWorkspace->DisableTexture(); - break; + // Remember OpenGl properties + GLint aSaveBlendDst = GL_ONE_MINUS_SRC_ALPHA, aSaveBlendSrc = GL_SRC_ALPHA; + GLint aSaveZbuffFunc; + GLboolean aSaveZbuffWrite; + glGetBooleanv (GL_DEPTH_WRITEMASK, &aSaveZbuffWrite); + glGetIntegerv (GL_DEPTH_FUNC, &aSaveZbuffFunc); + #if !defined(GL_ES_VERSION_2_0) + glGetIntegerv (GL_BLEND_DST, &aSaveBlendDst); + glGetIntegerv (GL_BLEND_SRC, &aSaveBlendSrc); + #endif + GLboolean wasZbuffEnabled = glIsEnabled (GL_DEPTH_TEST); + GLboolean wasBlendEnabled = glIsEnabled (GL_BLEND); - case Graphic3d_TOD_ALL: - // First pass - myWorkspace->NamedStatus &= ~OPENGL_NS_FORBIDSETTEX; - // Render the view - renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate); - myWorkspace->DisableTexture(); + // Change the properties for second rendering pass + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_BLEND); - // Second pass - if (myWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) - { - myWorkspace->NamedStatus |= OPENGL_NS_2NDPASSDO; - if (myRenderParams.Method != Graphic3d_RM_RAYTRACING) - { - myWorkspace->EnableTexture (myTextureEnv); - } + glDepthFunc (GL_EQUAL); + glDepthMask (GL_FALSE); + glEnable (GL_DEPTH_TEST); - // Remember OpenGl properties - GLint aSaveBlendDst = GL_ONE_MINUS_SRC_ALPHA, aSaveBlendSrc = GL_SRC_ALPHA; - GLint aSaveZbuffFunc; - GLboolean aSaveZbuffWrite; - glGetBooleanv (GL_DEPTH_WRITEMASK, &aSaveZbuffWrite); - glGetIntegerv (GL_DEPTH_FUNC, &aSaveZbuffFunc); - #if !defined(GL_ES_VERSION_2_0) - glGetIntegerv (GL_BLEND_DST, &aSaveBlendDst); - glGetIntegerv (GL_BLEND_SRC, &aSaveBlendSrc); - #endif - GLboolean wasZbuffEnabled = glIsEnabled (GL_DEPTH_TEST); - GLboolean wasBlendEnabled = glIsEnabled (GL_BLEND); - - // Change the properties for second rendering pass - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable (GL_BLEND); - - glDepthFunc (GL_EQUAL); - glDepthMask (GL_FALSE); - glEnable (GL_DEPTH_TEST); - - myWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX; - - // Render the view - renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate); - myWorkspace->DisableTexture(); - - // Restore properties back - glBlendFunc (aSaveBlendSrc, aSaveBlendDst); - if (!wasBlendEnabled) - glDisable (GL_BLEND); - - glDepthFunc (aSaveZbuffFunc); - glDepthMask (aSaveZbuffWrite); - if (!wasZbuffEnabled) - glDisable (GL_DEPTH_FUNC); - } - break; + // Render the view + renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate); + myWorkspace->DisableTexture(); + + // Restore properties back + glBlendFunc (aSaveBlendSrc, aSaveBlendDst); + if (!wasBlendEnabled) + glDisable (GL_BLEND); + + glDepthFunc (aSaveZbuffFunc); + glDepthMask (aSaveZbuffWrite); + if (!wasZbuffEnabled) + glDisable (GL_DEPTH_FUNC); } // Apply restored view matrix. diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 5ce42ab5c4..2fb3c3fc4c 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -970,12 +970,17 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th updateMaterial (TEL_BACK_MATERIAL); } - if ((NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0) + if (AspectFace_set->DoTextureMap()) { - if (AspectFace_set->DoTextureMap()) + EnableTexture (AspectFace_set->TextureRes (myGlContext), + AspectFace_set->TextureParams()); + } + else + { + if (!myEnvironmentTexture.IsNull()) { - EnableTexture (AspectFace_set->TextureRes (myGlContext), - AspectFace_set->TextureParams()); + EnableTexture (myEnvironmentTexture, + myEnvironmentTexture->GetParams()); } else { @@ -1094,6 +1099,8 @@ Handle(OpenGl_FrameBuffer) OpenGl_Workspace::FBOCreate (const Standard_Integer t if (!Activate()) return Handle(OpenGl_FrameBuffer)(); + DisableTexture(); + // create the FBO const Handle(OpenGl_Context)& aCtx = GetGlContext(); Handle(OpenGl_FrameBuffer) aFrameBuffer = new OpenGl_FrameBuffer(); diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index 3085c13af8..57d11d2d57 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -236,6 +236,18 @@ public: return myFrontCulling; } + //! Sets a new environment texture. + void SetEnvironmentTexture (const Handle(OpenGl_Texture)& theTexture) + { + myEnvironmentTexture = theTexture; + } + + //! Returns environment texture. + const Handle(OpenGl_Texture)& EnvironmentTexture() const + { + return myEnvironmentTexture; + } + protected: void updateMaterial (const int theFlag); @@ -281,6 +293,8 @@ protected: //! @name fields related to status OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect + Handle(OpenGl_Texture) myEnvironmentTexture; + public: //! @name type definition DEFINE_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient) diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index ea039d4ff3..693e094105 100644 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -546,10 +546,6 @@ static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, con TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName(); Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); - if (Draw::Atoi (argv[2])) - { - aViewer->SetDefaultSurfaceDetail (V3d_TEX_ALL); - } aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE); Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window(); Handle(V3d_View) aNewView = aViewer->CreateView(); diff --git a/src/V3d/FILES b/src/V3d/FILES index f69671b1dd..4b129d65b0 100755 --- a/src/V3d/FILES +++ b/src/V3d/FILES @@ -31,7 +31,6 @@ V3d_TypeOfPickCamera.hxx V3d_TypeOfPickLight.hxx V3d_TypeOfRepresentation.hxx V3d_TypeOfShadingModel.hxx -V3d_TypeOfSurfaceDetail.hxx V3d_TypeOfUpdate.hxx V3d_TypeOfView.hxx V3d_TypeOfVisualization.hxx diff --git a/src/V3d/V3d_TypeOfSurfaceDetail.hxx b/src/V3d/V3d_TypeOfSurfaceDetail.hxx deleted file mode 100644 index 929b6e0f86..0000000000 --- a/src/V3d/V3d_TypeOfSurfaceDetail.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// Created on: 1992-11-13 -// Created by: GG -// Copyright (c) 1992-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _V3d_TypeOfSurfaceDetail_HeaderFile -#define _V3d_TypeOfSurfaceDetail_HeaderFile - -//! Modes of visualization for objects in a view -//! - V3d_TEX_NONE: no texture mapping, -//! - V3d_TEX_ENVIRONMENT: environment mapping only, -//! - V3d_TEX_ALL: environment and texture mapping. -enum V3d_TypeOfSurfaceDetail -{ -V3d_TEX_NONE, -V3d_TEX_ENVIRONMENT, -V3d_TEX_ALL -}; - -#endif // _V3d_TypeOfSurfaceDetail_HeaderFile diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index f2c04933fa..dbc6a99f89 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -159,7 +159,6 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView th SetAxis (0.,0.,0.,1.,1.,1.); SetVisualization (theViewer->DefaultVisualization()); SetShadingModel (theViewer->DefaultShadingModel()); - SetSurfaceDetail (theViewer->DefaultSurfaceDetail()); SetTwist (0.); SetAt (0.,0.,0.); SetProj (theViewer->DefaultViewProj()); @@ -625,15 +624,6 @@ void V3d_View::SetShadingModel (const V3d_TypeOfShadingModel theShadingModel) myView->SetShadingModel (static_cast (theShadingModel)); } -//============================================================================= -//function : SetSurfaceDetail -//purpose : -//============================================================================= -void V3d_View::SetSurfaceDetail (const V3d_TypeOfSurfaceDetail theSurfaceDetail) -{ - myView->SetSurfaceDetailType (static_cast (theSurfaceDetail)); -} - //============================================================================= //function : SetTextureEnv //purpose : @@ -2421,15 +2411,6 @@ V3d_TypeOfShadingModel V3d_View::ShadingModel() const return static_cast (myView->ShadingModel()); } -//============================================================================= -//function : SurfaceDetail -//purpose : -//============================================================================= -V3d_TypeOfSurfaceDetail V3d_View::SurfaceDetail() const -{ - return static_cast (myView->SurfaceDetailType()); -} - //============================================================================= //function : TextureEnv //purpose : diff --git a/src/V3d/V3d_View.hxx b/src/V3d/V3d_View.hxx index cb6bc1045b..e9bdcf3cff 100644 --- a/src/V3d/V3d_View.hxx +++ b/src/V3d/V3d_View.hxx @@ -75,7 +75,6 @@ #include #include #include -#include #include #include #include @@ -260,9 +259,6 @@ public: //! Defines the shading model for the visualization. Various models are available. Standard_EXPORT void SetShadingModel (const V3d_TypeOfShadingModel theShadingModel); - //! Selects the kind of rendering for texture mapping. No texture mapping by default. - Standard_EXPORT void SetSurfaceDetail (const V3d_TypeOfSurfaceDetail theSurfaceDetail); - //! Sets the environment texture to use. No environment texture by default. Standard_EXPORT void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture); @@ -721,8 +717,6 @@ public: //! Returns the current shading model. Standard_EXPORT V3d_TypeOfShadingModel ShadingModel() const; - Standard_EXPORT V3d_TypeOfSurfaceDetail SurfaceDetail() const; - Standard_EXPORT Handle(Graphic3d_TextureEnv) TextureEnv() const; //! Returns the current visualisation mode. diff --git a/src/V3d/V3d_Viewer.cxx b/src/V3d/V3d_Viewer.cxx index 73079fce4c..d527a8c646 100644 --- a/src/V3d/V3d_Viewer.cxx +++ b/src/V3d/V3d_Viewer.cxx @@ -48,8 +48,7 @@ V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver, const V3d_TypeOfShadingModel theShadingModel, const V3d_TypeOfUpdate theUpdateMode, const Standard_Boolean theComputedMode, - const Standard_Boolean theDefaultComputedMode, - const V3d_TypeOfSurfaceDetail theSurfaceDetail) + const Standard_Boolean theDefaultComputedMode) :myNextCount (-1), myDriver (theDriver), myName (TCollection_ExtendedString (theName)), @@ -78,7 +77,6 @@ myZLayerGenId (1, IntegerLast()) SetDefaultBackgroundColor (theViewBackground); SetDefaultVisualization (theVisualization); SetDefaultShadingModel (theShadingModel); - SetDefaultSurfaceDetail (theSurfaceDetail); SetDefaultAngle (M_PI / 2.); SetDefaultTypeOfView (V3d_ORTHOGRAPHIC); @@ -319,11 +317,6 @@ void V3d_Viewer::SetDefaultShadingModel(const V3d_TypeOfShadingModel Type) { MyShadingModel = Type ; } -void V3d_Viewer::SetDefaultSurfaceDetail(const V3d_TypeOfSurfaceDetail Type) { - - MySurfaceDetail = Type ; -} - void V3d_Viewer::SetDefaultAngle(const Quantity_PlaneAngle Angle) { MyDefaultAngle = Angle; } @@ -372,10 +365,6 @@ V3d_TypeOfShadingModel V3d_Viewer::DefaultShadingModel() const { return MyShadingModel ; } -V3d_TypeOfSurfaceDetail V3d_Viewer::DefaultSurfaceDetail() const { - return MySurfaceDetail ; -} - Quantity_PlaneAngle V3d_Viewer::DefaultAngle() const { return MyDefaultAngle; } diff --git a/src/V3d/V3d_Viewer.hxx b/src/V3d/V3d_Viewer.hxx index e642f71c26..8088375c80 100644 --- a/src/V3d/V3d_Viewer.hxx +++ b/src/V3d/V3d_Viewer.hxx @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +90,7 @@ public: //! This limitation might be addressed in some future OCCT releases. //! If the size of the view is <= 0 //! Warning: Client must creates a graphic driver - Standard_EXPORT V3d_Viewer(const Handle(Graphic3d_GraphicDriver)& theDriver, const Standard_ExtString theName, const Standard_CString theDomain = "", const Quantity_Length theViewSize = 1000.0, const V3d_TypeOfOrientation theViewProj = V3d_XposYnegZpos, const Quantity_NameOfColor theViewBackground = Quantity_NOC_GRAY30, const V3d_TypeOfVisualization theVisualization = V3d_ZBUFFER, const V3d_TypeOfShadingModel theShadingModel = V3d_GOURAUD, const V3d_TypeOfUpdate theUpdateMode = V3d_WAIT, const Standard_Boolean theComputedMode = Standard_True, const Standard_Boolean theDefaultComputedMode = Standard_True, const V3d_TypeOfSurfaceDetail theSurfaceDetail = V3d_TEX_NONE); + Standard_EXPORT V3d_Viewer(const Handle(Graphic3d_GraphicDriver)& theDriver, const Standard_ExtString theName, const Standard_CString theDomain = "", const Quantity_Length theViewSize = 1000.0, const V3d_TypeOfOrientation theViewProj = V3d_XposYnegZpos, const Quantity_NameOfColor theViewBackground = Quantity_NOC_GRAY30, const V3d_TypeOfVisualization theVisualization = V3d_ZBUFFER, const V3d_TypeOfShadingModel theShadingModel = V3d_GOURAUD, const V3d_TypeOfUpdate theUpdateMode = V3d_WAIT, const Standard_Boolean theComputedMode = Standard_True, const Standard_Boolean theDefaultComputedMode = Standard_True); //! creates a view in the viewer according to its //! default parameters. @@ -179,9 +178,6 @@ public: //! Gives the default type of SHADING. Standard_EXPORT void SetDefaultShadingModel (const V3d_TypeOfShadingModel Type); - //! Gives the default type of texture mapping. - Standard_EXPORT void SetDefaultSurfaceDetail (const V3d_TypeOfSurfaceDetail Type); - Standard_EXPORT void SetDefaultAngle (const Quantity_PlaneAngle Angle); //! Defines the mode of regenerating the views making @@ -240,9 +236,6 @@ public: //! Returns the default type of Shading Standard_EXPORT V3d_TypeOfShadingModel DefaultShadingModel() const; - //! Returns the default type of texture mapping - Standard_EXPORT V3d_TypeOfSurfaceDetail DefaultSurfaceDetail() const; - Standard_EXPORT Quantity_PlaneAngle DefaultAngle() const; //! Returns the regeneration mode of views in the viewer. @@ -489,7 +482,6 @@ private: V3d_TypeOfOrientation MyViewProj; V3d_TypeOfVisualization MyVisualization; V3d_TypeOfShadingModel MyShadingModel; - V3d_TypeOfSurfaceDetail MySurfaceDetail; Quantity_PlaneAngle MyDefaultAngle; V3d_TypeOfView MyDefaultTypeOfView; Graphic3d_RenderingParams myDefaultRenderingParams; diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 1fc28ba9d2..13d4166f18 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -3201,8 +3201,6 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb, Standard_Integer aPreviousMode = 0; - ViewerTest::CurrentView()->SetSurfaceDetail (V3d_TEX_ALL); - TCollection_AsciiString aShapeName (theArgv[1]); Handle(AIS_InteractiveObject) anIO; diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index f882441b80..9e63f23627 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -4473,21 +4473,7 @@ static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** ar } else if (argc < 2) { - di << "Use: vzlayer "; - di << " add/del/get/settings/enable/disable [id]\n"; - di << " add - add new z layer to viewer and print its id\n"; - di << " del - del z layer by its id\n"; - di << " get - print sequence of z layers in increasing order of their overlay level\n"; - di << " settings - print status of z layer settings\n"; - di << " enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n"; - di << " enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n"; - di << " disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n"; - di << "\nWhere id is the layer identificator\n"; - di << "\nExamples:\n"; - di << " vzlayer add\n"; - di << " vzlayer enable poffset 1\n"; - di << " vzlayer disable depthtest 1\n"; - di << " vzlayer del 1\n"; + di << di.PrintHelp (argv[0]); return 1; } @@ -4625,6 +4611,10 @@ static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** ar { aSettings.SetDepthOffsetNegative(); } + else if (aSubOp == "textureenv") + { + aSettings.UseEnvironmentTexture = true; + } aViewer->SetZLayerSettings (anId, aSettings); } @@ -4662,6 +4652,10 @@ static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** ar { aSettings.DisableSetting (Graphic3d_ZLayerDepthOffset); } + else if (aSubOp == "textureenv") + { + aSettings.UseEnvironmentTexture = false; + } aViewer->SetZLayerSettings (anId, aSettings); } @@ -6572,11 +6566,9 @@ static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb, ); } aView->SetTextureEnv(aTexEnv); - aView->SetSurfaceDetail(V3d_TEX_ENVIRONMENT); } else // Disabling environment mapping { - aView->SetSurfaceDetail(V3d_TEX_NONE); Handle(Graphic3d_TextureEnv) aTexture; aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data } @@ -6980,40 +6972,6 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons return 1; } -//=============================================================================================== -//function : VSetTextureMode -//purpose : -//=============================================================================================== -static int VSetTextureMode (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) -{ - if (theArgsNb < 3) - { - theDi << theArgVec[0] << ": insufficient command arguments. Type help for more information.\n"; - return 1; - } - - TCollection_AsciiString aViewName (theArgVec[1]); - if (!ViewerTest_myViews.IsBound1 (aViewName)) - { - theDi << theArgVec[0] << ": view is not found.\n"; - return 1; - } - - const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName); - switch (atoi (theArgVec[2])) - { - case 0: aView->SetSurfaceDetail (V3d_TEX_NONE); break; - case 1: aView->SetSurfaceDetail (V3d_TEX_ENVIRONMENT); break; - case 2: aView->SetSurfaceDetail (V3d_TEX_ALL); break; - default: - theDi << theArgVec[0] << ": invalid mode.\n"; - return 1; - } - - aView->Redraw(); - return 0; -} - //=============================================================================================== //function : VZRange //purpose : @@ -9023,7 +8981,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) " settings - print status of z layer settings\n" " enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n" " enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n" + " enable textureenv \n enables environment texture mapping\n" " disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n" + " disable textureenv \n disables environment texture mapping\n" "\nWhere id is the layer identificator\n" "\nExamples:\n" " vzlayer add\n" @@ -9278,13 +9238,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) " change capping hatch on/off/ - set hatching mask.\n" " please use VSetTextureMode command to enable texture rendering in view.\n" , __FILE__, VClipPlane, group); - theCommands.Add("vsettexturemode", "vsettexturemode view_name mode \n" - " mode can be:\n" - " 0 - no textures enabled in view.\n" - " 1 - only environment textures enabled.\n" - " 2 - all textures enabled.\n" - " this command sets texture details mode for the specified view.\n" - , __FILE__, VSetTextureMode, group); theCommands.Add("vdefaults", "vdefaults [-absDefl value]" "\n\t\t: [-devCoeff value]" diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index 85fede6756..f0b3482391 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -839,11 +839,6 @@ static Standard_Integer meshcolors( Draw_Interpretor& di, aBuilder->SetInvalidColor(Quantity_NOC_BLACK); aBuilder->SetTextureCoords(aScaleMap); aMesh->AddBuilder(aBuilder, Standard_True); - - //set viewer to display texures - const Handle(V3d_Viewer)& aViewer = anIC->CurrentViewer(); - for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) - aViewer->ActiveView()->SetSurfaceDetail(V3d_TEX_ALL); } aMesh->GetDrawer()->SetBoolean ( MeshVS_DA_ColorReflection, Standard_Boolean(aReflection) ); diff --git a/tests/bugs/vis/bug24622 b/tests/bugs/vis/bug24622 index 8b509f6588..df2fbc5bd1 100644 --- a/tests/bugs/vis/bug24622 +++ b/tests/bugs/vis/bug24622 @@ -12,7 +12,6 @@ set aV2 "Driver1/Viewer2/View1" vinit name=$aV1 l=32 t=32 w=400 h=400 vinit name=$aV2 l=32 t=32 w=400 h=400 vactivate $aV1 -vsettexturemode $aV1 2 vclear OCC24622 1D @@ -32,7 +31,6 @@ if { $stat != 1 } { } vactivate $aV2 -vsettexturemode $aV2 2 vclear OCC24622 2D diff --git a/tests/bugs/vis/bug26434 b/tests/bugs/vis/bug26434 new file mode 100644 index 0000000000..565d189024 --- /dev/null +++ b/tests/bugs/vis/bug26434 @@ -0,0 +1,42 @@ +puts "============" +puts "CR26434" +puts "============" +puts "" + +########################################################################################## +puts "Visualization - Textured objects should have priority over the environment mapping" +########################################################################################## + +pload MODELING VISUALIZATION + +vclear +vclose all + +vinit View1 + +vsetdispmode 1 + +box b0 -1 -1 -1 1 2 3 +box b1 1 1 1 1 2 3 + +vdisplay b0 b1 +vzbufftrihedron + +vfit + +vdump $imagedir/${casename}_0.png + +vtexture b1 0 + +vdump $imagedir/${casename}_1.png + +puts "Checking that texture have priority over the environment mapping" +vtextureenv on 0 + +vdump $imagedir/${casename}_2.png + +vcaps -ffp 0 +vmoveto 100 300 +vmoveto 0 0 + +vdump $imagedir/${casename}_3.png -- 2.20.1