Page 1 of 1
compiler error defineImage no match (upgrading to 0.5.0)
Posted: Mon Jan 22, 2007 10:10
by mba
Hi
I'm trying to upgrade from 0.4.1 to 0.5.0 on my linux box, but I seem to be getting some compiler errors. First I had some difficulties finding out which dependencies I needed for the 0.5.0, this information isn't anywhere in the wiki or the forums?
Then I just downloaded the source from svn, and read the README which states that the only dependencies needed is freetype2 and PCRE, both of which I have installed on my system, along with all the dependencies for the 0.4.1 version, including devil.
The error I'm seeing is:
Code: Select all
g++ -DHAVE_CONFIG_H -I. -I. -I../include -I../include -I.. -I/usr/local/include/freetype2 -I/usr/local/include -g -O2 -MT CEGUIFreeTypeFont.lo -MD -MP -MF .deps/CEGUIFreeTypeFont.Tpo -c CEGUIFreeTypeFont.cpp -fPIC -DPIC -o CEGUIFreeTypeFont.lo
CEGUIFreeTypeFont.cpp: In member function `virtual void
CEGUI::FreeTypeFont::rasterize(unsigned int, unsigned int)':
CEGUIFreeTypeFont.cpp:281: error: parse error before `+' token
CEGUIFreeTypeFont.cpp:288: error: no matching function for call to `
CEGUI::Imageset::defineImage(CEGUI::String&, CEGUI::Rect (&)(...),
CEGUI::Point&)'
../include/CEGUIImageset.h:341: error: candidates are: void
CEGUI::Imageset::defineImage(const CEGUI::String&, const CEGUI::Point&,
const CEGUI::Size&, const CEGUI::Point&)
../include/CEGUIImageset.h:364: error: void
CEGUI::Imageset::defineImage(const CEGUI::String&, const CEGUI::Rect&, const
CEGUI::Point&)
Does anybody have a clue what is going on here?
Kind regards
Martin
Posted: Mon Jan 22, 2007 21:00
by scriptkid
Hi there,
i have not checked myself, but i think it's odd that it sais 'CEGUI::Rect (&)(...)' for the area parameter and the expected 'const&' typed for the String and the Point.
So it tries to map the 'CEGUI::Rect (&)(...)' onto a 'const Rect&'... I don't even know what that first construction means.
Maybe someone else has a guess?
Posted: Mon Jan 29, 2007 10:16
by mba
Hi again
thanks for replying scriptkid!
I have also no clue what the CEGUI::Rect (&)(...) construct means.
After trying a couple of things, I remembered that I tried 0.5.0 when it was a release candidate, so I downloaded the tar sourceball RC1 for linux, and voila! it builds just fine.
Kind regards
Martin
Posted: Mon Jan 29, 2007 12:38
by scriptkid
Glad to hear you got it to work!
You mean you are now using RC1? Because there is a 'real' release already:
http://prdownloads.sourceforge.net/cray ... z?download
But use the one which suits you best of course
Posted: Tue Jan 30, 2007 07:37
by mba
hi again
this doesn't actually count as working
, the problems I'm having is with the NEW release of cegui 0.5.0b... but as a test I tried the RC1, because I remembered that it had worked earlier, and it still does.
This could maybe give a hint of what is wrong, but I'm still at a loss here.
regards
Martin
Posted: Mon Feb 05, 2007 09:58
by mba
I have localized the problem and it has to do with this line where the area variable isn't properly constructed.
CEGUIFreeTypeFont.cpp line 281:
Code: Select all
Rect area(float(x), float(y),
float(x + glyph_w - INTER_GLYPH_PAD_SPACE),
float(y + glyph_h - INTER_GLYPH_PAD_SPACE));
whereas the version from release candidate 2
Code: Select all
Rect area(x, y,
x + glyph_w - INTER_GLYPH_PAD_SPACE,
y + glyph_h - INTER_GLYPH_PAD_SPACE);
works flawlessly.
The problem, I think, is the functional-style typecast of the float variables, this triggers a bug in my gcc/g++ 3.3.5 compiler (I'm guessing here, because I found a forum post where someone suggested that you upgrade from 3.2 to 3.4 because this bug was removed). If I change the typecast from
Code: Select all
float(x + glyph_w - INTER_GLYPH_PAD_SPACE)
to
Code: Select all
static_cast<float>(x + glyph_w - INTER_GLYPH_PAD_SPACE)
it works perfectly.
Kind regards
Martin
Posted: Mon Feb 05, 2007 20:29
by scriptkid
Hey,
good that you found it. I'll see if we can get patch this. Thanks for sharing the details!
Posted: Thu Feb 08, 2007 12:00
by mba
Hi scriptkid
I don't actually think its a problem in cegui, I'm guessing at a bug in the gcc 3.3.5 compiler. But either way, why is there used so many different ways of typecasting throughout the cegui project, I think all variations is represented
(float), float(), static_cast<float>....
Kind regards
Martin Bang Andersen
Posted: Fri Feb 09, 2007 14:48
by scriptkid
I know it's not a cegui problem, but when changing the cast helps avoiding compiler errors, we might help in this area
Not sure about all the different casts. The project is already a few years old and has different contributors. But you have a point: we might need to choose one way of doing this.
Posted: Tue May 27, 2008 13:34
by alphasnd
I just encountered this problem when compiling on OS X (and using gcc3.x), thanks to mba for the solution. Here is the patch if you want to apply it on over the 0.6.x branch:
Index: CEGUIFreeTypeFont.cpp
===================================================================
--- CEGUIFreeTypeFont.cpp (revision 1710)
+++ CEGUIFreeTypeFont.cpp (working copy)
@@ -279,8 +279,8 @@
drawGlyphToBuffer (mem_buffer + (y * texsize) + x, texsize);
// Create a new image in the imageset
- Rect area (float(x), float(y), float(x + glyph_w - INTER_GLYPH_PAD_SPACE),
- float(y + glyph_h - INTER_GLYPH_PAD_SPACE));
+ Rect area (static_cast<float>(x), static_cast<float>(y), static_cast<float>(x + glyph_w - INTER_GLYPH_PAD_SPACE),
+ static_cast<float>(y + glyph_h - INTER_GLYPH_PAD_SPACE));
Point offset (d_fontFace->glyph->metrics.horiBearingX * float(FT_POS_COEF),
-d_fontFace->glyph->metrics.horiBearingY * float(FT_POS_COEF));
With this, it compiles on OS X without any hickups.
Posted: Tue May 27, 2008 15:26
by CrazyEddie
Hi, and welcome
I have applied this fix (slightly extended to include the Point definition immediately below the Rect) in branches/v0-6 at rev. 1729. Thanks very much
For reference, the actual patch applied was:
Code: Select all
Index: src/CEGUIFreeTypeFont.cpp
===================================================================
--- src/CEGUIFreeTypeFont.cpp (revision 1724)
+++ src/CEGUIFreeTypeFont.cpp (working copy)
@@ -279,11 +279,14 @@
drawGlyphToBuffer (mem_buffer + (y * texsize) + x, texsize);
// Create a new image in the imageset
- Rect area (float(x), float(y), float(x + glyph_w - INTER_GLYPH_PAD_SPACE),
- float(y + glyph_h - INTER_GLYPH_PAD_SPACE));
- Point offset (d_fontFace->glyph->metrics.horiBearingX * float(FT_POS_COEF),
- -d_fontFace->glyph->metrics.horiBearingY * float(FT_POS_COEF));
+ Rect area(static_cast<float>(x),
+ static_cast<float>(y),
+ static_cast<float>(x + glyph_w - INTER_GLYPH_PAD_SPACE),
+ static_cast<float>(y + glyph_h - INTER_GLYPH_PAD_SPACE));
+ Point offset(d_fontFace->glyph->metrics.horiBearingX * static_cast<float>(FT_POS_COEF),
+ -d_fontFace->glyph->metrics.horiBearingY * static_cast<float>(FT_POS_COEF));
+
String name;
name += s->first;
is->defineImage (name, area, offset);
CE.
Posted: Wed May 28, 2008 09:34
by alphasnd
Thanks for the quick fix, happy to be onboard