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

setupdisplay_generic.cpp

Go to the documentation of this file.
00001 
00002 #ifdef WIN32
00003 #pragma warning (disable:4786)
00004 #endif
00005 
00006 #include <stdlib.h>
00007 #include "Display/Display/Generic/restype_surface.h"
00008 #include "Display/Font/resourcetype_font.h"
00009 #include "Display/Font/resourcetype_ttf.h"
00010 #include "API/Display/SurfaceProviders/provider_pcx.h"
00011 #include "API/Display/SurfaceProviders/provider_bmp.h"
00012 #include "API/Display/SurfaceProviders/provider_targa.h"
00013 
00014 #include "setupdisplay_generic.h"
00015 
00017 // Resource support: (sorry for the messy code)
00018 
00019 static class CL_PCX_ResourceSource : public CL_ResourceSource_Surface
00020 {
00021 public:
00022         virtual const char *get_name() { return "pcx"; }
00023 
00024         virtual bool can_create(
00025                 std::string ext,
00026                 CL_ResourceOptions *options)
00027         {
00028                 if (ext == ".pcx") return true;
00029                 if (options->exists("pcx")) return true;
00030                 
00031                 return false;
00032         }
00033         
00034         virtual CL_SurfaceProvider *create(
00035                 std::string filename,
00036                 CL_ResourceOptions *options,
00037                 CL_ResourceManager *parent)
00038         {
00039                 CL_InputSourceProvider *provider=NULL;
00040                 if (parent) 
00041                         provider=parent->get_resource_provider();
00042                 return new CL_PCXProvider(filename.c_str(), provider);
00043         }
00044 } *pcx_resource_source = NULL;
00045 
00046 static class CL_BMP_ResourceSource : public CL_ResourceSource_Surface
00047 {
00048 public:
00049         virtual const char *get_name() { return "bmp"; }
00050 
00051         virtual bool can_create(
00052                 std::string ext,
00053                 CL_ResourceOptions *options)
00054         {
00055                 if (ext == ".bmp") return true;
00056                 if (options->exists("bmp")) return true;
00057                 
00058                 return false;
00059         }
00060         
00061         virtual CL_SurfaceProvider *create(
00062                 std::string filename,
00063                 CL_ResourceOptions *options,
00064                 CL_ResourceManager *parent)
00065         {
00066                 CL_InputSourceProvider *provider=NULL;
00067                 if (parent) 
00068                         provider=parent->get_resource_provider();
00069 
00070                 return new CL_BMPProvider(filename.c_str(), provider);
00071         }
00072 
00073 } *bmp_resource_source = NULL;
00074 
00075 static class CL_Targa_ResourceSource : public CL_ResourceSource_Surface
00076 {
00077 public:
00078         virtual const char *get_name() { return "tga"; }
00079 
00080         virtual bool can_create(
00081                 std::string ext,
00082                 CL_ResourceOptions *options)
00083         {
00084                 if (ext == ".tga") return true;
00085                 if (options->exists("tga")) return true;
00086 
00087                 return false;
00088         }
00089 
00090         virtual CL_SurfaceProvider *create(
00091                 std::string filename,
00092                 CL_ResourceOptions *options,
00093                 CL_ResourceManager *parent)
00094         {
00095                 CL_InputSourceProvider *provider=NULL;
00096                 if (parent) 
00097                         provider=parent->get_resource_provider();
00098 
00099                 return new CL_TargaProvider(filename.c_str(), provider);
00100         }
00101 
00102 } *targa_resource_source = NULL;
00103 
00105 // CL_SetupDisplay_Generic initialization:
00106 
00107 static CL_Res_Surface *restype_surface = NULL;
00108 static CL_Res_Font *restype_font = NULL;
00109 
00110 void CL_SetupDisplay_Generic::init()
00111 {
00112         restype_surface = new CL_Res_Surface;
00113         restype_font = new CL_Res_Font;
00114 
00115         pcx_resource_source = new CL_PCX_ResourceSource;
00116         bmp_resource_source = new CL_BMP_ResourceSource;
00117         targa_resource_source = new CL_Targa_ResourceSource;
00118 }
00119 
00121 // CL_SetupDisplay_Generic deinitialization:
00122 
00123 void CL_SetupDisplay_Generic::deinit()
00124 {
00125         delete pcx_resource_source;
00126         delete bmp_resource_source;
00127         delete targa_resource_source;
00128 
00129         pcx_resource_source = NULL;
00130         bmp_resource_source = NULL;
00131         targa_resource_source = NULL;
00132 
00133         delete restype_surface;
00134         delete restype_font;
00135 
00136         restype_surface = NULL;
00137         restype_font = NULL;
00138 }

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