1 // File OpenGl_GraphicDriver_8.cxx
2 // Created Mardi 28 janvier 1997
5 //-Copyright MatraDatavision 1997
9 //-Design Declaration des variables specifiques aux Drivers
11 //-Warning Un driver encapsule les Pex et OpenGl drivers
20 #include <OpenGl_GraphicDriver.jxx>
22 #include <Aspect_DriverDefinitionError.hxx>
25 #include <OpenGl_tgl_funcs.hxx>
29 //-Global data definitions
34 Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& ACView)
37 Graphic3d_CView MyCView = ACView;
38 Standard_Boolean Result;
41 PrintFunction ("call_togl_begin_ajout_mode");
42 PrintCView (MyCView, 1);
44 Result = call_togl_begin_ajout_mode (&MyCView);
46 PrintIResult ("call_togl_begin_ajout_mode", Result);
52 void OpenGl_GraphicDriver::EndAddMode (void)
56 PrintFunction ("call_togl_end_ajout_mode");
58 call_togl_end_ajout_mode ();
62 Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode)
65 Graphic3d_CView MyCView = ACView;
66 Aspect_CLayer2d MyCUnderLayer = ACUnderLayer;
67 Aspect_CLayer2d MyCOverLayer = ACOverLayer;
68 Standard_Boolean Result;
72 PrintFunction ("call_togl_begin_immediat_mode");
73 PrintCView (MyCView, 1);
74 PrintBoolean ("DoubleBuffer", DoubleBuffer);
75 PrintBoolean ("RetainMode", RetainMode);
77 Result = call_togl_begin_immediat_mode
78 (&MyCView, &MyCUnderLayer, &MyCOverLayer,
79 (DoubleBuffer ? 1 : 0), (RetainMode ? 1 : 0));
81 PrintIResult ("call_togl_begin_immediat_mode", Result);
87 void OpenGl_GraphicDriver::BeginPolyline ()
91 PrintFunction ("call_togl_begin_polyline");
93 call_togl_begin_polyline ();
97 void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& ACView,
98 const Standard_Boolean aFlush)
101 Graphic3d_CView MyCView = ACView;
104 PrintFunction ("call_togl_clear_immediat_mode");
105 PrintCView (MyCView, 1);
107 call_togl_clear_immediat_mode (&MyCView, aFlush);
111 void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
116 PrintFunction ("call_togl_draw");
117 PrintShortReal ("X", X);
118 PrintShortReal ("Y", Y);
119 PrintShortReal ("Z", Z);
121 call_togl_draw (X, Y, Z);
125 void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& ACStructure) {
127 Graphic3d_CStructure MyCStructure = ACStructure;
130 PrintFunction ("call_togl_draw_structure");
131 PrintCStructure (MyCStructure, 1);
133 call_togl_draw_structure (ACStructure.Id);
137 void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer Synchronize)
141 PrintFunction ("call_togl_end_immediat_mode");
142 PrintInteger ("Synchronize", Synchronize);
144 call_togl_end_immediat_mode (int (Synchronize));
148 void OpenGl_GraphicDriver::EndPolyline ()
152 PrintFunction ("call_togl_end_polyline");
154 call_togl_end_polyline ();
158 void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
162 PrintFunction ("call_togl_move");
163 PrintShortReal ("X", X);
164 PrintShortReal ("Y", Y);
165 PrintShortReal ("Z", Z);
167 call_togl_move (X, Y, Z);
171 void OpenGl_GraphicDriver::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
175 PrintFunction ("call_togl_set_linecolor");
176 PrintShortReal ("R", R);
177 PrintShortReal ("G", G);
178 PrintShortReal ("B", B);
180 call_togl_set_linecolor (R, G, B);
184 void OpenGl_GraphicDriver::SetLineType (const Standard_Integer Type)
188 PrintFunction ("call_togl_set_linetype");
189 PrintInteger ("Type", Type);
191 call_togl_set_linetype (long (Type));
195 void OpenGl_GraphicDriver::SetLineWidth (const Standard_ShortReal Width)
199 PrintFunction ("call_togl_set_linewidth");
200 PrintShortReal ("Width", Width);
202 call_togl_set_linewidth (float (Width));
206 void OpenGl_GraphicDriver::SetMinMax (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal Z1, const Standard_ShortReal X2, const Standard_ShortReal Y2, const Standard_ShortReal Z2)
210 PrintFunction ("call_togl_set_minmax");
211 PrintShortReal ("X1", X1);
212 PrintShortReal ("Y1", Y1);
213 PrintShortReal ("Z1", Z1);
214 PrintShortReal ("X2", X2);
215 PrintShortReal ("Y2", Y2);
216 PrintShortReal ("Z2", Z2);
218 call_togl_set_minmax (X1, Y1, Z1, X2, Y2, Z2);
222 void OpenGl_GraphicDriver::Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType)
225 float theMatrix[4][4];
226 Standard_Integer i, j;
227 Standard_Integer lr, lc;
229 lr = AMatrix.LowerRow ();
230 lc = AMatrix.LowerCol ();
234 theMatrix[i][j] = float (AMatrix (i+lr, j+lc));
237 PrintFunction ("call_togl_transform");
238 PrintMatrix ("AMatrix", AMatrix);
240 call_togl_transform (theMatrix, (AType == Graphic3d_TOC_REPLACE) ? 1 : 0);