Page 1 of 1

[Solved] CEGUI widgets only partially visible

Posted: Sun May 22, 2011 16:06
by MarkR
Hi altogether,

I'm developing an overlay application for TS3 (http://ts3overlay.r-dev.de).
Basically the UI consists on two different windows which are shown all the time: The one where you can see relevant content of the TS3 server (channels, users, ...) and a small icon. There are also two windows, that are not always shown: A context menu, and a notification, that the overlay now accepts mouse input.

The overlay so far works in most games that use D3D8 or higher or OpenGL (so it's Windows only) ;-)
However, with one game, I ran into a strange problem when injecting the overlay.
The small logo is visible on the screen, however the window isn't.
The context menu itself also isn't showing.
If I move the mouse where I know the window should be, the cursor changes to the resize-cursor, so I know, the window IS there, it's just not being painted.

I experienced similar things in the past and I always messed up some rendering states, but in these cases I simply saw nothing. This case now is somewhat different.

This is the initialization of the logo, that is visible:

Code: Select all

CEGUI::ImagesetManager::getSingleton().createFromImageFile("ts3overlay_logo", "ts3overlay_logo.png", "imagesets");
logo = wmgr.createWindow("WindowsLook/StaticImage", "ts3overlay_logo");
logo->setProperty("FrameEnabled", "false");
logo->setProperty("BackgroundEnabled", "false");
logo->setProperty("Image", "set:logo image:full_image");
logo->setPosition(logo_pos);
logo->setSize(CEGUI::UVector2(cegui_absdim(16), cegui_absdim(16));
root->addChildWindow(logo);

as well as the hint window:

Code: Select all

warning_window = wmgr.createWindow("WindowsLook/StaticText");
warning_window->setEnabled(false);
warning_window->setText("Blah blah");
warning_window->setProperty("BackgroundColours", "tl:FF758BB2 tr:FF758BB2 bl:FFA7C7FF br:FFA7C7FF");
warning_window->setProperty("BackgroundEnabled", "true");
warning_window->setProperty("HorzFormatting", "HorzCentred");
warning_window->setAlwaysOnTop(true);
warning_window->setClippedByParent(false);
warning_window->setAlpha(1.0f);
warning_window->hide(); // window gets visible if Scroll-Lock is pressed
root->addChildWindow(warning_window);


While these two windows aren't visible:

Code: Select all

popup_menu = (CEGUI::PopupMenu*)wmgr.createWindow("WindowsLook/PopupMenu");
popup_menu->setInheritsAlpha(false);
popup_menu->setAlwaysOnTop(true);
CEGUI::MenuItem* item1 = (CEGUI::MenuItem*)wmgr.createWindow("WindowsLook/MenuItem");
item1->setText("Item1");
popupMenu->addChildWindow(item1);

and

Code: Select all

ts3_window = (CEGUI::FrameWindow*)wmgr.createWindow("TS3Overlay/FrameWindow");
ts3_window->setProperty("BackgroundColour", backgroundColour);
myRoot->addChildWindow(ts3_window);
ts3_window->setPosition(ts3_window_pos);
ts3_window->setSize(ts3_window_size);
ts3_window->setText("ts3overlay.r-dev.de");
ts3_window->setMouseInputPropagationEnabled(true);
ts3_window->getTitleBar()->setInheritsAlpha(false);
ts3_window->getCloseButton()->setInheritsAlpha(false);


The mentioned game uses D3D9:

Code: Select all

22/05/2011 15:58:44 (Std)    ---- Version 0.7.5 (Build: Dec 20 2010 Static Microsoft Windows MSVC++ 10.0 32 bit) ----
22/05/2011 15:58:44 (Std)    ---- Renderer module is: CEGUI::Direct3D9Renderer - Official Direct3D 9 based 2nd generation renderer module. ----
22/05/2011 15:58:44 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
22/05/2011 15:58:44 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
22/05/2011 15:58:44 (Std)    ---- Scripting module is: None ----


The CEGUI version is basically on 0.7.5 but is slightly modified to link all different renderer modules into one single DLL (important if you try to inject the DLL into a game that uses a CEGUI DLL of another version), a D3D8 Renderer, some speed improvements in the Tree widget, as well as the fix for ticket #445.

Before rendering, I try to put the D3D9Device into a reasonable state, and did an output of the rendering states after modifying those, just in case it helps (which I doubt) ^^

Code: Select all

22/05/2011 15:58:44 (Std)    D3DRS_ZENABLE                      0
22/05/2011 15:58:44 (Std)    D3DRS_FILLMODE                     3
22/05/2011 15:58:44 (Std)    D3DRS_SHADEMODE                    2
22/05/2011 15:58:44 (Std)    D3DRS_ZWRITEENABLE                 0
22/05/2011 15:58:44 (Std)    D3DRS_ALPHATESTENABLE              0
22/05/2011 15:58:44 (Std)    D3DRS_LASTPIXEL                    1
22/05/2011 15:58:44 (Std)    D3DRS_SRCBLEND                     5
22/05/2011 15:58:44 (Std)    D3DRS_DESTBLEND                    6
22/05/2011 15:58:44 (Std)    D3DRS_CULLMODE                     1
22/05/2011 15:58:44 (Std)    D3DRS_ZFUNC                        8
22/05/2011 15:58:44 (Std)    D3DRS_ALPHAREF                     0
22/05/2011 15:58:44 (Std)    D3DRS_ALPHAFUNC                    8
22/05/2011 15:58:44 (Std)    D3DRS_DITHERENABLE                 0
22/05/2011 15:58:44 (Std)    D3DRS_ALPHABLENDENABLE             1
22/05/2011 15:58:44 (Std)    D3DRS_FOGENABLE                    0
22/05/2011 15:58:44 (Std)    D3DRS_SPECULARENABLE               0
22/05/2011 15:58:44 (Std)    D3DRS_FOGCOLOR                     0
22/05/2011 15:58:44 (Std)    D3DRS_FOGTABLEMODE                 0
22/05/2011 15:58:44 (Std)    D3DRS_FOGSTART                     0
22/05/2011 15:58:44 (Std)    D3DRS_FOGEND                       1065353216
22/05/2011 15:58:44 (Std)    D3DRS_FOGDENSITY                   1065353216
22/05/2011 15:58:44 (Std)    D3DRS_RANGEFOGENABLE               0
22/05/2011 15:58:44 (Std)    D3DRS_STENCILENABLE                0
22/05/2011 15:58:44 (Std)    D3DRS_STENCILFAIL                  1
22/05/2011 15:58:44 (Std)    D3DRS_STENCILZFAIL                 1
22/05/2011 15:58:44 (Std)    D3DRS_STENCILPASS                  1
22/05/2011 15:58:44 (Std)    D3DRS_STENCILFUNC                  8
22/05/2011 15:58:44 (Std)    D3DRS_STENCILREF                   0
22/05/2011 15:58:44 (Std)    D3DRS_STENCILMASK                  4294967295
22/05/2011 15:58:44 (Std)    D3DRS_STENCILWRITEMASK             4294967295
22/05/2011 15:58:44 (Std)    D3DRS_TEXTUREFACTOR                4294967295
22/05/2011 15:58:44 (Std)    D3DRS_WRAP0                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP1                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP2                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP3                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP4                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP5                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP6                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP7                        0
22/05/2011 15:58:44 (Std)    D3DRS_CLIPPING                     1
22/05/2011 15:58:44 (Std)    D3DRS_LIGHTING                     1
22/05/2011 15:58:44 (Std)    D3DRS_AMBIENT                      0
22/05/2011 15:58:44 (Std)    D3DRS_FOGVERTEXMODE                0
22/05/2011 15:58:44 (Std)    D3DRS_COLORVERTEX                  0
22/05/2011 15:58:44 (Std)    D3DRS_LOCALVIEWER                  1
22/05/2011 15:58:44 (Std)    D3DRS_NORMALIZENORMALS             0
22/05/2011 15:58:44 (Std)    D3DRS_DIFFUSEMATERIALSOURCE        1
22/05/2011 15:58:44 (Std)    D3DRS_SPECULARMATERIALSOURCE       2
22/05/2011 15:58:44 (Std)    D3DRS_AMBIENTMATERIALSOURCE        0
22/05/2011 15:58:44 (Std)    D3DRS_EMISSIVEMATERIALSOURCE       0
22/05/2011 15:58:44 (Std)    D3DRS_VERTEXBLEND                  0
22/05/2011 15:58:44 (Std)    D3DRS_CLIPPLANEENABLE              0
22/05/2011 15:58:44 (Std)    D3DRS_POINTSIZE                    1065353216
22/05/2011 15:58:44 (Std)    D3DRS_POINTSIZE_MIN                1065353216
22/05/2011 15:58:44 (Std)    D3DRS_POINTSPRITEENABLE            0
22/05/2011 15:58:44 (Std)    D3DRS_POINTSCALEENABLE             0
22/05/2011 15:58:44 (Std)    D3DRS_POINTSCALE_A                 1065353216
22/05/2011 15:58:44 (Std)    D3DRS_POINTSCALE_B                 0
22/05/2011 15:58:44 (Std)    D3DRS_POINTSCALE_C                 0
22/05/2011 15:58:44 (Std)    D3DRS_MULTISAMPLEANTIALIAS         1
22/05/2011 15:58:44 (Std)    D3DRS_MULTISAMPLEMASK              4294967295
22/05/2011 15:58:44 (Std)    D3DRS_PATCHEDGESTYLE               0
22/05/2011 15:58:44 (Std)    D3DRS_DEBUGMONITORTOKEN            3131951870
22/05/2011 15:58:44 (Std)    D3DRS_POINTSIZE_MAX                1174405120
22/05/2011 15:58:44 (Std)    D3DRS_INDEXEDVERTEXBLENDENABLE     0
22/05/2011 15:58:44 (Std)    D3DRS_COLORWRITEENABLE             15
22/05/2011 15:58:44 (Std)    D3DRS_TWEENFACTOR                  0
22/05/2011 15:58:44 (Std)    D3DRS_BLENDOP                      1
22/05/2011 15:58:44 (Std)    D3DRS_POSITIONDEGREE               3
22/05/2011 15:58:44 (Std)    D3DRS_NORMALDEGREE                 1
22/05/2011 15:58:44 (Std)    D3DRS_SCISSORTESTENABLE            0
22/05/2011 15:58:44 (Std)    D3DRS_SLOPESCALEDEPTHBIAS          0
22/05/2011 15:58:44 (Std)    D3DRS_ANTIALIASEDLINEENABLE        0
22/05/2011 15:58:44 (Std)    D3DRS_MINTESSELLATIONLEVEL         1065353216
22/05/2011 15:58:44 (Std)    D3DRS_MAXTESSELLATIONLEVEL         1065353216
22/05/2011 15:58:44 (Std)    D3DRS_ADAPTIVETESS_X               0
22/05/2011 15:58:44 (Std)    D3DRS_ADAPTIVETESS_Y               0
22/05/2011 15:58:44 (Std)    D3DRS_ADAPTIVETESS_Z               1065353216
22/05/2011 15:58:44 (Std)    D3DRS_ADAPTIVETESS_W               0
22/05/2011 15:58:44 (Std)    D3DRS_ENABLEADAPTIVETESSELLATION   0
22/05/2011 15:58:44 (Std)    D3DRS_TWOSIDEDSTENCILMODE          0
22/05/2011 15:58:44 (Std)    D3DRS_CCW_STENCILFAIL              1
22/05/2011 15:58:44 (Std)    D3DRS_CCW_STENCILZFAIL             1
22/05/2011 15:58:44 (Std)    D3DRS_CCW_STENCILPASS              1
22/05/2011 15:58:44 (Std)    D3DRS_CCW_STENCILFUNC              8
22/05/2011 15:58:44 (Std)    D3DRS_COLORWRITEENABLE1            15
22/05/2011 15:58:44 (Std)    D3DRS_COLORWRITEENABLE2            15
22/05/2011 15:58:44 (Std)    D3DRS_COLORWRITEENABLE3            15
22/05/2011 15:58:44 (Std)    D3DRS_BLENDFACTOR                  0
22/05/2011 15:58:44 (Std)    D3DRS_SRGBWRITEENABLE              0
22/05/2011 15:58:44 (Std)    D3DRS_DEPTHBIAS                    0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP8                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP9                        0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP10                       0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP11                       0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP12                       0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP13                       0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP14                       0
22/05/2011 15:58:44 (Std)    D3DRS_WRAP15                       0
22/05/2011 15:58:44 (Std)    D3DRS_SEPARATEALPHABLENDENABLE     1
22/05/2011 15:58:44 (Std)    D3DRS_SRCBLENDALPHA                2
22/05/2011 15:58:44 (Std)    D3DRS_DESTBLENDALPHA               6
22/05/2011 15:58:44 (Std)    D3DRS_BLENDOPALPHA                 1

22/05/2011 15:58:44 (Std)    D3DSAMP_ADDRESSU                   1
22/05/2011 15:58:44 (Std)    D3DSAMP_ADDRESSV                   1
22/05/2011 15:58:44 (Std)    D3DSAMP_ADDRESSW                   3
22/05/2011 15:58:44 (Std)    D3DSAMP_BORDERCOLOR                0
22/05/2011 15:58:44 (Std)    D3DSAMP_MAGFILTER                  1
22/05/2011 15:58:44 (Std)    D3DSAMP_MINFILTER                  1
22/05/2011 15:58:44 (Std)    D3DSAMP_MIPFILTER                  0
22/05/2011 15:58:44 (Std)    D3DSAMP_MIPMAPLODBIAS              0
22/05/2011 15:58:44 (Std)    D3DSAMP_MAXMIPLEVEL                0
22/05/2011 15:58:44 (Std)    D3DSAMP_MAXANISOTROPY              1
22/05/2011 15:58:44 (Std)    D3DSAMP_SRGBTEXTURE                0
22/05/2011 15:58:44 (Std)    D3DSAMP_ELEMENTINDEX               0
22/05/2011 15:58:44 (Std)    D3DSAMP_DMAPOFFSET                 0


I already checked with PixWin, if they did some weird stuff, but couldn't find anything.
Does anyone have some ideas?

Re: CEGUI widgets only partially visible

Posted: Tue May 24, 2011 07:02
by CrazyEddie
Strange. To state the bleeding obvious - if one window shows up, they all should!

If you position the absent windows so that they overlap where the logo shows, do they then - at least a part of them - show up?

CE.

Re: CEGUI widgets only partially visible

Posted: Tue May 24, 2011 07:34
by MarkR
Nope, already tried that. If I swap the positions of the small icon and the main widget, the effect stays the same: The icon is shown, while the main widget isn't.

I also tried rendering right before the call to ID3D9Device::EndScene(), as well as right before ID3D9Device::Present(), but this doesn't make any difference.
Just thinking loudly:
Could this be a depth issue? D3DRS_ZENABLE is set to FALSE, but I'm not sure whether this also applies to the viewport's Z-range.
Probably the different windows are rendered with different Z values, while the main window is outside the viewport's range. Need to check how the game set's its viewport...

Re: CEGUI widgets only partially visible

Posted: Tue May 24, 2011 08:13
by CrazyEddie
Probably the different windows are rendered with different Z values, while the main window is outside the viewport's range.

Hmmm. We used to do that, but not any more. By default all window rendering has the same Z value, which is 0.

CE.

Re: CEGUI widgets only partially visible

Posted: Tue May 24, 2011 21:35
by MarkR
In this case, I'm totally out of ideas. Do you have an idea how to debug such an issue?

I could imagine that other users also could run into the same problem sooner or later, so would it make sense to submit a patch for "enhanced device state restoration", at least for the stuff I do have now?

Re: CEGUI widgets only partially visible

Posted: Wed May 25, 2011 00:04
by Jamarr
CrazyEddie wrote:If you position the absent windows so that they overlap where the logo shows, do they then - at least a part of them - show up?


MarkR wrote:Nope, already tried that. If I swap the positions of the small icon and the main widget, the effect stays the same: The icon is shown, while the main widget isn't.


There is a huge difference between the terms overlap and swap. Did you mean to say you tried both, or did you not actually try overlapping the windows? It is important to clarify since there may be some kind of clipping taking place which only affects the area outside the logo; I presume this is what CE was getting at.

Re: CEGUI widgets only partially visible

Posted: Wed May 25, 2011 06:28
by CrazyEddie
Yeah, you could also try attaching another window to the logo window, changing the size of the logo window, not drawing the logo window to see if another window appears.

Also, for the frame window you create, you could disable the AutoRenderingSurface by setting it to False and seeing if that changes anything :)

CE.

Re: CEGUI widgets only partially visible

Posted: Wed May 25, 2011 06:47
by MarkR
Jamarr wrote:There is a huge difference between the terms overlap and swap.


Ah, sorry, didn't make it clear enough.
What I did was swapping the initial positions of the two windows (normally the main window is in the top left corner, while the small icon is in the bottom left corner) as well as moving around both windows (including dragging the window over the icon and vice versa).
I did however not yet try to initialize them both at the same position. I'll check that.

CrazyEddie wrote:Yeah, you could also try attaching another window to the logo window, changing the size of the logo window, not drawing the logo window to see if another window appears.
Also, for the frame window you create, you could disable the AutoRenderingSurface by setting it to False and seeing if that changes anything.


Thanks for all those hints, I'll try that tonight.

Re: CEGUI widgets only partially visible

Posted: Sat May 28, 2011 12:24
by MarkR
It took a while, but I finally had the time to try these things.
setUsingAutoRenderingSurface(false) did the trick.

I would mark the thread as solved, but there are still questions remaining:
I checked the documentation and found, that disabling the AutoRenderingSurface might lead to a performance penalty (as the cache is disabled). Is that right?
If it doesn't affect performance, I'll disable the AutoRenderingSurface for any game, but I don't want to do that if this leads to (notifiable) performance loss.
In this case, is there any possibility to find out whether disabling the AutoRenderingSurface is required? Or would it be more feasable to generally create an own RenderingSurface and set this one to the FrameWindow?

Re: CEGUI widgets only partially visible

Posted: Sun May 29, 2011 19:14
by Kulik
AutoRenderingSurface basically provides a texture cache for Windows. It speeds up rendering in cases where the contents don't change (you only render a texture mapped quad instead of rendering all characters and widgets inside). I think it's definitely safe to disable and you shouldn't have major issues.

Re: CEGUI widgets only partially visible

Posted: Sun May 29, 2011 20:46
by MarkR
Great :D

Thanks for all your help :pint: