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.
* 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.
// 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");
" // 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);
}
//////////////////////////////////////////////////////////////////////
// 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");
" // 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);
}
//////////////////////////////////////////////////////////////////////
// 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",
" // 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");
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);
V3d_GOURAUD,
V3d_WAIT,
theComputedMode,
- theDefaultComputedMode,
- V3d_TEX_NONE);
+ theDefaultComputedMode);
}
DocumentCommon::DocumentCommon( const int theIndex, ApplicationCommonWindow* app )
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();
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
Graphic3d_TypeOfShaderObject.hxx
Graphic3d_TypeOfShadingModel.hxx
Graphic3d_TypeOfStructure.hxx
-Graphic3d_TypeOfSurfaceDetail.hxx
Graphic3d_TypeOfTexture.hxx
Graphic3d_TypeOfTextureFilter.hxx
Graphic3d_TypeOfTextureMode.hxx
SetTextureEnv (theOther->TextureEnv());
SetCullingEnabled (theOther->IsCullingEnabled());
SetShadingModel (theOther->ShadingModel());
- SetSurfaceDetailType (theOther->SurfaceDetailType());
SetBackfacingModel (theOther->BackfacingModel());
SetCamera (new Graphic3d_Camera (theOther->Camera()));
SetBackZClippingOn (theOther->BackZClippingIsOn());
#include <Graphic3d_TypeOfAnswer.hxx>
#include <Graphic3d_TypeOfBackfacingModel.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
-#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <Graphic3d_TypeOfVisualization.hxx>
#include <Graphic3d_Vec3.hxx>
#include <Graphic3d_ZLayerId.hxx>
//! 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;
+++ /dev/null
-// 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
Flags (Graphic3d_ZLayerDepthTest
| Graphic3d_ZLayerDepthWrite
| Graphic3d_ZLayerDepthClear),
- IsImmediate (false)
+ IsImmediate (false),
+ UseEnvironmentTexture (true)
{}
//! Returns true if theSetting is enabled.
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
};
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);
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);
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))
{
theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
anAppliedOffsetParams.factor,
anAppliedOffsetParams.units);
+
+ // restore environment texture
+ if (!myLayerSettings.UseEnvironmentTexture)
+ {
+ theWorkspace->SetEnvironmentTexture (anEnvironmentTexture);
+ }
}
#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
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;
}
}
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
{
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_StereoMode.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
-#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Sequence.hxx>
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()
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);
}
//! 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.
{
aBits |= OpenGl_PO_ClipPlanes;
}
- if (theEnableEnvMap && mySurfaceDetailState.Detail() == Graphic3d_TOD_ENVIRONMENT)
+ if (theEnableEnvMap)
{
// Environment map overwrites material texture
aBits |= OpenGl_PO_TextureEnv;
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:
#ifndef _OpenGl_State_HeaderFile
#define _OpenGl_State_HeaderFile
-#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <InterfaceGraphic_tgl_all.hxx>
#include <NCollection_List.hxx>
#include <OpenGl_Element.hxx>
};
-//! 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
myAntiAliasing (Standard_False),
myCulling (Standard_True),
myShadingModel (Graphic3d_TOSM_FACET),
- mySurfaceDetail (Graphic3d_TOD_ALL),
myBackfacing (Graphic3d_TOBM_AUTOMATIC),
myBgColor (myDefaultBg),
myFog (myDefaultFog),
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
-#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <Graphic3d_WorldViewProjState.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
//! 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; }
Standard_Boolean myAntiAliasing;
Standard_Boolean myCulling;
Graphic3d_TypeOfShadingModel myShadingModel;
- Graphic3d_TypeOfSurfaceDetail mySurfaceDetail;
Graphic3d_TypeOfBackfacingModel myBackfacing;
TEL_COLOUR myBgColor;
OPENGL_FOG myFog;
{
aResult &= theGlContext->BindProgram (aProgram);
- if (!myTextureEnv.IsNull() && mySurfaceDetail != Graphic3d_TOD_NONE)
+ if (!myTextureEnv.IsNull())
{
myTextureEnv->Bind (theGlContext,
GL_TEXTURE0 + OpenGl_RT_EnvironmentMapTexture);
aContext->ProjectionState.SetCurrent (myCamera->ProjectionStereoRightF());
aContext->ApplyProjectionMatrix();
}
+
+ myWorkspace->SetEnvironmentTexture (myTextureEnv);
+
renderScene (theProjection, theOutputFBO, theToDrawImmediate);
+ myWorkspace->SetEnvironmentTexture (Handle(OpenGl_Texture)());
+
// ===============================
// Step 4: Trihedron
// ===============================
// 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)
{
// 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.
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
{
if (!Activate())
return Handle(OpenGl_FrameBuffer)();
+ DisableTexture();
+
// create the FBO
const Handle(OpenGl_Context)& aCtx = GetGlContext();
Handle(OpenGl_FrameBuffer) aFrameBuffer = new OpenGl_FrameBuffer();
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);
OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
+ Handle(OpenGl_Texture) myEnvironmentTexture;
+
public: //! @name type definition
DEFINE_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
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();
V3d_TypeOfPickLight.hxx
V3d_TypeOfRepresentation.hxx
V3d_TypeOfShadingModel.hxx
-V3d_TypeOfSurfaceDetail.hxx
V3d_TypeOfUpdate.hxx
V3d_TypeOfView.hxx
V3d_TypeOfVisualization.hxx
+++ /dev/null
-// 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
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());
myView->SetShadingModel (static_cast<Graphic3d_TypeOfShadingModel> (theShadingModel));
}
-//=============================================================================
-//function : SetSurfaceDetail
-//purpose :
-//=============================================================================
-void V3d_View::SetSurfaceDetail (const V3d_TypeOfSurfaceDetail theSurfaceDetail)
-{
- myView->SetSurfaceDetailType (static_cast<Graphic3d_TypeOfSurfaceDetail> (theSurfaceDetail));
-}
-
//=============================================================================
//function : SetTextureEnv
//purpose :
return static_cast<V3d_TypeOfShadingModel> (myView->ShadingModel());
}
-//=============================================================================
-//function : SurfaceDetail
-//purpose :
-//=============================================================================
-V3d_TypeOfSurfaceDetail V3d_View::SurfaceDetail() const
-{
- return static_cast<V3d_TypeOfSurfaceDetail> (myView->SurfaceDetailType());
-}
-
//=============================================================================
//function : TextureEnv
//purpose :
#include <V3d_TypeOfBackfacingModel.hxx>
#include <V3d_TypeOfOrientation.hxx>
#include <V3d_TypeOfShadingModel.hxx>
-#include <V3d_TypeOfSurfaceDetail.hxx>
#include <V3d_TypeOfView.hxx>
#include <V3d_TypeOfVisualization.hxx>
#include <V3d_TypeOfZclipping.hxx>
//! 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);
//! 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.
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)),
SetDefaultBackgroundColor (theViewBackground);
SetDefaultVisualization (theVisualization);
SetDefaultShadingModel (theShadingModel);
- SetDefaultSurfaceDetail (theSurfaceDetail);
SetDefaultAngle (M_PI / 2.);
SetDefaultTypeOfView (V3d_ORTHOGRAPHIC);
MyShadingModel = Type ;
}
-void V3d_Viewer::SetDefaultSurfaceDetail(const V3d_TypeOfSurfaceDetail Type) {
-
- MySurfaceDetail = Type ;
-}
-
void V3d_Viewer::SetDefaultAngle(const Quantity_PlaneAngle Angle) {
MyDefaultAngle = Angle;
}
return MyShadingModel ;
}
-V3d_TypeOfSurfaceDetail V3d_Viewer::DefaultSurfaceDetail() const {
- return MySurfaceDetail ;
-}
-
Quantity_PlaneAngle V3d_Viewer::DefaultAngle() const {
return MyDefaultAngle;
}
#include <V3d_ListOfTransient.hxx>
#include <V3d_TypeOfOrientation.hxx>
#include <V3d_TypeOfShadingModel.hxx>
-#include <V3d_TypeOfSurfaceDetail.hxx>
#include <V3d_TypeOfUpdate.hxx>
#include <V3d_TypeOfView.hxx>
#include <V3d_TypeOfVisualization.hxx>
//! 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.
//! 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
//! 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.
V3d_TypeOfOrientation MyViewProj;
V3d_TypeOfVisualization MyVisualization;
V3d_TypeOfShadingModel MyShadingModel;
- V3d_TypeOfSurfaceDetail MySurfaceDetail;
Quantity_PlaneAngle MyDefaultAngle;
V3d_TypeOfView MyDefaultTypeOfView;
Graphic3d_RenderingParams myDefaultRenderingParams;
Standard_Integer aPreviousMode = 0;
- ViewerTest::CurrentView()->SetSurfaceDetail (V3d_TEX_ALL);
-
TCollection_AsciiString aShapeName (theArgv[1]);
Handle(AIS_InteractiveObject) anIO;
}
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;
}
{
aSettings.SetDepthOffsetNegative();
}
+ else if (aSubOp == "textureenv")
+ {
+ aSettings.UseEnvironmentTexture = true;
+ }
aViewer->SetZLayerSettings (anId, aSettings);
}
{
aSettings.DisableSetting (Graphic3d_ZLayerDepthOffset);
}
+ else if (aSubOp == "textureenv")
+ {
+ aSettings.UseEnvironmentTexture = false;
+ }
aViewer->SetZLayerSettings (anId, aSettings);
}
);
}
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
}
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 :
" 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"
" change <plane_name> capping hatch on/off/<id> - 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]"
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) );
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
}
vactivate $aV2
-vsettexturemode $aV2 2
vclear
OCC24622 2D
--- /dev/null
+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