0022819: Redesign of OpenGl driver
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_1.cxx
1 // File:      OpenGl_GraphicDriver_1.cxx
2 // Created:   20 October 2011
3 // Author:    Sergey ZERCHANINOV
4 // Copyright: OPEN CASCADE 2011
5
6 #include <OpenGl_GraphicDriver.hxx>
7
8 #include <Standard_ErrorHandler.hxx>
9 #include <Standard_Failure.hxx>
10
11 #include <OpenGl_CView.hxx>
12 #include <OpenGl_Display.hxx>
13
14 //=======================================================================
15 //function : Begin
16 //purpose  : 
17 //=======================================================================
18
19 Standard_Boolean OpenGl_GraphicDriver::Begin (const Standard_CString ADisplay)
20 {
21   try
22   {
23     openglDisplay = new OpenGl_Display(ADisplay);
24     return Standard_True;
25   }
26   catch (Standard_Failure)
27   {
28   }
29   return Standard_False;
30 }
31
32 //=======================================================================
33 //function : Begin
34 //purpose  : 
35 //=======================================================================
36
37 Standard_Boolean OpenGl_GraphicDriver::Begin (const Aspect_Display ADisplay)
38 {
39   try
40   {
41     openglDisplay = new OpenGl_Display(ADisplay);
42     return Standard_True;
43   }
44   catch (Standard_Failure)
45   {
46   }
47   return Standard_False;
48 }
49
50 //=======================================================================
51 //function : End
52 //purpose  : 
53 //=======================================================================
54
55 void OpenGl_GraphicDriver::End ()
56 {
57   openglDisplay.Nullify();
58 }
59
60 //=======================================================================
61 //function : BeginAnimation
62 //purpose  : 
63 //=======================================================================
64
65 void OpenGl_GraphicDriver::BeginAnimation (const Graphic3d_CView& ACView)
66 {
67   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
68   if (aCView)
69   {
70     const Standard_Boolean UpdateAM = (ACView.IsDegenerates && !ACView.IsDegeneratesPrev) || (!ACView.IsDegenerates && ACView.IsDegeneratesPrev);
71     aCView->WS->BeginAnimation(ACView.IsDegenerates != 0,UpdateAM);
72     ((Graphic3d_CView*)(&ACView))->IsDegeneratesPrev = ACView.IsDegenerates; //szvgl: temporary
73   }
74 }
75
76 //=======================================================================
77 //function : EndAnimation
78 //purpose  : 
79 //=======================================================================
80
81 void OpenGl_GraphicDriver::EndAnimation (const Graphic3d_CView& ACView)
82 {
83   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
84   if (aCView)
85     aCView->WS->EndAnimation();
86 }