This document describes how to port your game from an old ClanLib version to a new one. Upgrading from 0.7.8 to 0.8.0 ============================= 1. CL_InputEvent changes ------------------------ CL_InputEvent::right/left_alt/shift/ctrl got removed, use this to check if they are pressed instead: CL_Keyboard::get_keycode(CL_KEY_LSHIFT) // (CL_KEY_LCONTROL, CL_KEY_RCONTROL, etc) 2. CL_Surface changes --------------------- The CL_Surface_DrawParams got turned into references (they were pointers before): void draw( const CL_Surface_DrawParams1& params1, CL_GraphicContext *context = 0); void draw( const CL_Surface_DrawParams2& params2, CL_GraphicContext *context = 0); 3. CL_PixelBuffer changes ------------------------- CL_PixelBuffer is a ref_counted class, thus its no longer needed to manully keep track of the ownership, so all calls which took CL_PixelBuffer* have been changed to use CL_PixelBuffer instead: CL_Surface(CL_PixelBuffer*, bool delete_provider); was changed to CL_Surface(CL_PixelBuffer); 4. sig_key_dblclk() is gone --------------------------- If you need it, you have to emulate it now yourself via sig_key_down() and CL_System::get_time(). 5. CL_InputDevice::keyid_to_string(const std::string &str) --------------------------------------------------------------------- We renamed a function here to more sense what it actually does: int CL_InputDevice::keyid_to_string(const std::string &str) const; is now called int CL_InputDevice::string_to_keyid(const std::string &str) const; 6. ClanGUI clipping and translation changes ------------------ For performance reasons, GUI components do no longer automatically add translation and clipping to the drawing area. If you have a CL_Component and use sig_paint(), you can get the absolute screen coordinates by calling: CL_Rectf rect = component->get_screen_rect(); If you want to have a clipping section around your component use: component->set_clipping(true); 7. ClanGUI CL_Window buttons ---------------------------- If you want to hook into the close buttons of windows, use CL_Window::sig_close_button_clicked() instead of sig_close(). Also have a look at the GUIWindow example to see how you define which buttons go on the titlebar. Upgrading from 0.7.7 to 0.7.8 ============================= 1. Canvas changes ----------------- Instead of using surface.get_gc() to get a surface canvas, you now create a CL_Canvas object. Example: CL_Surface surface_foo("foo.png"); CL_Surface surface_bar("bar.png"); CL_Canvas canvas(surface_foo); surface_bar.draw(5, 5, canvas.get_gc()); Check the new Canvas example, and the API reference for more information. 2. Surface changes ------------------ The Hint parameter to surface construction was removed. 3. Module initializations ------------------------- To initialize ClanLib modules, you call CL_SetupCore::init(), CL_SetupDisplay::init(), etc for each module. ::deinit() to de-initialize them. This can cause problems, since in some cases objects on the stack are deleted after the deinit of ClanLib modules. So, we have added some new initialization classes to help remedy this problem. CL_SetupCore::init(); -> CL_SetupCore setup_core; CL_SetupDisplay::init(); -> CL_SetupDisplay setup_display; CL_SetupNetwork::init(); -> CL_SetupNetwork setup_network; etc, for all modules. There is no deinit in this new case. If you have problems with crashes on shutdown, try to use this alternative initialization. 4. TargaProvider changes ------------------------ The internal format of images provided by the Targa loader changed. Make sure you don't make any assumptions of the formats returned by the image providers. Check the format using get_format(), and its functions get_red/green/blue/alpha_mask(). Upgrading from 0.7.6 to 0.7.7 ============================= 1. OpenGL state changes ----------------------- Instead of begin_3d() / end_3d(), we now have a new method of synchronizing the OpenGL state between ClanLib and your own custom OpenGL code. Please read the new OpenGL Overview on how to use this new class. 2. CL_Component signal changes ------------------------------ sig_get_minimum_size / sig_get_maximum_size / sig_get_preferred_size These signals in CL_Component changed from CL_Point to CL_Size, so if you have a custom theme make sure you change the signal function to void ...::on_get_preferred_size(CL_Size &size) Note that CL_Size has width and height, compared to CL_Points x and y. 3. CL_Window construction changes --------------------------------- Previously, a CL_Window would always make itself a root component in the GUI hierarchy, no matter what parent component you specificed in its constructor. We've changed this behaviour to make it use the parent you give in its constructor. This way a CL_Window behaves the same as all other components, and also makes it possible to create MDI apps. To make sure your windows are root components, use get_gui_manager() as the parent. In most cases this is probably what you already do, or the parent IS the root component, so any changes will normally not be required. Upgrading from 0.7.5 to 0.7.6 ============================= No changes needed. Upgrading from 0.7.4 to 0.7.5 ============================= 1. ClanGUI changes ------------------ 1a. XML used for GUI To complete our transition away from proprietary formats, we have now moved the last part over to XML - the GUI definition files. GUI definition example of the old format: window my_window { x = 10; y = 10; width = 600; height = 400; title = "My Window"; button my_button { text = "My Button"; x = 25; y = 130; width = 100; height = 20; } } The same defintion in the new format: