Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

graphic_context.hxx

Go to the documentation of this file.
00001 //  $Id: graphic_context.hxx,v 1.14 2003/01/09 22:10:24 grumbel Exp $
00002 // 
00003 //  Construo - A wire-frame construction game
00004 //  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 // 
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_CONSTRUO_GRAPHIC_CONTEXT_HXX
00021 #define HEADER_CONSTRUO_GRAPHIC_CONTEXT_HXX
00022 
00023 #include <string>
00024 #include <vector>
00025 #include "math.hxx"
00026 #include "vector2d.hxx"
00027 #include "color.hxx"
00028 
00030 class GraphicContext
00031 {
00032 private:
00033 public:
00034   struct Line
00035   {
00036     float x1, y1;
00037     float x2, y2;
00038   };
00039 
00040   struct Circle
00041   {
00042     float x, y, r;
00043   };
00044 
00045   void draw_circle(const Vector2d& pos, float radius, Color color)
00046   {
00047     draw_circle (pos.x, pos.y, radius, color);
00048   }
00049 
00050   void draw_fill_circle(const Vector2d& pos, float radius, Color color)
00051   {
00052     draw_fill_circle (pos.x, pos.y, radius, color);
00053   }
00054 
00055   void draw_string(const Vector2d& pos, const std::string& str, Color color = Color (0xFFFFFFFF))
00056   {
00057     draw_string (pos.x, pos.y, str, color);
00058   }
00059 
00060   void draw_line (const Vector2d& pos1, const Vector2d& pos2, Color color, int wide = 0)
00061   {
00062     draw_line (pos1.x, pos1.y, pos2.x, pos2.y, color, wide);
00063   }
00064 
00065   void draw_rect (const Vector2d& pos1, const Vector2d& pos2, Color color)
00066   {
00067     draw_rect (Math::min(pos1.x, pos2.x),
00068                Math::min(pos1.y, pos2.y),
00069                Math::max(pos1.x, pos2.x),
00070                Math::max(pos1.y, pos2.y),
00071                color);
00072   }
00073 
00074   void draw_fill_rect (const Vector2d& pos1, const Vector2d& pos2, Color color)
00075   {
00076     draw_fill_rect (pos1.x, pos1.y, pos2.x, pos2.y, color);
00077   }
00078 
00079   virtual void draw_lines (std::vector<Line>& lines, Color color, int wide = 0) =0;
00080   virtual void draw_line(float x1, float y1, float x2, float y2, Color color, int wide = 0) =0;
00081   virtual void draw_rect(float x1, float y1, float x2, float y2, Color color) =0;
00082   virtual void draw_circle(float x, float y, float radius, Color color) =0;
00083   virtual void draw_circles(std::vector<Circle>& circles, Color color) =0;
00084   virtual void draw_fill_circle(float x, float y, float radius, Color color) =0;
00085   virtual void draw_fill_rect(float x1, float y1, float x2, float y2, Color color) =0;
00086   virtual void draw_string(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF)) =0;
00087 
00088   virtual void draw_string_centered(float x, float y, const std::string& str, Color color = Color (0xFFFFFFFF)) =0;
00089 
00090   virtual void set_clip_rect (int x1_, int y1_, int x2_, int y2_) =0;
00091 
00092   virtual int get_width ()  =0;
00093   virtual int get_height () =0;
00094 
00095   virtual void clear () =0;
00096 
00098   virtual void flip () =0;
00099   virtual void real_flip () {}
00100   virtual void flip (int x1, int y1, int x2, int y2) =0;
00101 };
00102 
00103 #endif
00104 
00105 /* EOF */

Generated on Thu Jul 24 10:24:29 2003 for Construo by doxygen1.3-rc3

Rabisu Mirror Service We provide mirrors to support Open source communities. Our mirror server is located in Istanbul/Turkey region.

Please do not hesitate to contact mirror@rabisu.com for new open source mirror submissions.