Results 1 to 20 of 27

Thread: First impressions about ClanLib 3.0 (and a bunch of questions)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default First impressions about ClanLib 3.0 (and a bunch of questions)

    Hi all,
    Being about to start a large project, I decided to switch to ClanLib 3.0 (even though it is still beta.) Better to switch early than having to modify a long code later - not to mention that might help ClanLib developers to eliminate some bugs or whatever.
    First impressions about version 3.0 are mostly positive - although converting existing code from 2.3.7 to 3.0 is not an easy task, mainly because it seems many things are changed. Documentation is limited, so I had to experiment a lot, guessing why existing code that used to work in 2.3.7 doesn't work on 3.0 and what needs to be modified. For example, the new way of declaring font formats is better compared to the old cl_format, but I needed quite some time to figure out how clan::StringFormat works. The consequences of using a (mostly undocumented) beta version, I guess...

    Anyway, I got some questions that I can't figure out without further documentation (beware, more to come as I keep modifying my 2.3.7 codes to work in version 3.0 )

    (1) When I compile any ClanLib-based code, g++ is complaining, giving 8 warnings concerning ClanLib/core.h, specifically half_float.h:
    /usr/include/ClanLib-3.0/ClanLib/Core/Math/half_float.h: In static member function ‘static float clan::HalfFloat::half_to_float_simple(short unsigned int)’:
    /usr/include/ClanLib-3.0/ClanLib/Core/Math/half_float.h:85:48: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
    (and 7 more similar warnings.) Of course, I can get rid of the warnings if I add the Cflag -Wno-strict-aliasing after -Wall but I'm not sure it's safe to allow non-strict aliasing. Note that strict aliasing rule used to work in 2.3.7, and I get no warnings at all using g++ -Wall to compile 2.3.7 code.

    (2) I'm not sure why Canvas was introduced, and what's the difference comparing to a GraphicContext. Furthermore, I don't get why clan::Font::resource() requires a Canvas as its first argument, while the corresponding method for sprites, namely clan::Sprite::resource(), requires a GraphicContext as its first argument. What's more confusing is the fact clan::Font::resource() gives a compiler error if I provide a GraphicContext as its first argument, while clan::Sprite::resource() is still working with a Canvas object, although documentation mentions only GraphicContext is allowed. Note that Breaking Changes says "fonts, images and sprites now use the Canvas class".

    (3) I also have another problem concerning fonts. In ClanLib 2.3.7, you can load a font which is not installed in your system (very useful feature for distributing your work to others who don't have to install specific fonts in their system.) For example, I used to load fonts using a resource file, like that:
    CL_ResourceManager resources("resources.xml");
    CL_Font_Freetype message_font("message",&resources);
    where resources.xml is something like
      <sprite name="rectangle">
    		<image file="rectangle.png">
      <font name="message">
        <freetype file="DejaVuSans.ttf" height="30" average_width="0" anti_alias="true" subpixel="true"/>
    and the ttf font, in this example DejaVuSans, is in the same directory as resources.xml. This doesn't seem to work anymore; I am able to use fonts installed in my system, but nothing else. The new way to use font descriptions in resource files seems to be (correct me if I am wrong)
    const clan::ResourceManager &resources=clan::XMLResourceManager::create(clan::XMLResourceDocument("resources.xml"));
    clan::Font message_font;
    but it doesn't let you load specific fonts (the file attribute in resources.xml seems to be ignored; unfortunately, clan::FontDescription() only accepts a typeface name as its argument, so the font description named "message" in my resource.xml file is interpreted as a typeface name. I looked at all the examples shipped with ClanLib 3.0, but none of them uses xml resources to describe fonts (only sprite fonts, which is a different story), and none of them uses font loading. So it seems impossible to load fonts from ttf (or otf) files, and all you can do is to use fonts installed in the system.

    Note that the sprite description in the above xml file works as expected, but the font description is ignored as it is; furthermore, even if I change resource.xml so that it describes a font installed in my system, parser seems to ignore the height attribute, and I get a microscopic font of height 1. So I have to give up using font descriptions in resource files and describe fonts in the code itself (much less convenient), and that only for fonts installed in my system.

    It seems fonts in version 3.0 lack the (very useful) feature of font loading, or, most probably, I am missing something important here.
    Sorry for wasting your time, but I have no clue what am I doing wrong here, after looking up in the doxygen documentation, and all examples in the ClanLib 3.0 folder. Needless to say any help concerning the above questions is much appreciated

    Note: using g++ version: 4.7.3 (Debian 4.7.3-4) on a Debian 8 64-bit system (no 32-bit libraries installed at all.)
    Last edited by Pap; 09-13-2013 at 06:28 PM.
    Using ClanLib 3.0.0, compiled from source on Debian 8.0 ("jessie") GNU/Linux (64-bit)

Similar Threads

  1. ClanLib 2.3.4 questions
    By Veitikka in forum Official ClanLib SDK Forums
    Replies: 10
    Last Post: 03-14-2012, 02:11 PM
  2. 2 questions when start using Clanlib GUI moudule
    By westpointer in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 05-26-2010, 12:44 PM
  3. First Impressions...
    By Fr3DBr in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 08-26-2009, 02:46 AM
  4. ClanLib 0.9 GUI Questions
    By rombust in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 02-10-2009, 01:17 PM
  5. First impressions...
    By whisperstorm in forum Novashell Game Creation System
    Replies: 1
    Last Post: 11-22-2006, 11:21 PM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts