1 // Created on: 2011-10-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <OpenGl_GraphicDriver.hxx>
23 #include <OpenGl_Context.hxx>
24 #include <OpenGl_View.hxx>
25 #include <OpenGl_Workspace.hxx>
27 IMPLEMENT_STANDARD_HANDLE(OpenGl_GraphicDriver,Graphic3d_GraphicDriver)
28 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver)
32 // Global maps - shared by whole TKOpenGl module. To be removed.
33 static NCollection_DataMap<Standard_Integer, Handle(OpenGl_View)> TheMapOfView (1, NCollection_BaseAllocator::CommonBaseAllocator());
34 static NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)> TheMapOfWS (1, NCollection_BaseAllocator::CommonBaseAllocator());
35 static NCollection_DataMap<Standard_Integer, OpenGl_Structure*> TheMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator());
36 static Standard_Boolean TheToUseVbo = Standard_True;
39 // Pour eviter de "mangler" MetaGraphicDriverFactory, le nom de la
40 // fonction qui cree un Graphic3d_GraphicDriver.
41 // En effet, ce nom est recherche par la methode DlSymb de la
42 // classe OSD_SharedLibrary dans la methode SetGraphicDriver de la
43 // classe Graphic3d_GraphicDevice
45 #ifdef WNT /* disable MS VC++ warning on C-style function returning C++ object */
47 #pragma warning(disable:4190)
49 Standard_EXPORT Handle(Graphic3d_GraphicDriver) MetaGraphicDriverFactory (const Standard_CString AShrName)
51 Handle(OpenGl_GraphicDriver) aOpenDriver = new OpenGl_GraphicDriver (AShrName);
59 // =======================================================================
60 // function : OpenGl_GraphicDriver
62 // =======================================================================
63 OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Standard_CString theShrName)
64 : Graphic3d_GraphicDriver (theShrName)
69 // =======================================================================
70 // function : DefaultTextHeight
72 // =======================================================================
73 Standard_ShortReal OpenGl_GraphicDriver::DefaultTextHeight() const
78 // =======================================================================
79 // function : GetMapOfViews
81 // =======================================================================
82 NCollection_DataMap<Standard_Integer, Handle(OpenGl_View)>& OpenGl_GraphicDriver::GetMapOfViews()
87 // =======================================================================
88 // function : GetMapOfWorkspaces
90 // =======================================================================
91 NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)>& OpenGl_GraphicDriver::GetMapOfWorkspaces()
96 // =======================================================================
97 // function : GetMapOfStructures
99 // =======================================================================
100 NCollection_DataMap<Standard_Integer, OpenGl_Structure*>& OpenGl_GraphicDriver::GetMapOfStructures()
102 return TheMapOfStructure;
105 // =======================================================================
106 // function : InvalidateAllWorkspaces
107 // purpose : ex-TsmInitUpdateState, deprecated, need to decide what to do with EraseAnimation() call
108 // =======================================================================
109 void OpenGl_GraphicDriver::InvalidateAllWorkspaces()
111 for (NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)>::Iterator anIt (OpenGl_GraphicDriver::GetMapOfWorkspaces());
112 anIt.More(); anIt.Next())
114 anIt.ChangeValue()->EraseAnimation();
118 // =======================================================================
119 // function : ToUseVBO
121 // =======================================================================
122 Standard_Boolean OpenGl_GraphicDriver::ToUseVBO()
127 // =======================================================================
128 // function : EnableVBO
130 // =======================================================================
131 void OpenGl_GraphicDriver::EnableVBO (const Standard_Boolean theToTurnOn)
133 TheToUseVbo = theToTurnOn;
136 // =======================================================================
137 // function : MemoryInfo
139 // =======================================================================
140 Standard_Boolean OpenGl_GraphicDriver::MemoryInfo (Standard_Size& theFreeBytes,
141 TCollection_AsciiString& theInfo) const
143 // this is extra work (for OpenGl_Context initialization)...
144 OpenGl_Context aGlCtx;
147 return Standard_False;
149 theFreeBytes = aGlCtx.AvailableMemory();
150 theInfo = aGlCtx.MemoryInfo();
151 return !theInfo.IsEmpty();