sdldisplay.h

Go to the documentation of this file.
00001 /*
00002   libwt - Vassilis Virvilis Toolkit - a widget library
00003   Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm>
00004  
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the
00017   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018   Boston, MA  02111-1307, SA.
00019 */
00020 
00021 #ifndef WT_SDLDISPLAY_H
00022 #define WT_SDLDISPLAY_H
00023 
00024 #include "sdlsurface.h"
00025 
00026 #include <wt/singleton.h>
00027 
00028 namespace Wt {
00029 
00030 /// interface to the underlying SDL_VideoSurface
00031 class SDLDisplay : public SDLSurface, public Singleton<SDLDisplay> {
00032     friend class Singleton<SDLDisplay>;
00033 
00034 public:
00035     typedef enum {
00036         defaultWidth = 640,
00037         defaultHeight = 480,
00038         defaultDepth = 32,
00039     } DefaultSurface;
00040 
00041 public:
00042     /// Initialize the target screen surface
00043     SDLDisplay(int w = defaultWidth, int h = defaultHeight,
00044                int depth = defaultDepth, int flags = 0);
00045 
00046     //! \name Informative methods
00047     //@{
00048     bool isAnyFormat() const {
00049         return flags() & SDL_ANYFORMAT ;
00050     }
00051 
00052     bool hasDoubleBuffer() const {
00053         return flags() & SDL_DOUBLEBUF;
00054     }
00055 
00056     bool isFullScreen() const {
00057         return flags() & SDL_FULLSCREEN;
00058     }
00059 
00060     bool hasOpenGL() const {
00061         return flags() & SDL_OPENGL;
00062     }
00063 
00064     bool hasOpenGLBlit() const {
00065         return flags() & SDL_OPENGLBLIT;
00066     }
00067 
00068     bool isResizable() const {
00069         return flags() & SDL_RESIZABLE;
00070     }
00071 
00072     bool hasFrame() const {
00073         return !(flags() & SDL_NOFRAME);
00074     }
00075     //@}
00076 
00077     //! \name update methods
00078     //@{
00079     /// Update the surface
00080     void update();
00081     /// Update a rectangle on the surface
00082     void update(const SDLRect& rect);
00083     /// Update a region on the surface
00084     void update(const std::vector<SDLRect>& rects);
00085     /// If doublebuffered(), flip the surface and its buffer, otherwise update()
00086     void flip();
00087     //@}
00088 
00089     //! \name Gamma methods
00090     //@{
00091     int setGamma(float red, float green, float blue);
00092     /// ???
00093     int setGammaRamp(const std::vector<Uint16>& red,
00094                      const std::vector<Uint16>& green,
00095                      const std::vector<Uint16>& blue);
00096     //@}
00097 
00098     //! \name resize methods
00099     //@{
00100     /// returns true if the surface is full screen
00101     int toggleFullScreen();
00102 
00103     /// resize the SDL window
00104     void resize(int w, int h);
00105     //@}
00106 
00107 protected:
00108     static SDLDisplay *load(int w = defaultWidth, int h = defaultHeight,
00109                int depth = defaultDepth, int flags = 0);
00110     /// copy constructor takes ownership. It is called from load()
00111     SDLDisplay(SDLSurface &src);
00112 
00113 private:
00114     //private constructor to prevent accidental use of singleton
00115     SDLDisplay(const SDLDisplay&);
00116     SDLDisplay& operator=(const SDLDisplay&);
00117 };
00118 
00119 }
00120 
00121 #endif // WT_SDLDISPLAY_H

Generated Fri Jul 28 19:23:00 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.