1
// $Id: display_graphic_context.hxx,v 1.2 2003/03/16 23:07:02 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
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.
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_DISPLAY_GRAPHIC_CONTEXT_HXX
21
#define HEADER_DISPLAY_GRAPHIC_CONTEXT_HXX
23
#include "../vector.hxx"
24
#include <ClanLib/Core/Math/rect.h>
26
#include "graphic_context.hxx"
28
/** A GraphicContext which represents the display and allows you to
30
class DisplayGraphicContext : public GraphicContext
33
/** Position of the display on the screen */
39
/** center of the display */
43
DisplayGraphicContext (int x1, int y1, int x2, int y2,
44
int /*x_offset*/, int /*y_offset*/);
45
virtual ~DisplayGraphicContext ();
49
float get_x_offset ();
50
float get_y_offset ();
52
void set_offset (float x, float y);
54
CL_Rect get_clip_rect();
60
void set_zoom (float new_zoom);
62
/** Set the current zoom and offset, so that the given rectangle is
63
completly visible on the screen and maximally zoomed. */
64
void zoom_to (const CL_Rect & rect);
66
/// Scroll the view by the given delta
67
void move (const Vector & delta);
69
/** Converts a given screen coordinate, as returned by
70
CL_Mouse::get_x(), into the world coordinate system. */
71
Vector screen_to_world (Vector pos);
72
Vector world_to_screen (Vector pos);
74
void clear (float r, float g, float b);
76
void draw (Sprite& sprite, const Vector& pos);
77
void draw (Sprite& sprite, const Vector& pos, int frame);
78
void draw (CL_Surface& sur, const Vector& pos);
79
void draw (CL_Surface& sur, const Vector& pos, int frame);
81
void draw (CL_Surface& sur, int x_pos, int y_pos);
82
void draw (CL_Surface& sur, int x_pos, int y_pos, int frame);
84
/** Draw a scaled surface */
85
void draw (CL_Surface& sur, int x_pos, int y_pos,
86
float size_x, float size_y, int frame);
89
void draw_line (const Vector& pos1, const Vector& pos2,
90
float r, float g, float b, float a = 1.0f);
92
void draw_line (int x1, int y1, int x2, int y2,
93
float r, float g, float b, float a = 1.0f);
95
/** Draw a filled rectangle (FIXME: [x1,x2] or [x1,x2[ ?) */
96
void draw_fillrect (int x1, int y1, int x2, int y2,
97
float r, float g, float b, float a = 1.0f);
99
/** Draw an unfilled rectangle (FIXME: [x1,x2] or [x1,x2[ ?) */
100
void draw_rect (int x1, int y1, int x2, int y2,
101
float r, float g, float b, float a = 1.0f);
103
/** Draw a singel pixel */
104
void draw_pixel (int x_pos, int y_pos,
105
float r, float g, float b, float a = 1.0f);
108
void draw_circle (int x_pos, int y_pos, int radius,
109
float r, float g, float b, float a = 1.0f);
111
void print_left (FontHandle font, int x_pos, int y_pos, const std::string& str);
113
void print_center (FontHandle font, int x_pos, int y_pos, const std::string& str);
115
void print_right (FontHandle font, int x_pos, int y_pos, const std::string& str);
118
DisplayGraphicContext (const DisplayGraphicContext&);
119
DisplayGraphicContext& operator= (const DisplayGraphicContext&);