Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

gui::SDLControl Class Reference

#include <SDLControl.h>

List of all members.

Public Member Functions

 SDLControl (int argc, char *argv[], int=640, int=480, int=16)
virtual ~SDLControl ()
virtual void Init_SDL ()
void Update8bitPalette ()
void ToggleFullscreen ()
void lockSurface ()
void unlockSurface ()
void LockMutex ()
void UnlockMutex ()
SDL_Surface * GetScreen ()
short GetBpp ()
bool IsOK ()
void SetOK (bool)
void status ()

Private Member Functions

void read_config (int argc, char *argv[])

Private Attributes

bool m_ok
SDL_Surface * m_screen
coord_t m_width
coord_t m_height
short m_bpp
bool m_hw
bool m_hwpalette
bool m_noframe
bool m_fullscreen
Uint32 m_videoflags


Constructor & Destructor Documentation

gui::SDLControl::SDLControl int  argc,
char *  argv[],
int  = 640,
int  = 480,
int  = 16
 

Definition at line 59 of file SDLControl.cpp.

References DEB, Init_SDL(), m_bpp, m_fullscreen, m_height, m_hw, m_hwpalette, m_noframe, m_ok, m_screen, m_videoflags, m_width, read_config(), and status().

00060 :m_ok(false) 00061 ,m_screen(NULL) 00062 ,m_width(x) 00063 ,m_height(y) 00064 ,m_bpp(b) 00065 ,m_hw(false) 00066 ,m_hwpalette(false) 00067 ,m_noframe(false) 00068 ,m_fullscreen(false) 00069 ,m_videoflags(SDL_SWSURFACE) 00070 //,m_timerThread(NULL) 00071 { 00072 // Command line 00073 DEB(printf("read_config()\n");) 00074 read_config(argc,argv); 00075 00076 // Init SDL 00077 DEB(printf("Init_SDL()\n");) 00078 Init_SDL(); 00079 00080 if (!m_ok) 00081 { 00082 DEB(printf("Ej OK\n");) 00083 return; 00084 } 00085 00086 // Set window title 00087 DEB(printf("Set window title\n");) 00088 SDL_WM_SetCaption("Client Window", "input"); 00089 00090 // check flags 00091 if (m_hw) 00092 { 00093 m_videoflags |= SDL_HWSURFACE; 00094 } 00095 if (m_hwpalette) 00096 { 00097 m_videoflags |= SDL_HWPALETTE; 00098 } 00099 if (m_noframe) 00100 { 00101 m_videoflags |= SDL_NOFRAME; 00102 } 00103 if (m_fullscreen) 00104 { 00105 m_videoflags |= SDL_FULLSCREEN; 00106 } 00107 00108 // Set a video mode 00109 int bpp = m_bpp; 00110 if ( (m_bpp = SDL_VideoModeOK(m_width, m_height, m_bpp, m_videoflags) ) == 0) 00111 { 00112 fprintf(stderr,"Video mode not supported: %s\n", SDL_GetError()); 00113 m_ok = false; 00114 // return NULL; 00115 } 00116 else 00117 { 00118 DEB(printf("SDL is recommending %dbpp. Using %dbpp.\n", m_bpp, m_bpp);) 00119 } 00120 00121 m_bpp = bpp; 00122 if ( (m_screen = SDL_SetVideoMode(m_width, m_height, m_bpp, m_videoflags) ) == NULL) 00123 { 00124 fprintf(stderr,"Could not initialize SDL: %s.\n", SDL_GetError()); 00125 m_ok = false; 00126 // return NULL; 00127 } 00128 00129 DEB(printf("SDLControl():\n");) 00130 status(); 00131 00132 // m_timerThread = new TimerThread; 00133 }

gui::SDLControl::~SDLControl  )  [virtual]
 

Definition at line 136 of file SDLControl.cpp.

References m_ok.

00137 { 00138 /* 00139 if (m_timerThread) 00140 { 00141 m_timerThread -> SetRunning(false); 00142 SDL_Delay(250); 00143 delete m_timerThread; 00144 } 00145 */ 00146 // DeInit SDL 00147 if (m_ok) 00148 { 00149 SDL_Quit(); 00150 } 00151 }


Member Function Documentation

short gui::SDLControl::GetBpp  ) 
 

Definition at line 295 of file SDLControl.cpp.

References m_bpp.

00296 { 00297 return m_bpp; 00298 }

SDL_Surface * gui::SDLControl::GetScreen  ) 
 

Definition at line 289 of file SDLControl.cpp.

References m_screen.

Referenced by gui::GuiEvent::MouseMotionEvent().

00290 { 00291 return m_screen; 00292 }

void gui::SDLControl::Init_SDL  )  [virtual]
 

Definition at line 206 of file SDLControl.cpp.

References DEB, and m_ok.

Referenced by SDLControl().

00207 { 00208 DEB(printf("SDL_Init()\n");) 00209 if (SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO ) < 0) 00210 { 00211 DEB(printf("SDL_Init() ej ok\n");) 00212 fprintf(stderr,"SDL error: %s\n",SDL_GetError() ); 00213 } 00214 else 00215 { 00216 DEB(printf("SDL_Init() OK\n");) 00217 m_ok = true; 00218 } 00219 }

bool gui::SDLControl::IsOK  ) 
 

Definition at line 301 of file SDLControl.cpp.

References DEB, and m_ok.

00302 { 00303 DEB( if (m_ok) 00304 { 00305 printf("m_ok is true\n"); 00306 } 00307 else 00308 { 00309 printf("m_ok is false\n"); 00310 }) 00311 return m_ok; 00312 }

void gui::SDLControl::LockMutex  ) 
 

Definition at line 322 of file SDLControl.cpp.

00323 { 00324 // m_mutex.Lock(); 00325 }

void gui::SDLControl::lockSurface  ) 
 

Definition at line 334 of file SDLControl.cpp.

References m_screen.

00335 { 00336 /* 00337 if (bClearRects) 00338 { 00339 while (m_rects.size()) 00340 { 00341 m_rects.erase(m_rects.begin()); 00342 } 00343 } 00344 */ 00345 if ( SDL_MUSTLOCK(m_screen) ) 00346 { 00347 if ( SDL_LockSurface(m_screen) < 0 ) 00348 { 00349 fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); 00350 return; 00351 } 00352 } 00353 }

void gui::SDLControl::read_config int  argc,
char *  argv[]
[private]
 

Definition at line 154 of file SDLControl.cpp.

References m_bpp, m_fullscreen, m_height, m_hw, m_hwpalette, m_noframe, and m_width.

Referenced by SDLControl().

00155 { 00156 // See if we try to get a hardware colormap 00157 for (int loop = 1; loop < argc; loop++) 00158 { 00159 if (!strcmp(argv[loop],"-width") && loop < argc - 1) 00160 { 00161 m_width = atoi(argv[loop + 1]); 00162 loop++; 00163 } 00164 else 00165 if (!strcmp(argv[loop],"-height") && loop < argc - 1) 00166 { 00167 m_height = atoi(argv[loop + 1]); 00168 loop++; 00169 } 00170 else 00171 if (!strcmp(argv[loop],"-bpp") && loop < argc - 1) 00172 { 00173 m_bpp = atoi(argv[loop + 1]); 00174 loop++; 00175 } 00176 else 00177 if (!strcmp(argv[loop],"-hw")) 00178 { 00179 m_hw = true; 00180 } 00181 else 00182 if (!strcmp(argv[loop],"-hwpalette")) 00183 { 00184 m_hwpalette = true; 00185 } 00186 else 00187 if (!strcmp(argv[loop],"-noframe")) 00188 { 00189 m_noframe = true; 00190 } 00191 else 00192 if (!strcmp(argv[loop],"-fullscreen")) 00193 { 00194 m_fullscreen = true; 00195 } 00196 else 00197 { 00198 fprintf(stderr,"'%s'?\n",argv[loop]); 00199 fprintf(stderr,"Usage: %s [-width xx] [-height xx] [-bpp xx]\n",*argv); 00200 fprintf(stderr," [-hw] [-hwpalette] [-noframe] [-fullscreen]\n"); 00201 } 00202 } 00203 }

void gui::SDLControl::SetOK bool   ) 
 

Definition at line 315 of file SDLControl.cpp.

References DEB, and m_ok.

00316 { 00317 DEB(printf("SetOK = %s\n",ok ? "TRUE" : "FALSE");) 00318 m_ok = ok; 00319 }

void gui::SDLControl::status  ) 
 

Definition at line 403 of file SDLControl.cpp.

References DEB, m_bpp, m_fullscreen, m_height, m_hw, m_hwpalette, m_noframe, m_ok, and m_width.

Referenced by SDLControl().

00404 { 00405 DEB( printf("m_ok: %s\n", m_ok ? "true" : "false"); 00406 printf("m_width: %d\n", m_width); 00407 printf("m_height: %d\n", m_height); 00408 printf("m_bpp: %d\n", m_bpp); 00409 printf("m_hw: %s\n", m_hw ? "true" : "false"); 00410 printf("m_hwpalette: %s\n", m_hwpalette ? "true" : "false"); 00411 printf("m_noframe: %s\n", m_noframe ? "true" : "false"); 00412 printf("m_fullscreen: %s\n", m_fullscreen ? "true" : "false");) 00413 }

void gui::SDLControl::ToggleFullscreen  ) 
 

Definition at line 271 of file SDLControl.cpp.

References m_bpp, m_fullscreen, m_height, m_ok, m_screen, m_videoflags, and m_width.

00272 { 00273 m_fullscreen = !m_fullscreen; 00274 m_videoflags ^= SDL_FULLSCREEN; 00275 // m_mutex.Lock(); 00276 00277 // CreateScreen(); 00278 if ( (m_screen = SDL_SetVideoMode(m_width, m_height, m_bpp, m_videoflags) ) == NULL) 00279 { 00280 fprintf(stderr,"Could not initialize SDL: %s.\n", SDL_GetError()); 00281 m_ok = false; 00282 // return NULL; 00283 } 00284 00285 // m_mutex.Unlock(); 00286 }

void gui::SDLControl::UnlockMutex  ) 
 

Definition at line 328 of file SDLControl.cpp.

00329 { 00330 // m_mutex.Unlock(); 00331 }

void gui::SDLControl::unlockSurface  ) 
 

Definition at line 378 of file SDLControl.cpp.

References m_screen.

00379 { 00380 if ( SDL_MUSTLOCK(m_screen) ) 00381 { 00382 SDL_UnlockSurface(m_screen); 00383 } 00384 /* 00385 if (bUpdateRects && m_rects.size()) 00386 { 00387 SDL_Rect *rects = new SDL_Rect[m_rects.size()]; 00388 int i = 0; 00389 rectvector_t::iterator it; 00390 00391 for (it = m_rects.begin(); it != m_rects.end(); it++) 00392 { 00393 rects[i] = (*it); 00394 i++; 00395 } 00396 SDL_UpdateRects(m_screen, i, rects); 00397 delete rects; 00398 } 00399 */ 00400 }

void gui::SDLControl::Update8bitPalette  ) 
 

Definition at line 265 of file SDLControl.cpp.

00266 { 00267 // SDL_SetColors(m_screen, gui::Color::m_palette, 0, gui::Color::m_qcolors); 00268 }


Member Data Documentation

short gui::SDLControl::m_bpp [private]
 

Definition at line 71 of file SDLControl.h.

Referenced by GetBpp(), read_config(), SDLControl(), status(), and ToggleFullscreen().

bool gui::SDLControl::m_fullscreen [private]
 

Definition at line 75 of file SDLControl.h.

Referenced by read_config(), SDLControl(), status(), and ToggleFullscreen().

coord_t gui::SDLControl::m_height [private]
 

Definition at line 70 of file SDLControl.h.

Referenced by read_config(), SDLControl(), status(), and ToggleFullscreen().

bool gui::SDLControl::m_hw [private]
 

Definition at line 72 of file SDLControl.h.

Referenced by read_config(), SDLControl(), and status().

bool gui::SDLControl::m_hwpalette [private]
 

Definition at line 73 of file SDLControl.h.

Referenced by read_config(), SDLControl(), and status().

bool gui::SDLControl::m_noframe [private]
 

Definition at line 74 of file SDLControl.h.

Referenced by read_config(), SDLControl(), and status().

bool gui::SDLControl::m_ok [private]
 

Definition at line 67 of file SDLControl.h.

Referenced by Init_SDL(), IsOK(), SDLControl(), SetOK(), status(), ToggleFullscreen(), and ~SDLControl().

SDL_Surface* gui::SDLControl::m_screen [private]
 

Definition at line 68 of file SDLControl.h.

Referenced by GetScreen(), lockSurface(), SDLControl(), ToggleFullscreen(), and unlockSurface().

Uint32 gui::SDLControl::m_videoflags [private]
 

Definition at line 76 of file SDLControl.h.

Referenced by SDLControl(), and ToggleFullscreen().

coord_t gui::SDLControl::m_width [private]
 

Definition at line 69 of file SDLControl.h.

Referenced by read_config(), SDLControl(), status(), and ToggleFullscreen().


The documentation for this class was generated from the following files:
Generated for My SDL C++ Gui by doxygen 1.3.6

www.TV-friendship.com
The matchmaking service with an all new twist.

Quantum 'Teleportation'
Some thoughts
Page, code, and content Copyright (C) 2004 by Anders Hedström