File indexing completed on 2025-01-18 10:04:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _OpenGl_GraphicDriver_HeaderFile
0017 #define _OpenGl_GraphicDriver_HeaderFile
0018
0019 #include <Graphic3d_GraphicDriver.hxx>
0020
0021 #include <Aspect_DisplayConnection.hxx>
0022 #include <Graphic3d_CView.hxx>
0023 #include <Graphic3d_CStructure.hxx>
0024 #include <NCollection_DataMap.hxx>
0025 #include <OpenGl_Context.hxx>
0026
0027 class Aspect_Window;
0028 class OpenGl_Structure;
0029 class OpenGl_View;
0030 class OpenGl_Window;
0031
0032
0033
0034 class OpenGl_StateCounter
0035 {
0036 public:
0037
0038 OpenGl_StateCounter() : myCounter (0) { }
0039
0040 Standard_Size Increment() { return ++myCounter; }
0041
0042 private:
0043
0044 Standard_Size myCounter;
0045 };
0046
0047
0048 class OpenGl_GraphicDriver : public Graphic3d_GraphicDriver
0049 {
0050 DEFINE_STANDARD_RTTIEXT(OpenGl_GraphicDriver, Graphic3d_GraphicDriver)
0051 public:
0052
0053
0054
0055
0056 Standard_EXPORT OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnection)& theDisp,
0057 const Standard_Boolean theToInitialize = Standard_True);
0058
0059
0060 Standard_EXPORT virtual ~OpenGl_GraphicDriver();
0061
0062
0063 Standard_EXPORT void ReleaseContext();
0064
0065
0066 Standard_EXPORT Standard_Boolean InitContext();
0067
0068
0069
0070
0071
0072 Standard_EXPORT Standard_Boolean InitEglContext (Aspect_Display theEglDisplay,
0073 Aspect_RenderingContext theEglContext,
0074 void* theEglConfig);
0075
0076
0077 Standard_EXPORT virtual Standard_Integer InquireLimit (const Graphic3d_TypeOfLimit theType) const Standard_OVERRIDE;
0078
0079 public:
0080
0081 Standard_EXPORT virtual Handle(Graphic3d_CStructure) CreateStructure (const Handle(Graphic3d_StructureManager)& theManager) Standard_OVERRIDE;
0082
0083 Standard_EXPORT virtual void RemoveStructure (Handle(Graphic3d_CStructure)& theCStructure) Standard_OVERRIDE;
0084
0085 Standard_EXPORT virtual Handle(Graphic3d_CView) CreateView (const Handle(Graphic3d_StructureManager)& theMgr) Standard_OVERRIDE;
0086
0087 Standard_EXPORT virtual void RemoveView (const Handle(Graphic3d_CView)& theView) Standard_OVERRIDE;
0088
0089
0090
0091
0092
0093 Standard_EXPORT virtual Handle(OpenGl_Window) CreateRenderWindow (const Handle(Aspect_Window)& theNativeWindow,
0094 const Handle(Aspect_Window)& theSizeWindow,
0095 const Aspect_RenderingContext theContext);
0096
0097 public:
0098
0099 Standard_EXPORT void TextSize (const Handle(Graphic3d_CView)& theView,
0100 const Standard_CString theText,
0101 const Standard_ShortReal theHeight,
0102 Standard_ShortReal& theWidth,
0103 Standard_ShortReal& theAscent,
0104 Standard_ShortReal& theDescent) const Standard_OVERRIDE;
0105
0106 Standard_EXPORT Standard_ShortReal DefaultTextHeight() const Standard_OVERRIDE;
0107
0108 Standard_EXPORT Standard_Boolean ViewExists (const Handle(Aspect_Window)& theWindow, Handle(Graphic3d_CView)& theView) Standard_OVERRIDE;
0109
0110 public:
0111
0112
0113
0114
0115
0116 Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
0117 const Graphic3d_ZLayerSettings& theSettings,
0118 const Graphic3d_ZLayerId theLayerAfter) Standard_OVERRIDE;
0119
0120
0121
0122
0123
0124 Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
0125 const Graphic3d_ZLayerSettings& theSettings,
0126 const Graphic3d_ZLayerId theLayerBefore) Standard_OVERRIDE;
0127
0128
0129
0130
0131
0132 Standard_EXPORT void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
0133
0134
0135 Standard_EXPORT void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) Standard_OVERRIDE;
0136
0137 public:
0138
0139
0140 inline const OpenGl_Caps& Options() const
0141 {
0142 return *myCaps.operator->();
0143 }
0144
0145
0146 inline OpenGl_Caps& ChangeOptions()
0147 {
0148 return *myCaps.operator->();
0149 }
0150
0151
0152 Standard_EXPORT void SetBuffersNoSwap (const Standard_Boolean theIsNoSwap);
0153
0154
0155
0156
0157 Standard_EXPORT virtual void EnableVBO (const Standard_Boolean theToTurnOn) Standard_OVERRIDE;
0158
0159
0160
0161 Standard_EXPORT virtual bool IsVerticalSync() const Standard_OVERRIDE;
0162
0163
0164 Standard_EXPORT virtual void SetVerticalSync (bool theToEnable) Standard_OVERRIDE;
0165
0166
0167
0168 Standard_EXPORT Standard_Boolean MemoryInfo (Standard_Size& theFreeBytes,
0169 TCollection_AsciiString& theInfo) const Standard_OVERRIDE;
0170
0171 public:
0172
0173
0174
0175
0176
0177 Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext (bool theBound = false) const;
0178
0179 Aspect_Display getRawGlDisplay() const { return myEglDisplay; }
0180 Aspect_RenderingContext getRawGlContext() const { return myEglContext; }
0181 void* getRawGlConfig() const { return myEglConfig; }
0182
0183
0184 Standard_EXPORT void setDeviceLost();
0185
0186 public:
0187
0188
0189 OpenGl_StateCounter* GetStateCounter() const { return &myStateCounter; }
0190
0191
0192 Standard_Size GetNextPrimitiveArrayUID() const { return myUIDGenerator.Increment(); }
0193
0194 protected:
0195
0196
0197 Standard_EXPORT void chooseVisualInfo();
0198
0199 protected:
0200
0201 Standard_Boolean myIsOwnContext;
0202
0203 Aspect_Display myEglDisplay;
0204 Aspect_RenderingContext myEglContext;
0205 void* myEglConfig;
0206
0207 Handle(OpenGl_Caps) myCaps;
0208 NCollection_Map<Handle(OpenGl_View)> myMapOfView;
0209 NCollection_DataMap<Standard_Integer, OpenGl_Structure*> myMapOfStructure;
0210
0211 mutable OpenGl_StateCounter myStateCounter;
0212 mutable OpenGl_StateCounter myUIDGenerator;
0213
0214 };
0215
0216 DEFINE_STANDARD_HANDLE(OpenGl_GraphicDriver, Graphic3d_GraphicDriver)
0217
0218 #endif