00001 // /////////////////////////////////////////////////////////////////////////// 00002 // xrb_pal.hpp by Victor Dods, created 2009/08/15 00003 // /////////////////////////////////////////////////////////////////////////// 00004 // Unless a different license was explicitly granted in writing by the 00005 // copyright holder (Victor Dods), this software is freely distributable under 00006 // the terms of the GNU General Public License, version 2. Any works deriving 00007 // from this work must also be released under the GNU GPL. See the included 00008 // file LICENSE for details. 00009 // /////////////////////////////////////////////////////////////////////////// 00010 00011 #if !defined(_XRB_PAL_HPP_) 00012 #define _XRB_PAL_HPP_ 00013 00014 #include "xrb.hpp" 00015 00016 #include "xrb_screencoord.hpp" 00017 00018 namespace Xrb 00019 { 00020 00021 class Event; 00022 class Font; 00023 class Screen; 00024 class Texture; 00025 00026 // Platform Abstraction Layer interface. at most one instance of this 00027 // interface will ever exist at one time (it is used as a singleton). 00028 class Pal 00029 { 00030 public: 00031 00032 enum Status { SUCCESS = 0, FAILURE = 1 }; 00033 00034 virtual ~Pal () { } 00035 00036 // for pre-video-mode setup (e.g. starting the millisecond timer). 00037 virtual Status Initialize () = 0; 00038 // for post-video-mode shutdown. 00039 virtual void Shutdown () = 0; 00040 00041 virtual Status InitializeVideo (Uint16 width, Uint16 height, Uint8 bit_depth, bool fullscreen) = 0; 00042 virtual void ShutdownVideo () = 0; 00043 00044 virtual void SetWindowCaption (char const *window_caption) = 0; 00045 // TODO: grab/release method and show/hide cursor method 00046 00047 // returns the number of milliseconds since the Pal instance was 00048 // initialized. due to the size of a 32-bit int, this value will 00049 // wrap about every 49 days 00050 virtual Uint32 CurrentTime () = 0; 00051 00052 // block the the process for at least the specified number of 00053 // milliseconds, but possibly longer due to OS process scheduling. 00054 virtual void Sleep (Uint32 milliseconds_to_sleep) = 0; 00055 00056 // called once, immediately after the game loop is done rendering 00057 // (could be used for video buffer swapping for example). 00058 virtual void FinishFrame () = 0; 00059 00060 // return the next queued (input) event. should return NULL if no 00061 // events are available, otherwise should new-up and return the 00062 // appropriate Xrb::Event (it will be deleted by XRB). 00063 virtual Event *PollEvent (Screen const *screen, Float time) = 0; 00064 00065 // should return NULL if the load failed 00066 virtual Texture *LoadImage (char const *image_path) = 0; 00067 // return value should indicate status 00068 virtual Status SaveImage (char const *image_path, Texture const &texture) = 0; 00069 00070 // should return NULL if the load failed 00071 virtual Font *LoadFont (char const *font_path, ScreenCoord pixel_height) = 0; 00072 }; // end of class Pal 00073 00074 } // end of namespace Xrb 00075 00076 #endif // !defined(_XRB_PAL_HPP_) 00077