ADTF_DISPLAY_TOOLBOX  3.8.0 (ADTF 3.14.3)
glcanvas.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #ifndef PI
11 #define PI 3.1415926535897932384626433832795
12 #endif
13 
14 
15 #include <adtf_base.h>
16 
17 #ifdef WIN32
18  #include <windows.h>
19  #include <gl/GL.h>
20 #else
21  #include <GL/gl.h>
22  #include <fontconfig/fontconfig.h>
23 #endif
24 
25 #ifdef GetObject
26 #undef GetObject
27 #endif
28 
34 
35 namespace adtf
36 {
37 
38 namespace disptb
39 {
40 
41 namespace graphicslib
42 {
43 
44 namespace dengar
45 {
46 
53 class cGLCanvas : public ucom::catwo::object<ICanvas>
54 {
55 
56 A_UTILS_D(cGLCanvas)
57 
58 friend class cGLFont;
59 
60 protected:
61 
62  struct sFlags
63  {
64  tBool bTextOppsedYAxis;
65  tBool bTextScales;
66  tBool bTextRotate;
67  tBool bTextBaselineOnTop;
68  };
69 
70 public:
71 
72  cGLCanvas();
73 
77  virtual ~cGLCanvas() final;
78 
85  tResult Create(tInt nWidth, tInt nHeight, tInt nBitsPerPixel) override;
86 
92  tResult Resize(tInt nWidth, tInt nHeight);
93 
97  tResult Release();
98 
102  tUInt32 GetMode();
103 
113  tVoid NormalizeRect(tInt& x1, tInt& y1, tInt& x2, tInt& y2) const;
114 
124  tVoid NormalizeRect(tFloat32& x1, tFloat32& y1, tFloat32& x2, tFloat32& y2) const;
125 
134  tVoid Coord(tFloat32* pXCoords, tFloat32* pYCoords, tInt nCount);
135 
136  virtual tVoid FlipTextHorizontally(tBool bOpposedYAxis);
137 
138  virtual tVoid TextScaleWithZoom(tBool bScaleWithZoom);
139 
140 
141 public: // implements IGraphicsMode
142  tBool IsSupported(tFeature nFeatureId) const override;
143 
144  tVoid EnableAlpha(tBool bAdditiveMode = tFalse) const override;
145 
146  tVoid DisableAlpha() const override;
147 
148  tVoid EnableAntialiasing() const override;
149 
150  tVoid DisableAntialiasing() const override;
151 
152  tVoid EnableLighting() const override;
153 
154  tVoid DisableLighting() const override;
155 
156  tVoid EnableDepthBuffer() const override;
157 
158  tVoid DisableDepthBuffer() const override;
159 
160  tVoid EnableBackFaceCulling() const override;
161 
162  tVoid DisableBackFaceCulling() const override;
163 
164  tVoid LineWidth(tFloat64 fWidth) override;
165 
166  tVoid LinePattern(tUInt16 ui16Pattern, tInt nFactor = 1) override;
167 
168  tVoid Color(const IColor* col) override;
169 
170  tVoid Color(tInt nRed, tInt nGreen, tInt nBlue, tInt nAlpha = 255) override;
171 
172  tVoid Color(tUInt8 nRed, tUInt8 nGreen, tUInt8 nBlue, tUInt8 nAlpha = 255) override;
173 
174  tVoid Color(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue, tFloat64 fAlpha = 1.0) override;
175 
176  tVoid BgColor(const IColor* col) override;
177 
178  tVoid BgColor(tInt nRed, tInt nGreen, tInt nBlue, tInt nAlpha = 255) override;
179 
180  tVoid BgColor(tUInt8 nRed, tUInt8 nGreen, tUInt8 nBlue, tUInt8 nAlpha = 255) override;
181 
182  tVoid BgColor(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue, tFloat64 fAlpha = 0.0) override;
183 
184  tVoid Begin(tMode eMode) override;
185 
186  tVoid Coord(tInt x, tInt y) override;
187 
188  tVoid Coord(tFloat32 x, tFloat32 y) override;
189 
190  tVoid Coord(IPoint* pt) override;
191 
192  tVoid Coord(IPoint** ppPoints, tInt nCount) override;
193 
194  tVoid CoordTexture(tFloat32 u, tFloat32 v) override;
195 
196  tVoid End() override;
197 
198 public: // implements ICanvas
199  tInt GetWidth() const override;
200 
201  tInt GetHeight() const override;
202 
203  tInt GetBitsPerPixel() const override;
204 
205  tVoid SetMapping(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) override;
206 
207  tVoid ClearMapping() override;
208 
209  tInt MapPixelX(tFloat32 x) override;
210 
211  tInt MapPixelY(tFloat32 y) override;
212 
213  tInt MapPixelX(tInt x) override;
214 
215  tInt MapPixelY(tInt y) override;
216 
217  tFloat32 UnmapPixelX(tInt x) override;
218 
219  tFloat32 UnmapPixelY(tInt y) override;
220 
221  tVoid Clear() override;
222 
223  tResult CreateTexture(IImage* pImage, ITexture*& pTexture) override;
224 
225  tVoid DrawTexture(ITexture* pTexture, tFloat32 vPoints[8]) override;
226 
227  tVoid DrawPixel(tInt x, tInt y) override;
228 
229  tVoid DrawLine(tInt x1, tInt y1, tInt x2, tInt y2) override;
230 
231  tVoid DrawRect(tInt x1, tInt y1, tInt x2, tInt y2) override;
232 
233  tVoid DrawCircle(tInt x1, tInt y1, tInt x2, tInt y2) override;
234 
235  tVoid DrawCircleSegment(tInt x1, tInt y1, tInt x2, tInt y2, tFloat64 fDegreeStart, tFloat64 fDegreeEnd,
236  tBool bNormalizeRect = tFalse) override;
237 
238  tVoid FillRect(tInt x1, tInt y1, tInt x2, tInt y2) override;
239 
240  tVoid FillCircle(tInt x1, tInt y1, tInt x2, tInt y2) override;
241 
242  tVoid FillCircleSegment(tInt x1, tInt y1, tInt x2, tInt y2, tFloat64 fDegreeStart, tFloat64 fDegreeEnd,
243  tBool bNormalizeRect = tFalse) override;
244 
245  tVoid DrawPixel(tFloat32 x, tFloat32 y) override;
246 
247  tVoid DrawLine(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) override;
248 
249  tVoid DrawRect(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) override;
250 
251  tVoid DrawCircle(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) override;
252 
253  tVoid DrawCircleSegment(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2, tFloat64 fDegreeStart, tFloat64 fDegreeEnd,
254  tBool bNormalizeRect = tFalse) override;
255 
256  tVoid FillRect(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) override;
257 
258  tVoid FillCircle(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) override;
259 
260  tVoid FillCircleSegment(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2, tFloat64 fDegreeStart, tFloat64 fDegreeEnd,
261  tBool bNormalizeRect = tFalse) override;
262 
263  tVoid DrawPixel(IPoint* pt) override;
264 
265  tVoid DrawLine(IPoint* ptStart, IPoint* ptEnd) override;
266 
267  tVoid DrawRect(IRect* rect) override;
268 
269  tVoid DrawPolygon(IPoint** ppPoints, tInt nCount) override;
270 
271  tVoid DrawCircle(IRect* rect) override;
272 
273  tVoid DrawCircleSegment(IRect* rect, tFloat64 fDegreeStart, tFloat64 fDegreeEnd) override;
274 
275  tVoid FillRect(IRect* rect) override;
276 
277  tVoid FillPolygon(IPoint** ppPoints, tInt nCount) override;
278 
279  tVoid FillCircle(IRect* rect) override;
280 
281  tVoid FillCircleSegment(IRect* rect, tFloat64 fDegreeStart, tFloat64 fDegreeEnd) override;
282 
283  IFont* CreateFont(const char* strName, tInt nHeight,
284  IFont::tStyle eFontStyle = IFont::STYLE_Default);
285 
286  tVoid SetFontAngle(tFloat64 fAngle);
287 
288  tFloat64 GetFontAngle();
289 
290  tVoid Font(IFont* pFont);
291 
292  tVoid OutputText(tInt x, tInt y, const char* fmt, ...);
293 
294  tVoid OutputText(tFloat32 x, tFloat32 y, const char* fmt, ...);
295 
296  ITexture* CreateTexture(const tBitmapFormat* psFormat, tInt nMode = 0) override;
297 
298  tVoid Texture(ITexture* pTexture) override;
299 
300  tVoid Blit(ITexture* pTexture, tInt x, tInt y, tInt nWidth, tInt nHeight) override;
301 
302  tVoid Blit(IImage* pImage, tInt x, tInt y, tInt nWidth, tInt nHeight) override;
303 
304  tVoid Capture(IImage** ppImage, tInt x, tInt y, tInt nWidth, tInt nHeight) override;
305 
306  IScene* BeginScene() override;
307 
308  tVoid EndScene() override;
309 
310  tVoid SetFlag(tUInt32 nFlag, tInt32 nValue);
311 
312  tInt32 GetFlag(tUInt32 nFlag);
313 
314  tResult PushFlags();
315 
316  tResult PopFlags();
317 
318  tVoid ResetFlags();
319 
320  tVoid DrawEllipse(tInt iOriginX, tInt iOriginY, tInt iWidth, tInt iHeight, tInt iAngle);
321 
322  tVoid DrawEllipse(tFloat32 f32OriginX, tFloat32 f32OriginY, tFloat32 f32Width, tFloat32 f32Height, tFloat32 f32Angle);
323 
324  tVoid FillEllipse(tInt iOriginX, tInt iOriginY, tInt iWidth, tInt iHeight, tInt iAngle);
325 
326  tVoid FillEllipse(tFloat32 f32OriginX, tFloat32 f32OriginY, tFloat32 f32Width, tFloat32 f32Height, tFloat32 f32Angle);
327 
328  tVoid PushMatrix();
329 
330  tVoid PopMatrix();
331 
332  tVoid Translate(tFloat fx, tFloat fy, tFloat fz) ;
333 
334  tVoid Scale(tFloat fx, tFloat fy, tFloat fz);
335 
336  tVoid Rotate(tFloat fangle, tFloat fx, tFloat fy, tFloat fz);
337 
338 
339 protected:
347  tVoid CoordLine(tInt x1, tInt y1, tInt x2, tInt y2) const;
348 
356  tVoid CoordRect(tInt x1, tInt y1, tInt x2, tInt y2) const;
357 
365  tVoid CoordCircle(tInt x1, tInt y1, tInt x2, tInt y2) const;
366 
376  tVoid CoordCircleSegment(tInt x1, tInt y1, tInt x2, tInt y2, tFloat64 fDegreeStart, tFloat64 fDegreeEnd) const;
377 
385  tVoid CoordLine(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) const;
386 
394  tVoid CoordRect(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) const;
395 
403  tVoid CoordCircle(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2) const;
404 
414  tVoid CoordCircleSegment(tFloat32 x1, tFloat32 y1, tFloat32 x2, tFloat32 y2, tFloat64 fDegreeStart,
415  tFloat64 fDegreeEnd) const;
416 
420  tVoid SwitchToScreenCoords();
421 
422 };
423 
424 }
425 
426 using dengar::cGLCanvas;
427 
428 }
429 
430 }
431 
432 }
433 
434 /// @endcond
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Main namespace.
Copyright © Audi Electronics Venture GmbH.
Struct to specifie a bitmap.