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

restype_surface.h

Go to the documentation of this file.
00001 /*
00002         $Id: restype_surface.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 #ifndef header_restype_surface
00016 #define header_restype_surface
00017 
00018 #include "API/Display/Display/surface.h"
00019 #include "API/Core/Resources/resource_manager.h"
00020 #include "API/Display/SurfaceProviders/generic_surfaceprovider.h"
00021 #include "API/Display/Display/res_surface.h"
00022 
00023 class CL_Res_Surface : public CL_ResourceType
00024 //: The surface resource type.
00025 // This class is used to load surface resources from a resource source
00026 // (datafile or script file).
00027 // <br>
00028 // Use the CL_ResourceManager to get an instance to the resource source, and
00029 // then call one of the static functions here to load the resource:
00030 // <code>
00031 // CL_ResourceManager res_manager("my_datafile.dat", true);
00032 // CL_Surface *my_surface = CL_Res_Surface::load("my_surface", res_manager);
00033 // </code>
00052 {
00053 public:
00054         CL_Res_Surface();
00055 
00056         static std::list<CL_ResourceSource_Surface*> surface_sources;
00057 
00058 private:
00059 friend CL_ResourceManager;
00060         virtual CL_Resource *create_from_location(
00061                 std::string name,
00062                 std::string location,
00063                 CL_ResourceOptions *options,
00064                 CL_ResourceManager *parent);
00065 
00066         virtual CL_Resource *create_from_serialization(
00067                 std::string name,
00068                 CL_ResourceManager *parent);
00069 };
00070 
00071 class CL_WritableSurfaceResource : public CL_Resource
00072 {
00073 protected:
00074         CL_Surface *loaded_surface;
00075         bool loaded;
00076         std::string surface_location;
00077         CL_ResourceOptions *options;
00078         CL_ResourceManager *parent;
00079         int load_count;
00080 public:
00081         CL_WritableSurfaceResource(std::string name);
00082         virtual ~CL_WritableSurfaceResource() { ; }
00083 
00084         virtual void serialize_save(CL_OutputSource *output);
00085         virtual void load();
00086         virtual void unload();
00087         virtual int get_load_count() { return load_count; }
00088 
00089         virtual CL_SurfaceProvider *create_provider()=0;
00090         virtual CL_Surface *create_surface();
00091 };
00092 
00093 class CL_SurfaceFileResource : public CL_WritableSurfaceResource
00094 {
00095 public:
00096         CL_SurfaceFileResource(
00097                 std::string name,
00098                 std::string location,
00099                 CL_ResourceOptions *options,
00100                 CL_ResourceManager *parent);
00101         virtual ~CL_SurfaceFileResource();
00102 
00103         virtual CL_SurfaceProvider *create_provider();
00104 };
00105 
00106 class CL_SurfaceDatafileResource : public CL_WritableSurfaceResource
00107 {
00108 public:
00109         CL_SurfaceDatafileResource(
00110                 std::string name,
00111                 CL_ResourceManager *parent);
00112         virtual ~CL_SurfaceDatafileResource();
00113 
00114         virtual CL_SurfaceProvider *create_provider();
00115 };
00116 
00117 class CL_MaskTranscolProvider : public CL_SurfaceProvider_Generic
00118 {
00119         CL_SurfaceProvider *parent;
00120         bool delete_provider;
00121         unsigned int *mask_indices;
00122         int num_mask_indices;
00123 public:
00124         CL_MaskTranscolProvider(
00125                         CL_SurfaceProvider *parent, 
00126                         bool delete_provider, 
00127                         const unsigned int *mask_indices,
00128                         int num_mask_indices);
00129         virtual ~CL_MaskTranscolProvider();
00130 
00131         virtual unsigned int get_pitch() const;
00132         virtual int get_translate_x() const;
00133         virtual int get_translate_y() const;
00134         virtual unsigned int get_width() const;
00135         virtual unsigned int get_height() const;
00136         virtual unsigned int get_num_frames() const;
00137         virtual unsigned int get_red_mask() const;
00138         virtual unsigned int get_green_mask() const;
00139         virtual unsigned int get_blue_mask() const;
00140         virtual unsigned int get_alpha_mask() const;
00141         virtual unsigned int get_depth() const;
00142         virtual bool is_indexed() const;
00143 
00144         virtual CL_Palette *get_palette() const;
00145         virtual unsigned int get_src_colorkey() const;
00146         virtual bool uses_src_colorkey() const;
00147         
00148         virtual void *get_data() const;
00149 
00150         virtual void perform_lock();
00151         virtual void perform_unlock();
00152 };
00153 
00154 #endif

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