Hiding mouse cursor stops GUI from clearing?

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

Megadanxzero
Just popping in
Just popping in
Posts: 4
Joined: Mon Feb 04, 2013 18:36

Hiding mouse cursor stops GUI from clearing?

Postby Megadanxzero » Mon Feb 11, 2013 17:37

I've come across quite a strange problem after trying to hide the mouse cursor. Previously rendered GUI stuff seems to get stuck on the screen if I either don't set a default mouse cursor, or hide it. Since it's not being cleared it accumulates over time and ends up filling the screen. The strangest thing is that it seems to somehow prevent anything else behind it from being redrawn as well (Either that or my own stuff rendered behind the GUI is getting stuck on the GUI on the first frame, and is then not being updated). Here's a screenshot to show what I mean:

http://i.imgur.com/QxxVNcf.jpg
(It cuts off on the left because I thought maybe resizing the root DefaultWindow so that it didn't take up the whole screen would allow stuff to continue drawing in the space on the left, but that didn't work)

I did a bit of testing with different layouts, some of them worked and some of them didn't, and it seems that any layouts I make with a "Vanilla/StaticText" window in them 'cause this problem, whereas if I have something like a FrameWindow instead it works fine. At first I thought maybe the StaticText window doesn't cause the GUI to redraw (since it's 'static' so maybe assumed it won't change?), but that doesn't seem to be the case as currently I'm using SetText to update a timer (Which you can see in the bottom right of the screenshot) and that redraws fine, showing the correct time as it counts down.

Any idea what would be causing this or how I could fix it? My log doesn't show any errors or anything, but I'll paste in the essential bit and my layout file:

Code: Select all

11/02/2013 17:03:13 (Std)    ********************************************************************************
11/02/2013 17:03:13 (Std)    * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM       -------- *
11/02/2013 17:03:13 (Std)    ********************************************************************************
11/02/2013 17:03:13 (Std)    ---- Version 0.7.9 (Build: Feb  3 2013 Microsoft Windows MSVC++ 10.0 32 bit) ----
11/02/2013 17:03:13 (Std)    ---- Renderer module is: CEGUI::Direct3D9Renderer - Official Direct3D 9 based 2nd generation renderer module. ----
11/02/2013 17:03:13 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
11/02/2013 17:03:13 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
11/02/2013 17:03:13 (Std)    ---- Scripting module is: None ----
11/02/2013 17:03:13 (Std)    ********************************************************************************
11/02/2013 17:03:13 (Std)    * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM         -------- *
11/02/2013 17:03:13 (Std)    ********************************************************************************


Code: Select all

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

<GUILayout >
    <Window Type="DefaultWindow" Name="Root" >
        <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
        <Window Type="Vanilla/StaticText" Name="Timer" >
            <Property Name="Font" Value="DejaVuSans-30" />
            <Property Name="Text" Value="0" />
            <Property Name="HorzExtent" Value="26" />
            <Property Name="VertExtent" Value="46.5625" />
            <Property Name="HorzFormatting" Value="HorzCentred" />
            <Property Name="UnifiedAreaRect" Value="{{0,-18},{0,-18},{0,48},{0,48}}" />
            <Property Name="VerticalAlignment" Value="Bottom" />
            <Property Name="HorizontalAlignment" Value="Right" />
        </Window>
    </Window>
</GUILayout>

Changing the "Vanilla/StaticText" to "Vanilla/FrameWindow" makes it work perfectly, but unfortunately I'd rather just have a StaticText window. Oh and the other windows you can see in the screenshot were being added dynamically in code, but I've disabled those completely, so the one StaticText window in the above layout file is the only one being added. Also just realised this might have been more appropriate in the Bug Reports forum, but I'm unsure if it actually is a bug or simply something I've done wrong in creating the layout since I'm new to CEGUI. :3

EDIT: So I tried some stuff to force the GUI to redraw to see if that would fix it, such as:
Invalidating the StaticText window and the root DefaultWindow every frame.
Calling signalRedraw on the system every frame.
Calling invalidateAllCachedRendering on the system every frame.
Manually calling render on the root window every frame.
Unfortunately none of those worked :(

I also noticed that around the edges of the StaticText window, where the border images are transparent, you can actually see what's behind being updated every frame. It seems everywhere but the StaticText window just refuses to redraw...
http://i.imgur.com/nCXmb5V.png

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

Re: Hiding mouse cursor stops GUI from clearing?

Postby CrazyEddie » Tue Feb 12, 2013 10:10

CEGUI does not clear the display. And windows that do no rendering - such as DefaultWindow - do not clear anything either.

This said, I'm unsure precisely what you're seeing and why - yes, I've seen the screenshot! But still. I'm also completely unsure why hiding the mouse - or not setting a default image for it - would cause this. I'm also not sure why changing from StaticText to FrameWindow would alleviate the issue (though FrameWindow is by default backed by a render texture, but why would that affect the rest of the display?)

If you have the samples running, are you able to reproduce the issue there? Such as by hiding the mouse in one of them?

CE.

Megadanxzero
Just popping in
Just popping in
Posts: 4
Joined: Mon Feb 04, 2013 18:36

Re: Hiding mouse cursor stops GUI from clearing?

Postby Megadanxzero » Tue Feb 12, 2013 16:10

Hi, didn't have any samples built, so I spent a while doing that and messing with them adding StaticText windows or changing some existing ones to StaticText, but I couldn't get the same thing to happen in the samples at all. I guess that means it must be something I'm doing in my own code, such as a RenderState change. I tried adding/removing various RenderState settings, and eventually removed all of my own RenderState changes completely (Though I assume CEGUI does some of its own), but that didn't seem to change anything.

I also tried messing with my screen clearing to see if maybe I had a wrong setting in there (Though I doubt the mouse cursor would affect it anyway) but again that didn't seem to change anything (Or it broke things more :3). Currently it's just this which I assume is fine.

Code: Select all

HR(mp_d3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0));


So I decided to try using PIX to have a look at the drawing process, and see whether the screen was simply not being cleared at all, or whether everything was being drawn normally at first, and then having a previous screen state drawn on top for some reason. Instead I found that running my program with PIX attached fixes the problem, and everything renders fine... So I can't use it to find out what the problem actually is! :(

I'm currently trying to find out if PIX maybe sets some kind of default render settings or something that might be accidentally fixing the problem. I also recorded some short videos just to be clearer what the actual problem looks like, it is a bit difficult to tell from just a screenshot:
Cursor Visible: http://youtu.be/ZY7K3NUPGrk
Cursor Hidden: http://youtu.be/9OtuYtxWo6Y

Oh and one last thing to be sure, I'm hiding the cursor by calling MouseCursor::getSingleton().hide() which I assume is correct. :3

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

Re: Hiding mouse cursor stops GUI from clearing?

Postby CrazyEddie » Wed Feb 13, 2013 09:41

Thanks for the videos, it made it a lot clearer as to what was happening :)

I couldn't fathom a possible cause at first, but after going through the issue a couple of times, I have come to the conclusion that at the point when you clear the display an render the non cegui parts of your scene, a render target other than the main display is set for the Direct3D device. This means that when you do the clear call, and then render your graphics, the results are going to some other target (likely a render texture or something) and not the screen.

Now, I don't know what else you're doing - either with your own stuff or with cegui - so am not certain 'whose issue' this is as such. So what follows might not be the right solution from a technical standpoint, although it should work. Basically, after the renderGUI call, you can do (or some equivalent):

Code: Select all

CEGUI::System::getSingleton().getRenderer()->getDefaultRenderingRoot().getRenderTarget().activate();


With the information you've given, needing to do this makes no sense. So I wonder if there is something else going on, or whether you're using multiple targets yourslf. If you are, then a better solution to the above would be to set the screen back as the target directly instead of using cegui to do that.

HTH

CE.

Megadanxzero
Just popping in
Just popping in
Posts: 4
Joined: Mon Feb 04, 2013 18:36

Re: Hiding mouse cursor stops GUI from clearing?

Postby Megadanxzero » Wed Feb 13, 2013 13:07

I tried the line you suggested and it didn't seem to have any effect, but I then tried getting the backbuffer and setting that as the render target on the actual device before drawing my own stuff each frame, and that has indeed fixed it. :) I imagine PIX must automatically do that when you attach it or something, so it worked fine through PIX.

The strange thing is that I'm not actually using any other render targets myself, so I would have expected the right render target to be set by default, but maybe I've done something wrong in my device/window creation that might explain it. Still have no idea why hiding the mouse cursor would affect whether it works or not though, but it could have been one of those things that shouldn't ever have worked, but just does by chance until you change something completely unrelated. :3

Anyway, thanks a lot for your help! I'll have to double check I haven't done something wrong elsewhere to cause this, but I'm looking in the right direction now at least.

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

Re: Hiding mouse cursor stops GUI from clearing?

Postby CrazyEddie » Thu Feb 14, 2013 09:23

It's strange that activating that default rendering target does not work - probably something I forgot about that prevents that from working :)

For information, the reason that hiding the mouse cursor affects this is because before rendering the cursor, the default rendering target is activated (and then left activated). If you hide the cursor or if the cursor has no image set, then this step is skipped and whatever target was active before is left active (and that's the part I can't explain, given the info I have the default target should already be active).

Anyway, glad you are on the right track now.

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests