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

provider_dynamic.h

Go to the documentation of this file.
00001 /*
00002         $Id: provider_dynamic.h,v 1.1 2001/03/06 15:09:12 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         File purpose:
00015                 Empty space dynamic surface provider header file
00016 
00017 */
00018 
00020 
00021 #ifndef header_dynamic_provider
00022 #define header_dynamic_provider
00023 
00024 #include "generic_surfaceprovider.h"
00025 
00026 class CL_DynamicProvider : public CL_SurfaceProvider_Generic
00027 {
00028 public:
00029 
00030         static CL_Surface *create(int width, int height, int no_sprs, EPixelFormat type = PAL8, int transcol = -1)
00031         {
00032                 return CL_Surface::create(new CL_DynamicProvider(width, height, no_sprs, type, transcol), true);
00033         }
00034 
00035         static CL_Surface *create(int width, int height, int no_sprs, int red_mask, int green_mask, int blue_mask, 
00036                                   int alpha_mask, int transcol = -1)
00037         {
00038                 return CL_Surface::create(new CL_DynamicProvider(width, height, no_sprs, red_mask, green_mask, 
00039                                           blue_mask, alpha_mask, transcol), true);
00040         }
00041 
00042         CL_DynamicProvider(int width, int height, int no_sprs, EPixelFormat type = PAL8, int trans_col = -1)
00043         {
00044                 this->width = width;
00045                 this->height = height;
00046                 this->no_sprs = no_sprs;
00047                 this->trans_col = trans_col;
00048                 data = NULL;
00049                 pixelformat = type;
00050                 bpp = get_bytes_pr_pixel();
00051                 data = new unsigned char[width * height * no_sprs * bpp]; 
00052 //              bzero(data, width * height * no_sprs * bpp);
00053         }  
00054 
00055         // has to be blitted by the dynamic blitter at the moment
00056         CL_DynamicProvider(int width, int height, int no_sprs, int red_mask, int green_mask, int blue_mask, 
00057                            int alpha_mask, int transcol = -1)
00058         {
00059                 this->width = width;
00060                 this->height = height;
00061                 this->no_sprs = no_sprs;
00062                 this->trans_col = trans_col;
00063                 this->red_mask = red_mask;
00064                 this->green_mask = green_mask;
00065                 this->blue_mask = blue_mask;
00066                 this->alpha_mask = alpha_mask;
00067                 
00068                 data = NULL;
00069                 pixelformat = CUSTOM;
00070                 bpp = get_bytes_pr_pixel();
00071 
00072                 data = new unsigned char[width * height * no_sprs * bpp]; 
00073 //              bzero(data, width * height * no_sprs * bpp);
00074         }  
00075 
00076 
00077         virtual ~CL_DynamicProvider() { delete[] data; }
00078         //: Deletes the DynamicProvider and deletes the data
00079         //: which was allocated in the constructor
00080 
00081         virtual int get_width() const { return width; }
00082         virtual int get_height() const { return height; }
00083         virtual int get_no_sprs() const { return no_sprs; }
00084         virtual EPixelFormat get_pixel_format() const { return pixelformat; }
00085         //: Returns the pixelformat of the DynamicProvider as it was set in the constructor
00086 
00087         virtual CL_Palette *get_palette() const { return NULL; }
00088         //: Returns NULL, because PAL8 isn't supported
00089 
00090         virtual int get_transcol() const { return trans_col; }
00091         //: Returns the transparent color, which was set in the constructor
00092 
00093         virtual void *get_data() const { cl_assert(data!=NULL); return data; }
00094         //: Returns the pointer to the surface data, where you
00095         //: can copy your data to. It should be
00096         //: only called between lock() and unlock(). 
00097 
00098         virtual void perform_lock() { }
00099         virtual void perform_unlock() { }
00100 
00101 private:
00102 
00103         int width, height, no_sprs, trans_col;
00104         int red_mask, green_mask, blue_mask, alpha_mask;
00105         EPixelFormat pixelformat;
00106         unsigned char *data;
00107         int bpp;
00108 };
00109 
00110 #endif

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