1 // RenderArea2D.hxx - a class to manage 2D polygon-based drawing
2 // for a complex instrument (eg. GPS).
4 // Written by David Luff, started 2005.
6 // Copyright (C) 2005 - David C Luff - david.luff@nottingham.ac.uk
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef _RENDER_AREA_2D
25 #define _RENDER_AREA_2D
31 #include <simgear/compiler.h>
38 enum RA2DDrawingType {
44 struct RA2DPrimitive {
56 RenderArea2D(int logx, int logy, int sizex, int sizey, int posx, int posy);
61 void SetPixelColor(const float* rgba);
62 void SetBackgroundColor(const float* rgba);
63 void SetPosition(int posx, int posy);
64 void SetLogicalSize(int logx, int logy);
65 void SetActualSize(int sizex, int sizey);
67 // Set clipping region in logical units
68 void SetClipRegion(int x1, int y1, int x2, int y2);
69 // Set clip region to be the same as the rendered area (default)
70 void ResetClipRegion();
72 // Drawing specified in logical units
73 void DrawLine(int x1, int y1, int x2, int y2);
74 void DrawQuad(int x1, int y1, int x2, int y2, bool invert = false);
75 void DrawBackground();
76 // Draw a pixel specified by *logical* position
77 void DrawPixel(int x, int y, bool invert = false);
79 // The old drawing functions have been renamed in order to buffer the drawing for FG
81 // Drawing specified in logical units
82 void oldDrawLine(int x1, int y1, int x2, int y2);
83 void oldDrawQuad(int x1, int y1, int x2, int y2, bool invert = false);
84 void oldDrawBackground();
85 // Draw a pixel specified by *logical* position
86 void oldDrawPixel(int x, int y, bool invert = false);
88 // Flush the buffer pipeline
91 // Turn debugging on or off.
92 inline void SetDebugging(bool b) { _ra2d_debug = b; }
95 int _logx, _logy; // logical size of rendered area
96 int _sizex, _sizey; // Actual size of rendered area
97 int _posx, _posy; // Position of rendered area
98 int _clipx1, _clipx2, _clipy1, _clipy2; // Current clipping region in *logical* units
100 float _backgroundColor[4];
101 float _pixelColor[4];
103 // Actual drawing routines copied from Atlas
104 void doSetColor( const float *rgb );
105 void doDrawQuad( const sgVec2 *p, const sgVec3 *normals );
106 void doDrawQuad( const sgVec2 *p, const sgVec3 *normals, const sgVec4 *color );
108 vector<RA2DPrimitive> drawing_list;
110 // Control whether to output debugging output