File indexing completed on 2025-01-18 10:04:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef OpenGl_Workspace_HeaderFile
0017 #define OpenGl_Workspace_HeaderFile
0018
0019 #include <Graphic3d_BufferType.hxx>
0020 #include <Graphic3d_PresentationAttributes.hxx>
0021
0022 #include <OpenGl_Aspects.hxx>
0023 #include <OpenGl_Vec.hxx>
0024
0025 class OpenGl_FrameBuffer;
0026 class OpenGl_Group;
0027 class OpenGl_View;
0028 class OpenGl_Window;
0029 class Image_PixMap;
0030
0031 class OpenGl_Workspace;
0032 DEFINE_STANDARD_HANDLE(OpenGl_Workspace,Standard_Transient)
0033
0034
0035
0036 class OpenGl_Workspace : public Standard_Transient
0037 {
0038 public:
0039
0040
0041 Standard_EXPORT OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow);
0042
0043
0044 virtual ~OpenGl_Workspace() {}
0045
0046
0047 Standard_EXPORT Standard_Boolean Activate();
0048
0049 OpenGl_View* View() const { return myView; }
0050
0051 const Handle(OpenGl_Context)& GetGlContext() { return myGlContext; }
0052
0053 Standard_EXPORT Handle(OpenGl_FrameBuffer) FBOCreate (const Standard_Integer theWidth, const Standard_Integer theHeight);
0054
0055 Standard_EXPORT void FBORelease (Handle(OpenGl_FrameBuffer)& theFbo);
0056
0057 Standard_Boolean BufferDump (const Handle(OpenGl_FrameBuffer)& theFbo,
0058 Image_PixMap& theImage,
0059 const Graphic3d_BufferType& theBufferType);
0060
0061 Standard_EXPORT Standard_Integer Width() const;
0062
0063 Standard_EXPORT Standard_Integer Height() const;
0064
0065
0066
0067 Standard_Boolean SetUseZBuffer (const Standard_Boolean theToUse)
0068 {
0069 const Standard_Boolean wasUsed = myUseZBuffer;
0070 myUseZBuffer = theToUse;
0071 return wasUsed;
0072 }
0073
0074
0075 Standard_Boolean& UseZBuffer() { return myUseZBuffer; }
0076
0077
0078 Standard_Boolean& UseDepthWrite() { return myUseDepthWrite; }
0079
0080
0081
0082 Standard_EXPORT Graphic3d_PolygonOffset SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset);
0083
0084
0085
0086
0087 bool ToAllowFaceCulling() const { return myToAllowFaceCulling; }
0088
0089
0090
0091
0092 bool SetAllowFaceCulling (bool theToAllow)
0093 {
0094 const bool wasAllowed = myToAllowFaceCulling;
0095 myToAllowFaceCulling = theToAllow;
0096 return wasAllowed;
0097 }
0098
0099
0100 bool ToHighlight() const { return !myHighlightStyle.IsNull(); }
0101
0102
0103 const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; }
0104
0105
0106 void SetHighlightStyle (const Handle(Graphic3d_PresentationAttributes)& theStyle) { myHighlightStyle = theStyle; }
0107
0108
0109 const OpenGl_Vec4& EdgeColor() const
0110 {
0111 return !myHighlightStyle.IsNull()
0112 ? myHighlightStyle->ColorRGBA()
0113 : myAspectsSet->Aspect()->EdgeColorRGBA();
0114 }
0115
0116
0117 const OpenGl_Vec4& InteriorColor() const
0118 {
0119 return !myHighlightStyle.IsNull()
0120 ? myHighlightStyle->ColorRGBA()
0121 : myAspectsSet->Aspect()->InteriorColorRGBA();
0122 }
0123
0124
0125 const OpenGl_Vec4& TextColor() const
0126 {
0127 return !myHighlightStyle.IsNull()
0128 ? myHighlightStyle->ColorRGBA()
0129 : myAspectsSet->Aspect()->ColorRGBA();
0130 }
0131
0132
0133 const OpenGl_Vec4& TextSubtitleColor() const
0134 {
0135 return !myHighlightStyle.IsNull()
0136 ? myHighlightStyle->ColorRGBA()
0137 : myAspectsSet->Aspect()->ColorSubTitleRGBA();
0138 }
0139
0140
0141 const OpenGl_Aspects* Aspects() const { return myAspectsSet; }
0142
0143
0144 Standard_EXPORT const OpenGl_Aspects* SetAspects (const OpenGl_Aspects* theAspect);
0145
0146
0147 const Handle(OpenGl_TextureSet)& TextureSet() const
0148 {
0149 const Handle(OpenGl_TextureSet)& aTextureSet = myAspectsSet->TextureSet (myGlContext, ToHighlight());
0150 return !aTextureSet.IsNull()
0151 || myAspectsSet->Aspect()->ToMapTexture()
0152 ? aTextureSet
0153 : myEnvironmentTexture;
0154 }
0155
0156
0157
0158
0159 Standard_EXPORT const OpenGl_Aspects* ApplyAspects (bool theToBindTextures = true);
0160
0161
0162 void ResetAppliedAspect();
0163
0164
0165
0166 Standard_Integer RenderFilter() const { return myRenderFilter; }
0167
0168
0169
0170 void SetRenderFilter (Standard_Integer theFilter) { myRenderFilter = theFilter; }
0171
0172
0173
0174
0175
0176 bool ShouldRender (const OpenGl_Element* theElement, const OpenGl_Group* theGroup);
0177
0178
0179
0180 Standard_Integer NbSkippedTransparentElements() { return myNbSkippedTranspElems; }
0181
0182
0183
0184 void ResetSkippedCounter() { myNbSkippedTranspElems = 0; }
0185
0186
0187 const OpenGl_Aspects& NoneCulling() const { return myNoneCulling; }
0188
0189
0190 const OpenGl_Aspects& FrontCulling() const { return myFrontCulling; }
0191
0192
0193 void SetEnvironmentTexture (const Handle(OpenGl_TextureSet)& theTexture) { myEnvironmentTexture = theTexture; }
0194
0195
0196 const Handle(OpenGl_TextureSet)& EnvironmentTexture() const { return myEnvironmentTexture; }
0197
0198
0199 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0200
0201 protected:
0202
0203 OpenGl_View* myView;
0204 Handle(OpenGl_Window) myWindow;
0205 Handle(OpenGl_Context) myGlContext;
0206 Standard_Boolean myUseZBuffer;
0207 Standard_Boolean myUseDepthWrite;
0208 OpenGl_Aspects myNoneCulling;
0209 OpenGl_Aspects myFrontCulling;
0210
0211 protected:
0212
0213 Standard_Integer myNbSkippedTranspElems;
0214 Standard_Integer myRenderFilter;
0215
0216 OpenGl_Aspects myDefaultAspects;
0217 const OpenGl_Aspects* myAspectsSet;
0218 Handle(Graphic3d_Aspects) myAspectsApplied;
0219
0220 Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
0221
0222 bool myToAllowFaceCulling;
0223 Handle(Graphic3d_PresentationAttributes) myHighlightStyle;
0224
0225 OpenGl_Aspects myAspectFaceHl;
0226
0227 Handle(OpenGl_TextureSet) myEnvironmentTexture;
0228
0229 public:
0230
0231 DEFINE_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
0232 DEFINE_STANDARD_ALLOC
0233
0234 };
0235
0236 #endif