Surface Refresh/Reload ====================== If one switches from fullscreen to windowed mode one loses the rendering context and thus all the surfaces under Win32, same things would happen when one would want to switch from SDL to OpenGL mode under Linux. ClanLib currently does not provide any means to solve this problem, so one is either forced to try to implemented that oneshelf, which is difficult or even impossible since its hard to get a notice when a surface got invalid or simply avoid mode switching alltogether, which forces the user to restart the game manually, which is ugly. To fix this situation I propose to associate with each CL_Surface a abstract CL_SurfaceLoader class, this class should have the knownledge to reload a CL_Surface when its data gets lost. In addition to that it could also be used as a load-on-demand feature in case one wants to have immediate startup of the application and only load surfaces when they are first drawn. CL_SurfaceLoader should be an abstract class and basically only provide a single function, namly 'load()': class CL_SurfaceLoader { /** Attach the loader to a CL_Surface */ CL_SurfaceLoader(CL_Surface surface); /** Let the loader load the data into the given surface */ void load(); }; Classes inherit from the CL_SurfaceLoader could than be the following: class CL_ResourceSurfaceLoader : public CL_SurfaceLoader { public: CL_ResourceSurfaceLoader(std::string name, CL_ResourceManager resource); void load(); }; class CL_FileSurfaceLoader : public CL_SurfaceLoader { public: CL_FileSurfaceLoader(std::string filename, int x = 0, int y = 0, int width = -1, int height = -1); void load(); }; class CL_PixelBufferSurfaceLoader : public CL_SurfaceLoader { public: CL_PixelBufferSurfaceLoader(CL_PixelBuffer buffer); void load(); }; Since providing this functionallity might give a small memory hit, especially when a lot of raw CL_PixelBuffers come into play, one should be able to switch it off. Questions ========= Should switch off for CL_SurfaceLoader be global or per surface? Should CL_SurfaceLoader load into a CL_Surface or a CL_PixelBuffer? Instead of using CL_SurfaceLoader all this could be implemnted via a signal mechanism such as CL_Surface::sig_lost() which gets called if a surface is lost. Would this be better or worse and why? Examples ======== SuperTux implements a similar functionallity with SDL and allows fullscreen/window switching and switching between software rendering and OpenGL rendering. # EOF #