Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

displaycard_ptc.h

Go to the documentation of this file.
00001 /*
00002         $Id: displaycard_ptc.h,v 1.1 2001/03/06 15:09:17 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 
00015 #ifdef USE_PTC
00016 
00017 #ifndef header_displaycard_ptc
00018 #define header_displaycard_ptc
00019 
00020 #include "Display/Display/Generic/displaycard_generic.h"
00021 
00022 #ifndef WIN32
00023 #include "Display/Display/X11/display_xwindow.h"
00024 #else
00025 #include <ptc/ptc.h>
00026 #endif
00027 
00028 #include "API/Core/Display/display.h"
00029 #include "API/Core/Display/palette.h"
00030 #include "API/Core/Display/target.h"
00031 
00032 #include "API/Core/System/cl_assert.h"
00033 
00034 class CL_Target_PTC;
00035 
00036 class CL_DisplayCard_PTC
00037 #ifndef WIN32
00038 : public CL_XWindow_CompatibleCard
00039 #else
00040 : public CL_DisplayCard_Generic
00041 #endif
00042 {
00043 public:
00044         CL_DisplayCard_PTC(int card_no);
00045         virtual ~CL_DisplayCard_PTC();
00046         
00047 #ifndef WIN32   
00048         // CL_XWindow_CompatibleCard:
00049         // --------------------------
00050         
00051         virtual Window get_window() { return m_console.getX11Window(); }
00052         virtual Display *get_display() { return m_console.getX11Display(); }
00053         virtual Window get_root() { return 0; /*m_console.getX11Root();*/ }
00054 #else
00055         virtual HWND get_window() {return m_console.window(); }
00056 #endif
00057 
00058         // CL_DisplayCard functions:
00059         // -------------------------
00060 
00061         virtual void flip_display(bool sync=false);
00062         virtual void put_display(const class CL_Rect &pos);
00063         virtual void set_palette(CL_Palette *palette);
00064         virtual CL_Palette *get_palette();
00065         virtual void set_videomode(int width, int height, int bpp, bool fullscreen, bool allow_resize, bool video_memory);
00066         virtual bool is_initialized();
00067         
00068         virtual std::string get_name() { return "OpenPTC Display"; }
00069         virtual int get_total_memory() { return -1; }
00070         virtual const std::list<CL_VidMode*> &get_videomodes();
00071 
00072         // CL_DisplayCard_Generic functions:
00073         // ---------------------------------
00074         virtual CL_Target *get_target();
00075         virtual CL_Target *get_frontbuffer();
00076 
00077 private:
00078         CL_Palette m_palette;
00079         bool m_initialized;
00080         
00081         Console m_console;
00082         CL_Target_PTC *m_target;
00083 };
00084 
00085 class CL_Target_PTC : public CL_Target
00086 {
00087 public:
00088         CL_Target_PTC(Console *console, CL_Palette *pal)
00089         {
00090                 m_console = console;
00091                 m_pal = pal;
00092                 m_lock_ref = 0;
00093         }
00094 
00095         virtual void lock()
00096         {
00097                 m_lock_ref++;
00098                 if (m_lock_ref > 1) return;
00099                 
00100                 m_lock_ptr = m_console->lock();
00101         }
00102 
00103         virtual void unlock()
00104         {
00105                 m_lock_ref--;
00106                 cl_assert(m_lock_ref >= 0);
00107 
00108                 if (m_lock_ref == 0) m_console->unlock();
00109         }
00110 
00111         virtual void *get_data() const
00112         {
00113                 return m_lock_ptr;
00114         }
00115 
00116         virtual unsigned int get_width() const { return m_console->width(); }
00117         virtual unsigned int get_height() const { return m_console->height(); }
00118         virtual unsigned int get_pitch() const { return m_console->pitch(); }
00119 
00120         virtual unsigned int get_depth() const
00121         {
00122                 Format format = m_console->format();
00123                 return format.bits();
00124         }
00125         
00126         virtual unsigned int get_red_mask() const
00127         {
00128                 Format format = m_console->format();
00129                 return format.r();
00130         }
00131 
00132         virtual unsigned int get_green_mask() const
00133         {
00134                 Format format = m_console->format();
00135                 return format.g();
00136         }
00137 
00138         virtual unsigned int get_blue_mask() const
00139         {
00140                 Format format = m_console->format();
00141                 return format.b();
00142         }
00143 
00144         virtual unsigned int get_alpha_mask() const
00145         {
00146                 Format format = m_console->format();
00147                 return format.a();
00148         }
00149 
00150         virtual CL_Palette *get_palette() const
00151         {
00152                 return m_pal;
00153         }
00154 
00155         virtual unsigned int get_num_frames() const { return 1; }
00156         virtual bool is_indexed() const { return false; }
00157 
00158 private:
00159         CL_Palette *m_pal;
00160         Console *m_console;
00161         int m_lock_ref;
00162         void *m_lock_ptr;
00163 };
00164 
00165 #ifdef WIN32
00166 
00167 class CL_Display_PTC : public CL_Display
00168 {
00169 public:
00170         CL_Display_PTC(int options);
00171         virtual ~CL_Display_PTC();
00172 
00173         static CL_DisplayCard_PTC *cur_card;
00174 };
00175 
00176 #endif
00177 
00178 #endif
00179 
00180 #endif

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001