00001 /* 00002 $Id: display.h,v 1.2 2001/03/15 12:14:46 mbn Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00016 00017 #ifndef header_display 00018 #define header_display 00019 00020 #include <vector> 00021 class CL_Palette; 00022 class CL_DisplayCard; 00023 class CL_VidMode; 00024 class CL_Target; 00025 class CL_Surface; 00026 class CL_Rect; 00027 00028 #include "cliprect.h" 00029 #include "../../signals.h" 00030 00031 class CL_Display 00032 //: Main Display class. 00033 // <p>CL_Display is the "main" class when dealing with 2D graphics. It 00034 // contains simple drawing operations, backbuffer clipping and access to the 00035 // display cards available on the system.</p> 00036 // 00037 // <p>A large amount of the functions in the class have the same purpose as 00038 // their name equalient in CL_DisplayCard. The difference is that those 00039 // placed here operate on a selected display card, while those in 00040 // CL_DisplayCard class require an instance to the card.</p> 00041 // 00042 // <p>All backbuffer related drawing operations in other classes (CL_Surface 00043 // for instance) work on the currently selected display card, unless you 00044 // explict pass a pointer pointing to a display card.</p> 00045 // 00046 // <p>The main purpose of this system is to avoid passing around a pointer 00047 // to the display card in those games, where it only access one single 00048 // card anyway.</p> 00049 // 00050 // <p>When using OpenGL the GL context will always point to the selected 00051 // card. So if you need to use OpenGL commands to draw onto another card, 00052 // you have to select it here.</p> 00053 { 00054 public: 00055 virtual ~CL_Display() { ; } 00056 00057 static void flip_display(bool sync=false); 00058 //: Flips the front and backbuffer. Everything is normally drawn to the 00059 //: backbuffer, and flip_display() needs to be called before it can be seen 00060 //: onto the screen. 00062 00063 static void put_display(const CL_Rect &rect); 00064 //: Copies the specified area of the backbuffer to the front buffer. This is 00065 //: in particular useful if you only want to update a limited region, and not 00066 //: do a full-blown flipping. 00067 00068 static void sync_buffers(); 00069 //: Copies the contents of the frontbuffer to all other buffers (usually just 00070 //: the backbuffer). This ensures that all buffers contain the same image. 00071 00072 static void clear_display(float red=0, float green=0, float blue=0, float alpha=1); 00073 //: Clears backbuffer with the specified color. 00078 00079 static void set_palette(CL_Palette *palette); 00080 //: Set system palette on this card. 00081 //: <br> 00082 //: If the display card is in a non-palettelized mode, this will be the palette 00083 //: used when surfaceproviders doesn't specify a palette themself. 00085 00086 static CL_Palette *get_palette(); 00087 //: Return the current system palette on this card. 00089 00090 static void select_card(CL_DisplayCard *card); 00091 //: Selects the display card used by the other memberfunctions of this class. 00093 00094 static CL_DisplayCard *get_current_card(); 00095 //: Returns the currently selected display card. 00097 00098 static void set_videomode(CL_VidMode *mode); 00099 //: Change the display card's video mode. 00102 00103 static void set_videomode( 00104 int width, 00105 int height, 00106 int bpp, 00107 bool fullscreen = true, 00108 bool allow_resize = false, 00109 bool video_memory = true); 00110 //: Change the display card's video mode. 00115 00116 static CL_Target *get_target(); 00117 //: Returns either NULL or the framebuffer 00119 00120 static int get_width(); 00121 //: Returns the width of the current video mode. 00123 00124 static int get_height(); 00125 //: Returns the height of the current video mode. 00127 00128 static int get_bpp(); 00129 //: Returns the depth of the current video mode. 00131 00132 static std::vector<CL_DisplayCard*> cards; 00133 //: The list of display cards available to the application. 00134 00135 static void push_clip_rect(); 00136 //: Pushes the current clipping rectangle onto the cliprect stack. 00137 00138 static void push_clip_rect(const CL_ClipRect &rect); 00139 //: Pushes the current clipping rectangle onto the cliprect stack. It then clips 00140 //: the passed rectangle 'rect' with the current one, and uses the result as the 00141 //: new clipping rect. 00143 00144 static CL_ClipRect get_clip_rect(); 00145 //: Returns the current clipping rectangle. 00147 00148 static void set_clip_rect(const CL_ClipRect &rect); 00149 //: Sets the current clipping rectangle. This is an absolute set, so it doesn't 00150 //: get clipped with the previous one. 00151 00152 static void pop_clip_rect(); 00153 //: Pop the clipping rectangle last pushed onto the stack. 00154 00155 static void push_translate_offset(); 00156 //: Pushes the current translation rectangle onto the cliprect stack. 00157 00158 static void push_translate_offset(int x, int y); 00159 //: Push translation offset onto translation stack. This offset will 00160 //: affect any subsequent display operations on the current displaycard, by 00161 //: translating the position of the display operation with the offset. 00162 //: The offset will be offset by any previous offsets pushed onto the stack, 00163 //: eg. it inherits the previous offset. 00164 00165 static int get_translate_offset_x(); 00166 //: Returns the current effective x-axis translation offset. 00167 00168 static int get_translate_offset_y(); 00169 //: Returns the current effective y-axis translation offset. 00170 00171 static void set_translate_offset(int x, int y); 00172 //: Sets the translation offset as a new absolute translation offset. 00173 //: The new offset will disregard any previous offset's, but will not 00174 //: empty the translation stack. The new translation offset will affect 00175 //: any subsequent display operations on the current displaycard, by 00176 //: translating the position of the display operation with the offset 00177 00178 static void pop_translate_offset(); 00179 //: Pops the last pushed translation offset from the translation offset 00180 //: stack. If the stack is empty, nothing will happen, and if the last 00181 //: translation offset is popped, the translation offset will be set to 0,0 00182 00183 static void draw_rect(int x1, int y1, int x2, int y2, float r, float g, float b, float a=1.0f); 00184 //: Draw a rectangle from ('x1', 'y1') to ('x2', 'y2') using the color 00185 //: ('r', 'g', 'b', 'a'). 00194 00195 static void fill_rect(int x1, int y1, int x2, int y2, float r, float g, float b, float a=1.0f); 00196 //: Draw a filled rectangle from ('x1', 'y1') to ('x2', 'y2') using the color 00197 //: ('r', 'g', 'b', 'a'). 00206 00207 static void draw_line(int x1, int y1, int x2, int y2, float r, float g, float b, float a=1.0f); 00208 //: Draw a line from ('x1', 'y1') to ('x2', 'y2') using the color 00209 //: ('r', 'g', 'b', 'a'). 00218 00219 static void fill_rect(int x1, int y1, int x2, int y2, CL_Surface *fill_surface, int focus_x=0, int focus_y=0); 00220 //: Draw a filled rectangle from ('x1', 'y1') to ('x2', 'y2') using the surface 'fill_surface' as tiled background 00228 00229 static CL_Signal_v2<int, int> &get_sig_resize(); 00230 //: Returns the resize signal for the currently selected display card. 00231 // You can use this signal to listen for window resize events. 00232 // The parameters passed by the signal are the new width and height of the window. 00233 00234 static CL_Signal_v1<const CL_Rect &> &get_sig_paint(); 00235 //: Returns the paint signal for the currently selected display card. 00236 // Use this signal to listen for invalidated screen areas that need to be repainted. 00237 // The parameter passed by the signal is the area that need a repaint. 00238 }; 00239 00240 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001