Rebuild autotool system
[construo.git] / graphic_context.hxx
blob829dc8dacd56f456df0a336a749dac95a8b3cf31
1 // $Id: graphic_context.hxx,v 1.16 2003/07/24 21:33:11 grumbel Exp $
2 //
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_CONSTRUO_GRAPHIC_CONTEXT_HXX
21 #define HEADER_CONSTRUO_GRAPHIC_CONTEXT_HXX
23 #include <string>
24 #include <vector>
25 #include "math.hxx"
26 #include "vector2d.hxx"
27 #include "color.hxx"
29 /** Graphic abstraction interface */
30 class GraphicContext
32 private:
33 public:
34 struct Line
36 float x1, y1;
37 float x2, y2;
40 struct Circle
42 float x, y, r;
45 void draw_circle(const Vector2d& pos, float radius, Color color)
47 draw_circle (pos.x, pos.y, radius, color);
50 void draw_fill_circle(const Vector2d& pos, float radius, Color color)
52 draw_fill_circle (pos.x, pos.y, radius, color);
55 void draw_string(const Vector2d& pos, const std::string& str, Color color = Color (0xFFFFFFFF))
57 draw_string (pos.x, pos.y, str, color);
60 void draw_line (const Vector2d& pos1, const Vector2d& pos2, Color color, int wide = 0)
62 draw_line (pos1.x, pos1.y, pos2.x, pos2.y, color, wide);
65 void draw_rect (const Vector2d& pos1, const Vector2d& pos2, Color color)
67 draw_rect (Math::min(pos1.x, pos2.x),
68 Math::min(pos1.y, pos2.y),
69 Math::max(pos1.x, pos2.x),
70 Math::max(pos1.y, pos2.y),
71 color);
74 void draw_fill_rect (const Vector2d& pos1, const Vector2d& pos2, Color color)
76 draw_fill_rect (pos1.x, pos1.y, pos2.x, pos2.y, color);
79 virtual void draw_lines (std::vector<Line>& lines, Color color, int wide = 0) =0;
80 virtual void draw_line(float x1, float y1, float x2, float y2, Color color, int wide = 0) =0;
81 virtual void draw_rect(float x1, float y1, float x2, float y2, Color color) =0;
82 virtual void draw_circle(float x, float y, float radius, Color color) =0;
83 virtual void draw_circles(std::vector<Circle>& circles, Color color) =0;
84 virtual void draw_fill_circle(float x, float y, float radius, Color color) =0;
85 virtual void draw_fill_rect(float x1, float y1, float x2, float y2, Color color) =0;
86 virtual void draw_string(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF)) =0;
88 virtual void draw_string_centered(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF)) =0;
90 virtual void set_clip_rect (int x1_, int y1_, int x2_, int y2_) =0;
92 virtual int get_width () =0;
93 virtual int get_height () =0;
95 virtual void clear () =0;
97 /** FIXME: flip should be handled outsite of GraphicContext */
98 virtual void flip () =0;
99 virtual void real_flip () {}
100 virtual void flip (int x1, int y1, int x2, int y2) =0;
102 /** Goes into quick draw mode, disabling anti-aliasing and other
103 time consuming features */
104 virtual void push_quick_draw() {}
106 /** Goes out of quickdraw mode, restoring previous settings */
107 virtual void pop_quick_draw() {}
110 #endif
112 /* EOF */