0023544: Texture management in TKOpenGl should be redesigned
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_9.cxx
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
20 #include <OpenGl_GraphicDriver.hxx>
21 #include <OpenGl_CView.hxx>
22 #include <OpenGl_Trihedron.hxx>
23 #include <OpenGl_GraduatedTrihedron.hxx>
24 #include <OpenGl_tgl_funcs.hxx>
25
26 void OpenGl_GraphicDriver::Environment(const Graphic3d_CView& theCView)
27 {
28   const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
29   if (aCView == NULL)
30   {
31     return;
32   }
33
34   aCView->View->SetTextureEnv    (GetSharedContext(), theCView.Context.TextureEnv);
35   aCView->View->SetSurfaceDetail ((Visual3d_TypeOfSurfaceDetail)theCView.Context.SurfaceDetail);
36 }
37
38 //
39 // Triedron methods : the Triedron is a non-zoomable object.
40 //
41
42 void OpenGl_GraphicDriver::ZBufferTriedronSetup (
43   const Quantity_NameOfColor XColor,
44   const Quantity_NameOfColor YColor,
45   const Quantity_NameOfColor ZColor,
46   const Standard_Real        SizeRatio,
47   const Standard_Real        AxisDiametr,
48   const Standard_Integer     NbFacettes)
49 {
50   OpenGl_Trihedron::Setup(XColor,YColor,ZColor,SizeRatio,AxisDiametr,NbFacettes);
51 }
52
53 void OpenGl_GraphicDriver::TriedronDisplay (
54   const Graphic3d_CView& ACView,
55   const Aspect_TypeOfTriedronPosition APosition,
56   const Quantity_NameOfColor AColor,
57   const Standard_Real AScale,
58   const Standard_Boolean AsWireframe )
59 {
60   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
61   if (aCView)
62   {
63     aCView->View->TriedronDisplay(APosition, AColor, AScale, AsWireframe);
64   }
65 }
66
67 void OpenGl_GraphicDriver::TriedronErase (const Graphic3d_CView& ACView)
68 {
69   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
70   if (aCView)
71   {
72     aCView->View->TriedronErase();
73   }
74 }
75
76 void OpenGl_GraphicDriver::TriedronEcho (const Graphic3d_CView& ACView,const Aspect_TypeOfTriedronEcho AType )
77 {
78   // Do nothing
79 }
80
81 void OpenGl_GraphicDriver::BackgroundImage( const Standard_CString FileName,
82                                            const Graphic3d_CView& ACView,
83                                            const Aspect_FillMethod FillStyle )
84 {
85   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
86   if (aCView)
87   {
88     aCView->View->CreateBackgroundTexture( FileName, FillStyle );
89   }
90 }
91
92 void OpenGl_GraphicDriver::SetBgImageStyle( const Graphic3d_CView& ACView,
93                                            const Aspect_FillMethod FillStyle )
94 {
95   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
96   if (aCView)
97   {
98     aCView->View->SetBackgroundTextureStyle( FillStyle );
99   }
100 }
101
102 void OpenGl_GraphicDriver::SetBgGradientStyle(const Graphic3d_CView& ACView,const Aspect_GradientFillMethod FillType)
103 {
104   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
105   if (aCView)
106   {
107     aCView->View->SetBackgroundGradientType(FillType);
108   }
109 }
110
111 void OpenGl_GraphicDriver::GraduatedTrihedronDisplay(const Graphic3d_CView& ACView, const Graphic3d_CGraduatedTrihedron& cubic)
112 {
113   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
114   if (aCView)
115   {
116     aCView->View->GraduatedTrihedronDisplay(cubic);
117   }
118 }
119
120 void OpenGl_GraphicDriver::GraduatedTrihedronErase(const Graphic3d_CView& ACView)
121 {
122   const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
123   if (aCView)
124   {
125     aCView->View->GraduatedTrihedronErase();
126   }
127 }
128
129 void OpenGl_GraphicDriver::GraduatedTrihedronMinMaxValues(const Standard_ShortReal xmin,
130                                                          const Standard_ShortReal ymin,
131                                                          const Standard_ShortReal zmin,
132                                                          const Standard_ShortReal xmax,
133                                                          const Standard_ShortReal ymax,
134                                                          const Standard_ShortReal zmax)
135 {
136   OpenGl_GraduatedTrihedron::SetMinMax(xmin, ymin, zmin, xmax, ymax, zmax);
137 }