diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index e6ed01acc9..f94652a1fd 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -68,7 +68,6 @@ OpenGl_PriorityList.hxx OpenGl_PriorityList.cxx OpenGl_AVIWriter.hxx OpenGl_AVIWriter.cxx -OpenGl_tsm.hxx OpenGl_FrameBuffer.hxx OpenGl_FrameBuffer.cxx OpenGl_Texture.cxx diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index a4125db8f4..7c82cd8b6e 100755 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -193,7 +193,7 @@ Standard_Boolean OpenGl_GraphicDriver::GetOpenClDeviceInfo (const Graphic3d_CVie { return Standard_False; } - + return reinterpret_cast (theCView.ptrView)->WS->GetOpenClDeviceInfo (theInfo); } @@ -347,7 +347,7 @@ void OpenGl_GraphicDriver::SetStencilTestOptions (const Graphic3d_CGroup& theCGr { OpenGl_StencilTest* aStencilTest = new OpenGl_StencilTest(); aStencilTest->SetOptions (theIsEnabled); - ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelNil, aStencilTest); + ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aStencilTest); } // ======================================================================= @@ -375,7 +375,7 @@ void OpenGl_GraphicDriver::Text (const Graphic3d_CGroup& theCGro aParams.VAlign = theVta; const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z()); OpenGl_Text* aText = new OpenGl_Text (theText, aPoint, aParams); - ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelText, aText); + ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aText); } // ======================================================================= @@ -589,5 +589,5 @@ void OpenGl_GraphicDriver::SetFlippingOptions (const Graphic3d_CGroup& theCGroup { OpenGl_Flipper* aFlipper = new OpenGl_Flipper (theRefPlane); aFlipper->SetOptions (theIsEnabled); - ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelNil, aFlipper); + ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aFlipper); } diff --git a/src/OpenGl/OpenGl_GraphicDriver_713.cxx b/src/OpenGl/OpenGl_GraphicDriver_713.cxx index d64d6031fe..cacd95546f 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_713.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_713.cxx @@ -69,7 +69,7 @@ void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup, if ( ACGroup.ptrGroup && parray ) { OpenGl_PrimitiveArray *aparray = new OpenGl_PrimitiveArray( (CALL_DEF_PARRAY *) parray ); - ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelParray, aparray ); + ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement (aparray); } } @@ -82,7 +82,7 @@ void OpenGl_GraphicDriver::UserDraw (const Graphic3d_CGroup& theCGroup, OpenGl_Element* aUserDraw = myUserDrawCallback(&theUserDraw); if (aUserDraw != NULL) { - ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelUserdraw, aUserDraw); + ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aUserDraw); } } } diff --git a/src/OpenGl/OpenGl_Group.cxx b/src/OpenGl/OpenGl_Group.cxx index 266d096035..2c1da8b127 100644 --- a/src/OpenGl/OpenGl_Group.cxx +++ b/src/OpenGl/OpenGl_Group.cxx @@ -73,7 +73,7 @@ void OpenGl_Group::SetAspectLine (const CALL_DEF_CONTEXTLINE& theAspect, { OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine(); anAspectLine->SetAspect (theAspect); - AddElement (TelNil/*TelAspectLine*/, anAspectLine); + AddElement (anAspectLine); } } @@ -96,7 +96,7 @@ void OpenGl_Group::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect, { OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace(); anAspectFace->SetAspect (theAspect); - AddElement (TelNil/*TelAspectFace*/, anAspectFace); + AddElement (anAspectFace); } #ifdef HAVE_OPENCL @@ -131,7 +131,7 @@ void OpenGl_Group::SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect, { OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker(); anAspectMarker->SetAspect (theAspect); - AddElement (TelNil/*TelAspectMarker*/, anAspectMarker); + AddElement (anAspectMarker); } } @@ -154,7 +154,7 @@ void OpenGl_Group::SetAspectText (const CALL_DEF_CONTEXTTEXT& theAspect, { OpenGl_AspectText* anAspectText = new OpenGl_AspectText(); anAspectText->SetAspect (theAspect); - AddElement ( TelNil/*TelAspectText*/, anAspectText); + AddElement (anAspectText); } } @@ -162,11 +162,10 @@ void OpenGl_Group::SetAspectText (const CALL_DEF_CONTEXTTEXT& theAspect, // function : AddElement // purpose : // ======================================================================= -void OpenGl_Group::AddElement (const TelType theType, OpenGl_Element *theElem) +void OpenGl_Group::AddElement (OpenGl_Element* theElem) { OpenGl_ElementNode *aNode = new OpenGl_ElementNode(); - aNode->type = theType; aNode->elem = theElem; aNode->next = NULL; (myLast? myLast->next : myFirst) = aNode; @@ -194,7 +193,6 @@ void OpenGl_Group::AddElement (const TelType theType, OpenGl_Element *theElem) void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { // Is rendering in ADD or IMMEDIATE mode? - const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0; const Handle(OpenGl_RenderFilter)& aFilter = theWorkspace->GetRenderFilter(); // Setup aspects @@ -210,27 +208,7 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const // Render group elements for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next) { - switch (aNodeIter->type) - { - case TelMarker: - case TelMarkerSet: - case TelText: - { - glDisable (GL_LIGHTING); - if (isImmediate) - { - glDepthMask (GL_FALSE); - } - - aNodeIter->elem->RenderFiltered (theWorkspace, aFilter); - break; - } - default: - { - aNodeIter->elem->RenderFiltered (theWorkspace, aFilter); - break; - } - } + aNodeIter->elem->RenderFiltered (theWorkspace, aFilter); } // Restore aspects diff --git a/src/OpenGl/OpenGl_Group.hxx b/src/OpenGl/OpenGl_Group.hxx index 092d6b9933..d65c3178d6 100644 --- a/src/OpenGl/OpenGl_Group.hxx +++ b/src/OpenGl/OpenGl_Group.hxx @@ -26,18 +26,15 @@ #include #include -#include - class OpenGl_Group; class OpenGl_Structure; -typedef NCollection_List OpenGl_ListOfGroup; +typedef NCollection_List OpenGl_ListOfGroup; struct OpenGl_ElementNode { - TelType type; - OpenGl_Element *elem; - OpenGl_ElementNode *next; + OpenGl_Element* elem; + OpenGl_ElementNode* next; DEFINE_STANDARD_ALLOC }; @@ -56,7 +53,7 @@ public: void SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect, const Standard_Boolean IsGlobal = Standard_True); void SetAspectText (const CALL_DEF_CONTEXTTEXT& theAspect, const Standard_Boolean IsGlobal = Standard_True); - void AddElement (const TelType, OpenGl_Element * ); + void AddElement (OpenGl_Element* theElem); virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; virtual void Release (const Handle(OpenGl_Context)& theGlCtx); @@ -90,7 +87,7 @@ protected: OpenGl_ElementNode* myFirst; OpenGl_ElementNode* myLast; - + #ifdef HAVE_OPENCL const OpenGl_Structure* myAncestorStructure; Standard_Boolean myIsRaytracable; diff --git a/src/OpenGl/OpenGl_SceneGeometry.cxx b/src/OpenGl/OpenGl_SceneGeometry.cxx index ede32b5ffc..b45e5856fd 100755 --- a/src/OpenGl/OpenGl_SceneGeometry.cxx +++ b/src/OpenGl/OpenGl_SceneGeometry.cxx @@ -163,7 +163,7 @@ struct OpenGL_BVHParallelBuilder { OpenGl_TriangleSet* aTriangleSet = dynamic_cast ( Set->Objects().ChangeValue (static_cast (anObjectIdx)).operator->()); - + if (aTriangleSet != NULL) { aTriangleSet->BVH(); @@ -183,7 +183,7 @@ Standard_Boolean OpenGl_RaytraceGeometry::ProcessAcceleration() #ifdef BVH_PRINT_INFO OSD_Timer aTimer; #endif - + MarkDirty(); // force BVH rebuilding #ifdef BVH_PRINT_INFO @@ -197,7 +197,7 @@ Standard_Boolean OpenGl_RaytraceGeometry::ProcessAcceleration() tbb::parallel_for (tbb::blocked_range (0, Size()), OpenGL_BVHParallelBuilder (this)); #endif - + for (Standard_Integer anObjectIdx = 0; anObjectIdx < Size(); ++anObjectIdx) { OpenGl_TriangleSet* aTriangleSet = dynamic_cast ( @@ -205,7 +205,7 @@ Standard_Boolean OpenGl_RaytraceGeometry::ProcessAcceleration() Standard_ASSERT_RETURN (aTriangleSet != NULL, "Error! Failed to get triangulation of OpenGL element", Standard_False); - + Standard_ASSERT_RETURN (!aTriangleSet->BVH().IsNull(), "Error! Failed to update bottom-level BVH of OpenGL element", Standard_False); } @@ -323,7 +323,7 @@ OpenGl_TriangleSet* OpenGl_RaytraceGeometry::TriangleSet (Standard_Integer theNo if (aBVH->NodeInfoBuffer().at (theNodeIdx).x() > myObjects.Size()) return NULL; - + return dynamic_cast (myObjects.ChangeValue ( aBVH->NodeInfoBuffer().at (theNodeIdx).x() - 1).operator->()); } @@ -336,12 +336,9 @@ namespace OpenGl_Raytrace // ======================================================================= Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode) { - if (TelParray == theNode->type) - { - OpenGl_PrimitiveArray* anArray = dynamic_cast< OpenGl_PrimitiveArray* > (theNode->elem); - return anArray->PArray()->type >= TelPolygonsArrayType; - } - return Standard_False; + OpenGl_PrimitiveArray* anArray = dynamic_cast< OpenGl_PrimitiveArray* > (theNode->elem); + return anArray != NULL + && anArray->PArray()->type >= TelPolygonsArrayType; } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index b675cb321f..727586d742 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -283,7 +283,7 @@ void OpenGl_Structure::SetHighlightBox (const Handle(OpenGl_Context)& theGlCtx, myHighlightBox->SetAspectLine (aContextLine); OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (theBoundBox); - myHighlightBox->AddElement (TelParray, aBndBoxPrs); + myHighlightBox->AddElement (aBndBoxPrs); } // ======================================================================= @@ -359,7 +359,7 @@ void OpenGl_Structure::RegisterAncestorStructure (const OpenGl_Structure* theStr if (anIt.Value() == theStructure) { return; - } + } } myAncestorStructures.Append (theStructure); @@ -377,7 +377,7 @@ void OpenGl_Structure::UnregisterAncestorStructure (const OpenGl_Structure* theS { myAncestorStructures.Remove (anIt); return; - } + } } } @@ -397,7 +397,7 @@ void OpenGl_Structure::UnregisterFromAncestorStructure() const { anAncestor->myConnected.Remove (anIts); return; - } + } } } } @@ -564,7 +564,7 @@ void OpenGl_Structure::Clear (const Handle(OpenGl_Context)& theGlCtx) #ifdef HAVE_OPENCL aRaytracableGroupDeleted |= anIter.Value()->IsRaytracable(); #endif - + // Delete objects OpenGl_Element::Destroy (theGlCtx, const_cast (anIter.ChangeValue())); } diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index f94dda261d..5e9e7335e3 100755 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -394,10 +394,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const aProgram->BindWithVariables (aCtx); const OpenGl_MaterialState* aMaterialState = aCtx->ShaderManager()->MaterialState (aProgram); - + if (aMaterialState == NULL || aMaterialState->Aspect() != aTextAspect) aCtx->ShaderManager()->UpdateMaterialStateTo (aProgram, aTextAspect); - + aCtx->ShaderManager()->PushState (aProgram); } else @@ -709,6 +709,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, // push enabled flags to the stack glPushAttrib (GL_ENABLE_BIT); + glDisable (GL_LIGHTING); // setup depth test if (!myIs2d diff --git a/src/OpenGl/OpenGl_Texture.hxx b/src/OpenGl/OpenGl_Texture.hxx index b6c708394c..68cd57713c 100644 --- a/src/OpenGl/OpenGl_Texture.hxx +++ b/src/OpenGl/OpenGl_Texture.hxx @@ -136,20 +136,16 @@ public: private: //! Creates new texture format. - OpenGl_TextureFormat (const GLint theChannels, const GLint theInternal) - : myChannels (theChannels), - myInternal (theInternal) - { - // - } + OpenGl_TextureFormat (const GLint theChannels, + const GLint theInternal) + : myInternal (theInternal), + myChannels (theChannels) {} private: - //! OpenGL internal format of the pixel data. - GLint myInternal; + GLint myInternal; //!< OpenGL internal format of the pixel data + GLint myChannels; //!< Number of channels for each pixel (from 1 to 4) - //! Number of channels for each pixel (from 1 to 4). - GLint myChannels; }; //! Texture resource. diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index ca0ab39cac..923441efff 100755 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -44,8 +44,6 @@ #include -#include - #include #include #include @@ -211,14 +209,14 @@ public: //! @param theFilter [in] the filter instance. inline void SetRenderFilter (const Handle(OpenGl_RenderFilter)& theFilter) { - myRenderFilter = theFilter; + myRenderFilter = theFilter; } //! Get rendering filter. //! @return filter instance. - inline const Handle(OpenGl_RenderFilter)& GetRenderFilter() const - { - return myRenderFilter; + inline const Handle(OpenGl_RenderFilter)& GetRenderFilter() const + { + return myRenderFilter; } //! @return applied view matrix. @@ -275,7 +273,7 @@ protected: //! @name methods related to ray-tracing //! Updates environment map for ray-tracing. Standard_Boolean UpdateRaytraceEnvironmentMap(); - + //! Adds OpenGL structure to ray-traced scene geometry. Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure, const Standard_ShortReal* theTransform, std::set& theElements); @@ -314,7 +312,7 @@ protected: //! @name methods related to ray-tracing //! Initializes OpenCL resources. Standard_Boolean InitOpenCL(); - + //! Releases OpenCL resources. void ReleaseOpenCL(); @@ -353,7 +351,7 @@ protected: //! @name fields related to ray-tracing Standard_Boolean myIsRaytraceDataValid; //! Is geometry data musty be updated? Standard_Boolean myToUpdateRaytraceData; - + //! 3D scene geometry data for ray-tracing. OpenGl_RaytraceGeometry myRaytraceGeometry; diff --git a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx index 8f8e436b7d..9c2bd577ab 100755 --- a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx +++ b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx @@ -406,24 +406,19 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure* // Add OpenGL elements from group (extract primitives arrays and aspects) for (const OpenGl_ElementNode* aNode = anItg.Value()->FirstNode(); aNode != NULL; aNode = aNode->next) { - if (TelNil == aNode->type) + OpenGl_AspectFace* anAspect = dynamic_cast (aNode->elem); + if (anAspect != NULL) { - OpenGl_AspectFace* anAspect = dynamic_cast (aNode->elem); + aMatID = static_cast (myRaytraceGeometry.Materials.size()); - if (anAspect != NULL) - { - aMatID = static_cast (myRaytraceGeometry.Materials.size()); + OpenGl_RaytraceMaterial aMaterial; + CreateMaterial (anAspect->IntFront(), aMaterial); - OpenGl_RaytraceMaterial aMaterial; - CreateMaterial (anAspect->IntFront(), aMaterial); - - myRaytraceGeometry.Materials.push_back (aMaterial); - } + myRaytraceGeometry.Materials.push_back (aMaterial); } - else if (TelParray == aNode->type) + else { OpenGl_PrimitiveArray* aPrimArray = dynamic_cast (aNode->elem); - if (aPrimArray != NULL) { NCollection_Handle > aSet = @@ -608,7 +603,7 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceVertexIndices (OpenGl_TriangleSet* case TelTriangleFansArrayType: return AddRaytraceTriangleFanArray (theSet, theArray, theOffset, theCount, theMatID); - case TelTriangleStripsArrayType: + case TelTriangleStripsArrayType: return AddRaytraceTriangleStripArray (theSet, theArray, theOffset, theCount, theMatID); case TelQuadrangleStripsArrayType: @@ -1242,7 +1237,7 @@ void OpenGl_Workspace::ReleaseOpenCL() clReleaseProgram (myRaytraceProgram); clReleaseCommandQueue (myComputeQueue); - + clReleaseMemObject (myRaytraceOutputImage); clReleaseMemObject (myRaytraceEnvironment); clReleaseMemObject (myRaytraceOutputImageAA); @@ -1304,15 +1299,15 @@ Standard_Boolean OpenGl_Workspace::ResizeRaytraceOutputBuffer (const cl_int theS myGlContext->DelayedRelease (myRaytraceOutputTextureAA); } } - + myRaytraceOutputTexture = new OpenGl_Texture(); - + myRaytraceOutputTexture->Create (myGlContext); myRaytraceOutputTexture->InitRectangle (myGlContext, theSizeX, theSizeY, OpenGl_TextureFormat::Create()); - + myRaytraceOutputTextureAA = new OpenGl_Texture(); - + myRaytraceOutputTextureAA->Create (myGlContext); myRaytraceOutputTextureAA->InitRectangle (myGlContext, theSizeX, theSizeY, OpenGl_TextureFormat::Create()); @@ -1422,7 +1417,7 @@ Standard_Boolean OpenGl_Workspace::WriteRaytraceSceneToDevice() cl_int anErrorTmp = CL_SUCCESS; const NCollection_Handle >& aBVH = myRaytraceGeometry.BVH(); - + const size_t aSceneMinPointBufferSize = aBVH->MinPointBuffer().size() != 0 ? aBVH->MinPointBuffer().size() : 1; @@ -1472,7 +1467,7 @@ Standard_Boolean OpenGl_Workspace::WriteRaytraceSceneToDevice() aTotalBVHNodesNb += aTriangleSet->BVH()->NodeInfoBuffer().size(); } - + aTotalBVHNodesNb = aTotalBVHNodesNb > 0 ? aTotalBVHNodesNb : 1; myObjectNodeInfoBuffer = clCreateBuffer (myComputeContext, @@ -1647,9 +1642,9 @@ Standard_Boolean OpenGl_Workspace::WriteRaytraceSceneToDevice() #endif #ifdef RAY_TRACE_PRINT_INFO - + Standard_ShortReal aMemUsed = 0.f; - + for (Standard_Integer anElemIdx = 0; anElemIdx < myRaytraceGeometry.Size(); ++anElemIdx) { OpenGl_TriangleSet* aTriangleSet = dynamic_cast ( @@ -1669,7 +1664,7 @@ Standard_Boolean OpenGl_Workspace::WriteRaytraceSceneToDevice() aMemUsed += static_cast ( aTriangleSet->BVH()->MaxPointBuffer().size() * sizeof (BVH_Vec4f)); } - + aMemUsed += static_cast ( myRaytraceGeometry.BVH()->NodeInfoBuffer().size() * sizeof (BVH_Vec4i)); aMemUsed += static_cast ( @@ -1758,7 +1753,7 @@ Standard_Boolean OpenGl_Workspace::RunRaytraceOpenCLKernels (const Graphic3d_CVi if (anError != CL_SUCCESS) { const TCollection_ExtendedString aMessage = "Error! Failed to set arguments of ray-tracing kernel!"; - + myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMessage); diff --git a/src/OpenGl/OpenGl_tsm.hxx b/src/OpenGl/OpenGl_tsm.hxx deleted file mode 100644 index caa96f9415..0000000000 --- a/src/OpenGl/OpenGl_tsm.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 1995-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 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 OPENGL_TSM_H -#define OPENGL_TSM_H - -typedef enum -{ - TelNil = 0, - TelMarker, - TelMarkerSet, - TelText, - TelParray, - TelUserdraw, - TelLast -} TelType; - -#endif