OCC22199 OpenGL memory leaks in TKOpenGl
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_Layer.cxx
CommitLineData
7fd59977 1
2// File OpenGl_GraphicDriver_Layer.cxx
3// Created Mardi 3 novembre 1998
4// Author CAL
5
6//-Copyright MatraDatavision 1998
7
8//-Version
9
10//-Design Declaration des variables specifiques aux Drivers
11
12//-Warning Un driver encapsule les Pex et OpenGl drivers
13
14//-References
15
16//-Language C++ 2.0
17
18//-Declarations
19
20// for the class
21#include <OpenGl_GraphicDriver.jxx>
22
23#include <Aspect_DriverDefinitionError.hxx>
24
25#include <OpenGl_tgl_funcs.hxx>
26
27//-Aliases
28#define NO_DEBUG
29
30//-Global data definitions
31
32//-Methods, in order
33
34void OpenGl_GraphicDriver::Layer (Aspect_CLayer2d& ACLayer) {
35 Aspect_CLayer2d MyCLayer = ACLayer;
36
37 if (MyTraceLevel) {
38 PrintFunction ("call_togl_layer2d");
39 PrintInteger ("ALayerType", int (ACLayer.layerType));
40 }
41 call_togl_layer2d (&MyCLayer);
42 ACLayer = MyCLayer;
43#ifdef DEBUG
44 cout << "OpenGl_GraphicDriver::Layer" << endl;
45 call_def_ptrLayer ptrLayer;
46 ptrLayer = (call_def_ptrLayer) MyCLayer.ptrLayer;
47 if (ptrLayer == NULL)
48 cout << "\tptrLayer == NULL" << endl;
49 else
50 cout << "\tptrLayer->listIndex = " << ptrLayer->listIndex << endl;
51#endif
52}
53
54void OpenGl_GraphicDriver::RemoveLayer (const Aspect_CLayer2d& ACLayer) {
55 Aspect_CLayer2d MyCLayer = ACLayer;
56
57 if (MyTraceLevel) {
58 PrintFunction ("call_togl_removelayer2d");
59 PrintInteger ("ALayerType", int (ACLayer.layerType));
60 }
61 call_togl_removelayer2d (&MyCLayer);
62}
63
64void OpenGl_GraphicDriver::BeginLayer (const Aspect_CLayer2d& ACLayer) {
65 Aspect_CLayer2d MyCLayer = ACLayer;
66
67 if (MyTraceLevel) {
68 PrintFunction ("call_togl_begin_layer2d");
69 PrintInteger ("ALayerType", int (ACLayer.layerType));
70 }
71 call_togl_begin_layer2d (&MyCLayer);
72}
73
74void OpenGl_GraphicDriver::BeginPolygon2d () {
75 if (MyTraceLevel) {
76 PrintFunction ("call_togl_begin_polygon2d");
77 }
78 call_togl_begin_polygon2d ();
79}
80
81void OpenGl_GraphicDriver::BeginPolyline2d () {
82 if (MyTraceLevel) {
83 PrintFunction ("call_togl_begin_polyline2d");
84 }
85 call_togl_begin_polyline2d ();
86}
87
88void OpenGl_GraphicDriver::ClearLayer (const Aspect_CLayer2d& ACLayer) {
89 Aspect_CLayer2d MyCLayer = ACLayer;
90
91 if (MyTraceLevel) {
92 PrintFunction ("call_togl_clear_layer2d");
93 PrintInteger ("ALayerType", int (ACLayer.layerType));
94 }
95 call_togl_clear_layer2d (&MyCLayer);
96}
97
98void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y) {
99 if (MyTraceLevel) {
100 PrintFunction ("call_togl_draw2d");
101 PrintShortReal ("X", X);
102 PrintShortReal ("Y", Y);
103 }
104 call_togl_draw2d (X, Y);
105}
106
107void OpenGl_GraphicDriver::Edge (const Standard_ShortReal X, const Standard_ShortReal Y) {
108 if (MyTraceLevel) {
109 PrintFunction ("call_togl_edge2d");
110 PrintShortReal ("X", X);
111 PrintShortReal ("Y", Y);
112 }
113 call_togl_edge2d (X, Y);
114}
115
116void OpenGl_GraphicDriver::EndLayer () {
117 if (MyTraceLevel) {
118 PrintFunction ("call_togl_end_layer2d");
119 }
120 call_togl_end_layer2d ();
121}
122
123void OpenGl_GraphicDriver::EndPolygon2d () {
124 if (MyTraceLevel) {
125 PrintFunction ("call_togl_end_polygon2d");
126 }
127 call_togl_end_polygon2d ();
128}
129
130void OpenGl_GraphicDriver::EndPolyline2d () {
131 if (MyTraceLevel) {
132 PrintFunction ("call_togl_end_polyline2d");
133 }
134 call_togl_end_polyline2d ();
135}
136
137void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y) {
138 if (MyTraceLevel) {
139 PrintFunction ("call_togl_move2d");
140 PrintShortReal ("X", X);
141 PrintShortReal ("Y", Y);
142 }
143 call_togl_move2d (X, Y);
144}
145
146void OpenGl_GraphicDriver::Rectangle (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Width, const Standard_ShortReal Height) {
147 if (MyTraceLevel) {
148 PrintFunction ("call_togl_rectangle2d");
149 PrintShortReal ("X", X);
150 PrintShortReal ("Y", Y);
151 PrintShortReal ("Width", Width);
152 PrintShortReal ("Height", Height);
153 }
154 call_togl_rectangle2d (X, Y, Width, Height);
155}
156
157void OpenGl_GraphicDriver::SetColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B) {
158 if (MyTraceLevel) {
159 PrintFunction ("call_togl_set_color");
160 PrintShortReal ("R", R);
161 PrintShortReal ("G", G);
162 PrintShortReal ("B", B);
163 }
164 call_togl_set_color (R, G, B);
165}
166
167void OpenGl_GraphicDriver::SetTransparency (const Standard_ShortReal ATransparency) {
168 if (MyTraceLevel) {
169 PrintFunction ("call_togl_set_transparency");
170 PrintShortReal ("Transparency", ATransparency);
171 }
172 call_togl_set_transparency (ATransparency);
173}
174
175void OpenGl_GraphicDriver::UnsetTransparency () {
176 if (MyTraceLevel) {
177 PrintFunction ("call_togl_unset_transparency");
178 }
179 call_togl_unset_transparency ();
180}
181
182void OpenGl_GraphicDriver::SetLineAttributes (const Standard_Integer Type, const Standard_ShortReal Width) {
183 if (MyTraceLevel) {
184 PrintFunction ("call_togl_set_line_attributes");
185 PrintInteger ("Type", Type);
186 PrintShortReal ("Width", Width);
187 }
188 call_togl_set_line_attributes (Type, Width);
189}
190
191void OpenGl_GraphicDriver::SetTextAttributes (const Standard_CString Font, const Standard_Integer AType, const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B) {
192 if (MyTraceLevel) {
193 PrintFunction ("call_togl_set_text_attributes");
194 PrintString ("Font", Font);
195 PrintInteger ("Type", AType);
196 PrintShortReal ("R", R);
197 PrintShortReal ("G", G);
198 PrintShortReal ("B", B);
199 }
200 call_togl_set_text_attributes ((Tchar*)Font, AType, R, G, B);
201}
202
203void OpenGl_GraphicDriver::Text (const Standard_CString AText, const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Height) {
204 if (MyTraceLevel) {
205 PrintFunction ("call_togl_text2d");
206 PrintString ("Text", AText);
207 PrintShortReal ("X", X);
208 PrintShortReal ("Y", Y);
209 PrintShortReal ("Height", Height);
210 }
211 Standard_ShortReal h = Height;
212 if ( h < 0 )
213 h = DefaultTextHeight();
214 call_togl_text2d ((char *)AText, X, Y, h);
215}
216
217void OpenGl_GraphicDriver::TextSize (const Standard_CString AText, const Standard_ShortReal AHeight, Standard_ShortReal& AWidth, Standard_ShortReal& AnAscent, Standard_ShortReal& ADescent) const {
218 call_togl_textsize2d ((char *) AText, AHeight, &AWidth, &AnAscent, &ADescent);
219 if (MyTraceLevel) {
220 PrintFunction ("call_togl_textsize2d");
221 PrintString ("Text", AText);
222 PrintShortReal ("AHeight", AHeight);
223 PrintShortReal ("AWidth", AWidth);
224 PrintShortReal ("AnAscent", AnAscent);
225 PrintShortReal ("ADescent", ADescent);
226 }
227}