00001 /* 00002 $Id: surfaceprovider.cpp,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 #include "Core/precomp.h" 00016 #include <API/Core/Resources/resource_manager.h> 00017 #include <API/Display/Display/surfaceprovider.h> 00018 #include <Display/Display/Generic/restype_surface.h> 00019 00020 CL_SurfaceProvider *CL_SurfaceProvider::load( 00021 const char *resource_id, 00022 CL_ResourceManager *manager) 00023 { 00024 CL_WritableSurfaceResource *resource = 00025 (CL_WritableSurfaceResource *) manager->get_resource(resource_id); 00026 00027 resource->load(); 00028 00029 return resource->create_provider(); 00030 } 00031 /* 00032 bool CL_SurfaceProvider::pixel_transparent(int x, int y) const 00033 { 00034 int transcol = get_transcol(); 00035 if (transcol == -1) return false; 00036 00037 cl_assert(x>=0 && y>=0 && (unsigned int) x<get_width() && (unsigned int) y<get_height()); 00038 00039 int bytes_pr_pixel = get_bytes_pr_pixel(); 00040 unsigned char *surface_data = (unsigned char *) get_data(); 00041 00042 unsigned char *pos = &surface_data[x*bytes_pr_pixel+y*get_pitch()]; 00043 00044 switch (bytes_pr_pixel) 00045 { 00046 case 1: 00047 return *pos == transcol; 00048 case 2: 00049 return *((unsigned short *) pos) == transcol; 00050 case 3: 00051 { 00052 // This may not work at all (can't test it!) 00053 unsigned long val = *((unsigned long *) pos); 00054 val &= 0xffffff00; 00055 return val == (unsigned long) transcol; 00056 } 00057 case 4: 00058 return *((unsigned long *) pos) == (unsigned long) transcol; 00059 default: 00060 cl_assert(false); // Nutty business! 00061 return false; 00062 } 00063 } 00064 */
1.2.6 written by Dimitri van Heesch,
© 1997-2001