Rendering opaque and transparent separately

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sat Aug 27, 2016 18:40

@niello , I made a prototype for you and tested it. It generally works but has one big caveat I will get at later in this post. Please test it using this branch & commit:

https://bitbucket.org/cegui/cegui/commi ... 0be22a9563

You will need to call GUIContext::draw(...) and fill in the right DrawMode you want as parameter. For each window you will have to set a "DrawMode" property which is of type integer.
setProperty<int>( static_cast<int>(DrawMode::DM_OPAQUE) )

should work for example.

Now let's get to the big caveat.
What's not working:
Every window that has a AutoRenderingSurface set it true (framewindow default in 0.8.X) will render all its contents regardless. This will always show up. Maybe I overlooked something but the fix for this seemed not so easy to me. This is more or less a cache after all.


EDIT:
I think the above should be solvable by adapting this function to also take the DrawMode param and do the same as for the GuiContext functions:

Code: Select all

void Window::queueGeometry(const RenderingContext& ctx)


What will never automagically work for AutoRenderingSurfaces though is a detection if a DrawMode of a Window has changed. If desiring to do this in run-time then the affected parents will need to be invalidated so that they are updated in the next frame. I think adding a listener or anything on that would be overkill.
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 439
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Rendering opaque and transparent separately

Postby YaronCT » Sat Aug 27, 2016 19:21

@Ident: The type of the property being "int" is temporary, right?

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sat Aug 27, 2016 19:34

YaronCT wrote:@Ident: The type of the property being "int" is temporary, right?

No. What's wrong with that?

There is two ways to go on about it in v0 and default:
#1 keep it as-is
#2 add a new property of type enum : short, that will be part of every window and signify the draw mode.

The latter has the advantage that we can create functions for this and make usage therefore easier and clean up the whole thing better. Also it will be stored as short internally then. Disadvantage is that every window will be bigger in size by sizeof(short). Not a tremendous amount obviously but for something that most people won't use, it may matter?

the disadvantage of #1 is that properties like this will be stored as string and then converted to int each time. Clearly a String("1") takes more space than a short. So if this feature is actually used a lot then it will end up taking more space than with approach #2.
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 439
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Rendering opaque and transparent separately

Postby YaronCT » Sat Aug 27, 2016 19:52

Y not make a spcialized property helper for that enum, like u have e.g. for "AspectMode", and since branch "v0" store it as simply the enum (again, like "AspectMode")?

I wouldn't bother myself with space issues - I think we're past the days that the not very young of us remember when we had to deal with a 1MB or 64KB RAM. Really, it's hard for me to think of a scenario where the space of an "enum" would matter here, and I wouldn't mess with its size. Usually speed is more important so I wouldn't b surprised if compilers represent it as the fastest integer type or, if it's a smaller type, align it to multiples of the fastest type when it arranges the fields in the class.

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sat Aug 27, 2016 20:26

YaronCT wrote:Y not make a spcialized property helper for that enum, like u have e.g. for "AspectMode", and since branch "v0" store it as simply the enum (again, like "AspectMode")?

Yea, that's specifically and exactly how it should be done. I guess you meant this should be done for v0-8 already and I guess you are right ;)
CrazyEddie: "I don't like GUIs"

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sat Aug 27, 2016 20:46

I guess if we make it like with AspectMode we will have to do it as String not int.
CrazyEddie: "I don't like GUIs"

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sat Aug 27, 2016 21:29

There you guys go: https://bitbucket.org/cegui/cegui/commi ... 6a1ade8bf2

Any comments Yaron?
CrazyEddie: "I don't like GUIs"

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sun Aug 28, 2016 08:52

Final fix: https://bitbucket.org/cegui/cegui/commi ... 6a1ade8bf2

Using "UserString" instead of a property now. I think a property is not feasible in v0-8 or would be really annoying to shoehorn in.

Usage:

Code: Select all

wnd->setUserString(PropertyHelper<DrawMode>::getDataTypeName(), PropertyHelper<DrawMode>::OnlyOpaque);

or if you like living on the edge:

Code: Select all

wnd->setUserString("DrawMode", "OnlyOpaque");


I tested it and it works, now also for ARS
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 439
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Rendering opaque and transparent separately

Postby YaronCT » Sun Aug 28, 2016 09:36

@Ident: Even in branch "v0-8" where u use a user string, u can still make it a property (of type DrawMode), where its setter and getter will set or get the user string. How the property is stored should b transparent to the cegui user, and shouldn't change between branch "v0-8" and branch "v0" (or later).

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sun Aug 28, 2016 10:25

YaronCT wrote:@Ident: Even in branch "v0-8" where u use a user string, u can still make it a property (of type DrawMode), where its setter and getter will set or get the user string. How the property is stored should b transparent to the cegui user, and shouldn't change between branch "v0-8" and branch "v0" (or later).

Could, but wouldnt that force us to add an actual user String for EVERY window?
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 439
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Rendering opaque and transparent separately

Postby YaronCT » Sun Aug 28, 2016 10:27

No. If the user string doesn't exist u can regard the property has having its default value.

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sun Aug 28, 2016 10:29

Like I do now. True. I will try that approach
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 439
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Rendering opaque and transparent separately

Postby YaronCT » Sun Aug 28, 2016 10:32

@Ident: And in the user string u can just store it as a string which contains an integer (the enum value) - the cegui user shouldn't use the user string directly anyway.

YaronCT
CEGUI Team
Posts: 439
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Rendering opaque and transparent separately

Postby YaronCT » Sun Aug 28, 2016 10:38

@Ident: I don't know if it matters much, but shouldn't this whole thing b implemented in "Element" rather than "Window"? The way I understand it is that elements knows about its area and to draw itself, but doesn't know about events.

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Rendering opaque and transparent separately

Postby Ident » Sun Aug 28, 2016 10:56

YaronCT wrote:@Ident: I don't know if it matters much, but shouldn't this whole thing b implemented in "Element" rather than "Window"? The way I understand it is that elements knows about its area and to draw itself, but doesn't know about events.


Afaik an Element doesnt know anything about actual drawing. Window::render() is not derived from Element.
CrazyEddie: "I don't like GUIs"


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 1 guest