Layout XML misaligned when loaded vs CEGUI Layout Editor

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

lymantok
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 13, 2007 03:24

Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby lymantok » Sat Jul 25, 2009 03:17

Hi,

When loading an Aqualook layout file in cegui layout editor it looks fine: http://www.flickr.com/photos/22251599@N04/3753322813/
When loading the same Aqualook layout file via the following code, the body is misaligned by 1 pixel: http://www.flickr.com/photos/22251599@N04/3753322859/

// Load the GUI main menu window
sprintf(resourcePath, "%s/%s/%s", dataPathPrefix, "layouts/", "fitg_main_menu.layout");
m_pWmgr->loadWindowLayout(resourcePath);

What am I doing wrong? How can I fix the misaligned body when it's loaded via code vs the cegui layout editor?

Thx!

PS. The Aqualook skin is in the skin's library. Here is the xml for the layout I am using...

<?xml version="1.0" encoding="UTF-8"?>

<GUILayout >
<Window Type="DefaultWindow" Name="MainMenu" >
<Property Name="InheritsAlpha" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{0,640},{0,480}}" />
<Window Type="AquaLook/FrameWindow" Name="Root/Frame" >
<Property Name="Font" Value="BlueHighway-10" />
<Property Name="Text" Value="Freedom In The Galaxy - Main Menu" />
<Property Name="TitlebarFont" Value="BlueHighway-10" />
<Property Name="RollUpEnabled" Value="False" />
<Property Name="SizingEnabled" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="TitlebarEnabled" Value="True" />
<Property Name="UnifiedAreaRect" Value="{{0,268},{0,31},{0,542},{0,220}}" />
<Window Type="AquaLook/StaticText" Name="Root/Frame/StaticText" >
<Property Name="Font" Value="BlueHighway-10" />
<Property Name="Text" Value="Main Menu" />
<Property Name="TextColours" Value="tl:FF000000 tr:FF000000 bl:FF000000 br:FF000000" />
<Property Name="FrameEnabled" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0,114},{0,43},{0,206},{0,67}}" />
<Property Name="BackgroundEnabled" Value="False" />
</Window>
<Window Type="AquaLook/Button" Name="Root/Frame/ButtonSave" >
<Property Name="Font" Value="BlueHighway-10" />
<Property Name="Text" Value="Save" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.172851,0},{0.554199,0},{0.422851,0},{0.688423,0}}" />
</Window>
<Window Type="AquaLook/Button" Name="Root/Frame/ButtonLoad" >
<Property Name="Font" Value="BlueHighway-10" />
<Property Name="Text" Value="Load" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.172851,0},{0.693258,0},{0.422851,0},{0.827482,0}}" />
</Window>
<Window Type="AquaLook/Button" Name="Root/Frame/ButtonSettings" >
<Property Name="Font" Value="BlueHighway-10" />
<Property Name="Text" Value="Settings" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.545117,0},{0.418956,0},{0.795117,0},{0.553181,0}}" />
</Window>
<Window Type="AquaLook/Button" Name="Root/Frame/ButtonExit" >
<Property Name="Font" Value="BlueHighway-10" />
<Property Name="Text" Value="Exit" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.545117,0},{0.558015,0},{0.795117,0},{0.692239,0}}" />
</Window>
<Window Type="AquaLook/Button" Name="Root/Frame/ButtonNew" >
<Property Name="Font" Value="BlueHighway-10" />
<Property Name="Text" Value="New" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.172851,0},{0.419847,0},{0.422851,0},{0.554071,0}}" />
</Window>
</Window>
</Window>
</GUILayout>

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby CrazyEddie » Sat Jul 25, 2009 08:34

Based on the info given I don't think you're particularly doing anything wrong, as such. I'll run a test on the actual skin later, but for now this seems quite odd (yeah, stating the obvious!). Can you tell us whether your app is using the OpenGL renderer module (the same as the layout editor) or one of the others? And also, what is the size of the viewport (i.e. the client area) in your app?

[Edit]
I see from your other thread you're using the Irrlicht renderer, so no need to post that now :)

CE.

lymantok
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 13, 2007 03:24

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby lymantok » Sat Jul 25, 2009 23:55

Hi CE,

Yes, Irrlicht renderer on Windows XP.

The viewport is 1024 x 768.

Thx for taking a look!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby CrazyEddie » Sun Jul 26, 2009 09:29

Ok, I've run some initial tests, but did not reproduce the issue. This being said, my system does not match yours in that I tested it here on my main box which is Gentoo based. I'll see if I can get to testing it on WinXP a little later on. Are you using the GL based driver for Irrlicht or the D3D one? Also is this on a AMD/ATI or NVidia (or some other card)? Can you test on another, similar but not identical, system?

The actual skin definition looks fine, for example the positioning of the left side corner pieces and the left side edge piece are all specified with an absolute co-ordinate of zero; where and how that side piece is getting offset by one pixel is a little confusing (surely zero is zero?!). By any chance do you get any strangeness when moving the frame window around?

CE

lymantok
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 13, 2007 03:24

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby lymantok » Mon Jul 27, 2009 03:12

Hi CE,

I'm using the D3D driver for Irrlicht.
Video driver is a NVIDIA Quadro FX 570M in a laptop.

I can replicate my set up and test on a desktop and let you know.

I can move the frame window when I figure out how to code it! ;-)

Thx!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby CrazyEddie » Mon Jul 27, 2009 08:27

Thanks for the info, I'll run a test on windows XP using irrlicht and the D3D driver and see if I have any luck reproducing this issue. Might not get to that today though, depends how 'other stuff' pans out ;)

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby CrazyEddie » Tue Jul 28, 2009 09:57

Ok. I have now tested this on Win32 Irrlicht running under the D3D driver and can reproduce the issue; when running on the same system with Irrlicht using the OpenGL driver there are no issues (and to answer my own question, no, moving the window does not cause any other strange behaviour!). So now I guess the question becomes is this a CEGUI issue or a Irrlicht issue - I'm not sure at the moment, I may post again if I can establish the fact one way or the other (my first guess is that it's a pixel / texel origin issue, and since for 0.6.x the images are drawn via IVideoDriver::draw2DImage any differences in origin should be taken care of internally by Irrlicht - I'll double check this though).

CE.

lymantok
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 13, 2007 03:24

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby lymantok » Thu Jul 30, 2009 04:24

Thx CE. Let me know what you conclude. If it's an Irrlicht issue, I'll post on their forum. Thx again for investigating.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby CrazyEddie » Fri Jul 31, 2009 09:14

Sure. I'll look at this today and reply here this evening some time.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Layout XML misaligned when loaded vs CEGUI Layout Editor

Postby CrazyEddie » Fri Jul 31, 2009 13:56

Ok. I have conducted a series of tests and have confirmed that this is an issue (at least from our point of view) in Irrlicht with the Direct3D driver(s) as regards to incorrect texel to pixel mapping for the 2D rendering function(s). Unfortunately, this can't be fudged or fixed on the CEGUI side because the draw2DImage function we use from Irrlicht is - quite reasonably - using integers for the destination coordinates, but this means we can't pre-offset them to get the required mapping.

The solution is to modify the draw2DImage implementations in the D3D driver code for Irrlicht so that the positions are offset by the required amount, for example:

Code: Select all

--- CD3D9Driver.cpp.org   Fri Jul 31 14:49:57 2009
+++ CD3D9Driver.cpp   Fri Jul 31 14:50:43 2009
@@ -1255,10 +1255,10 @@
    core::rect<f32> npos;
    f32 xFact = 2.0f / ( renderTargetSize.Width );
    f32 yFact = 2.0f / ( renderTargetSize.Height );
-   npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f;
-   npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact );
-   npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f;
-   npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact );
+   npos.UpperLeftCorner.X = ( (destRect.UpperLeftCorner.X - 0.5f) * xFact ) - 1.0f;
+   npos.UpperLeftCorner.Y = 1.0f - ( (destRect.UpperLeftCorner.Y - 0.5f) * yFact );
+   npos.LowerRightCorner.X = ( (destRect.LowerRightCorner.X - 0.5f) * xFact ) - 1.0f;
+   npos.LowerRightCorner.Y = 1.0f - ( (destRect.LowerRightCorner.Y - 0.5f) * yFact );
 
    const video::SColor temp[4] =
    {

Note this only 'fixes' the function we actually use (there are other overloads, that may or may not be affected).

HTH

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 22 guests