Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-10-20 |
2 | // Created by: Sergey ZERCHANINOV | |
3 | // Copyright (c) 2011-2012 OPEN CASCADE SAS | |
4 | // | |
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. | |
9 | // | |
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. | |
12 | // | |
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. | |
19 | ||
7fd59977 | 20 | |
2166f0fa | 21 | #include <OpenGl_GraphicDriver.hxx> |
7fd59977 | 22 | |
2166f0fa SK |
23 | #include <OpenGl_View.hxx> |
24 | #include <OpenGl_Workspace.hxx> | |
7fd59977 | 25 | |
2166f0fa SK |
26 | IMPLEMENT_STANDARD_HANDLE(OpenGl_GraphicDriver,Graphic3d_GraphicDriver) |
27 | IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver) | |
7fd59977 | 28 | |
2166f0fa SK |
29 | namespace |
30 | { | |
31 | // Global maps - shared by whole TKOpenGl module. To be removed. | |
32 | static NCollection_DataMap<Standard_Integer, Handle(OpenGl_View)> TheMapOfView (1, NCollection_BaseAllocator::CommonBaseAllocator()); | |
33 | static NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)> TheMapOfWS (1, NCollection_BaseAllocator::CommonBaseAllocator()); | |
34 | static NCollection_DataMap<Standard_Integer, OpenGl_Structure*> TheMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator()); | |
35 | static Standard_Boolean TheToUseVbo = Standard_True; | |
36 | }; | |
7fd59977 | 37 | |
38 | // Pour eviter de "mangler" MetaGraphicDriverFactory, le nom de la | |
39 | // fonction qui cree un Graphic3d_GraphicDriver. | |
40 | // En effet, ce nom est recherche par la methode DlSymb de la | |
41 | // classe OSD_SharedLibrary dans la methode SetGraphicDriver de la | |
42 | // classe Graphic3d_GraphicDevice | |
43 | extern "C" { | |
44 | #ifdef WNT /* disable MS VC++ warning on C-style function returning C++ object */ | |
2166f0fa SK |
45 | #pragma warning(push) |
46 | #pragma warning(disable:4190) | |
7fd59977 | 47 | #endif |
2166f0fa SK |
48 | Standard_EXPORT Handle(Graphic3d_GraphicDriver) MetaGraphicDriverFactory (const Standard_CString AShrName) |
49 | { | |
50 | Handle(OpenGl_GraphicDriver) aOpenDriver = new OpenGl_GraphicDriver (AShrName); | |
51 | return aOpenDriver; | |
52 | } | |
7fd59977 | 53 | #ifdef WNT |
2166f0fa | 54 | #pragma warning(pop) |
7fd59977 | 55 | #endif |
56 | } | |
57 | ||
2166f0fa SK |
58 | OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Standard_CString theShrName) |
59 | : Graphic3d_GraphicDriver (theShrName) | |
7fd59977 | 60 | { |
2166f0fa | 61 | // |
7fd59977 | 62 | } |
63 | ||
7fd59977 | 64 | Standard_ShortReal OpenGl_GraphicDriver::DefaultTextHeight() const |
65 | { | |
66 | return 16.; | |
67 | } | |
68 | ||
2166f0fa SK |
69 | NCollection_DataMap<Standard_Integer, Handle(OpenGl_View)>& OpenGl_GraphicDriver::GetMapOfViews() |
70 | { | |
71 | return TheMapOfView; | |
72 | } | |
73 | ||
74 | NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)>& OpenGl_GraphicDriver::GetMapOfWorkspaces() | |
75 | { | |
76 | return TheMapOfWS; | |
77 | } | |
78 | ||
79 | NCollection_DataMap<Standard_Integer, OpenGl_Structure*>& OpenGl_GraphicDriver::GetMapOfStructures() | |
80 | { | |
81 | return TheMapOfStructure; | |
82 | } | |
83 | ||
84 | //TsmInitUpdateState | |
85 | void OpenGl_GraphicDriver::InvalidateAllWorkspaces() | |
86 | { | |
87 | for (NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)>::Iterator anIt (OpenGl_GraphicDriver::GetMapOfWorkspaces()); | |
88 | anIt.More(); anIt.Next()) | |
89 | { | |
90 | anIt.ChangeValue()->Invalidate(); | |
91 | anIt.ChangeValue()->EraseAnimation(); | |
92 | } | |
93 | } | |
94 | ||
95 | Standard_Boolean OpenGl_GraphicDriver::ToUseVBO() | |
7fd59977 | 96 | { |
2166f0fa | 97 | return TheToUseVbo; |
7fd59977 | 98 | } |
99 | ||
2166f0fa | 100 | void OpenGl_GraphicDriver::EnableVBO (const Standard_Boolean theToTurnOn) |
7fd59977 | 101 | { |
2166f0fa | 102 | TheToUseVbo = theToTurnOn; |
7fd59977 | 103 | } |