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>
Layout XML misaligned when loaded vs CEGUI Layout Editor
Moderators: CEGUI MVP, CEGUI Team
- 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
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.
[Edit]
I see from your other thread you're using the Irrlicht renderer, so no need to post that now
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Layout XML misaligned when loaded vs CEGUI Layout Editor
Hi CE,
Yes, Irrlicht renderer on Windows XP.
The viewport is 1024 x 768.
Thx for taking a look!
Yes, Irrlicht renderer on Windows XP.
The viewport is 1024 x 768.
Thx for taking a look!
- 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
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
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
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Layout XML misaligned when loaded vs CEGUI Layout Editor
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!
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!
- 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
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.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
- 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
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.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Layout XML misaligned when loaded vs CEGUI Layout Editor
Thx CE. Let me know what you conclude. If it's an Irrlicht issue, I'll post on their forum. Thx again for investigating.
- 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
Sure. I'll look at this today and reply here this evening some time.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
- 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
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:
Note this only 'fixes' the function we actually use (there are other overloads, that may or may not be affected).
HTH
CE.
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.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Who is online
Users browsing this forum: No registered users and 22 guests