Adonthell 0.4
|
00001 /* 00002 $Id: screen.h,v 1.25 2004/10/25 06:55:01 ksterker Exp $ 00003 00004 Copyright (C) 1999/2000/2001/2004 Alexandre Courbot 00005 Part of the Adonthell Project http://adonthell.linuxgames.com 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License. 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY. 00011 00012 See the COPYING file for more details. 00013 */ 00014 00015 /** 00016 * @file screen.h 00017 * @author Alexandre Courbot <alexandrecourbot@linuxgames.com> 00018 * 00019 * @brief Declares the screen class. 00020 * 00021 * 00022 */ 00023 00024 #ifndef SCREEN_H_ 00025 #define SCREEN_H_ 00026 00027 #include "surface.h" 00028 #include <string> 00029 00030 00031 #ifndef SWIG 00032 using namespace std; 00033 #endif 00034 00035 00036 /** Screen access is made through this class. 00037 * This static class sets video modes, flush the frame buffer to the physical 00038 * screen and make abstraction of the real screen depth to ease the graphic 00039 * programmer's task. 00040 */ 00041 class screen 00042 { 00043 public: 00044 00045 /** 00046 * The actual screen surface. 00047 * It is publicly available so you can do fast operations on the screen. 00048 * Manipulate it just as a classic surface. 00049 * 00050 */ 00051 static surface display; 00052 00053 /** Sets the video mode. 00054 * @param nl X screen resolution. 00055 * @param nh Y screen resolution. 00056 * @param depth desired screen depth. 00057 */ 00058 static void set_video_mode (u_int16 nl, u_int16 nh, u_int8 depth = 0, bool dbl = false, bool fscreen = false); 00059 00060 /** Returns the length of the screen. 00061 * @return length of the screen. 00062 */ 00063 static u_int16 length () 00064 { 00065 return display.length (); 00066 } 00067 00068 /** Returns the height of the screen. 00069 * @return height of the screen. 00070 */ 00071 static u_int16 height () 00072 { 00073 return display.height (); 00074 } 00075 00076 /** Returns the screen depth, in bytes per pixel. 00077 * @return screen depth, in bytes per pixel. 00078 */ 00079 static u_int8 bytes_per_pixel () 00080 { 00081 return bytes_per_pixel_; 00082 } 00083 00084 /** Returns the translucent color in %screen's depth format. 00085 * For manipulation on images that will only be displayed, this is 00086 * the right function to call for getting the translucent color. 00087 * @return the translucent color in %screen's depth format. 00088 */ 00089 static u_int32 trans_col () 00090 { 00091 return trans; 00092 } 00093 00094 /** 00095 * Totally clears the screen with black. 00096 * 00097 */ 00098 static void clear () 00099 { 00100 display.fillrect (0, 0, display.length (), display.height (), 0x0); 00101 } 00102 00103 /** Ensure the framebuffer is copied to the physical screen. 00104 */ 00105 static void show (); 00106 00107 /** Returns whether the current mode is fullscreen or windowed. 00108 * @return 00109 * - true: fullscreen. 00110 * - false: windowed. 00111 */ 00112 static bool is_fullscreen () 00113 { 00114 return fullscreen_; 00115 } 00116 00117 /** Sets fullscreen/windowed mode. 00118 * @param mode 00119 * - true: fullscreen mode. 00120 * - false: windowed mode. 00121 * @return 00122 * @li true if the operation succeed. 00123 * @li false if the mode is already set, or the system doesn't support 00124 * this mode. 00125 */ 00126 static bool set_fullscreen (bool m); 00127 00128 /** 00129 * Returns information about the current screen settings, 00130 * suitable for being displayed to the user. 00131 * 00132 * 00133 * @return printable information about the current screen settings. 00134 */ 00135 static string info (); 00136 00137 static bool dbl_mode () { return dblmode; } 00138 00139 /** 00140 * Make a nice transition effect. 00141 * 00142 * @param i advancement of the transition (finished when i == screen::length () / 2) 00143 */ 00144 static void transition (u_int16 i); 00145 00146 private: 00147 /// Bytes per pixel. 00148 static u_int8 bytes_per_pixel_; 00149 00150 /// Transparent color. 00151 static u_int32 trans; 00152 00153 /// Whether fullscreen is on or not. 00154 static bool fullscreen_; 00155 00156 static bool dblmode; 00157 }; 00158 00159 00160 #endif