[Solved] weird color change caused by CEGUI rendering

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

andrewfeng123
Just popping in
Just popping in
Posts: 14
Joined: Sat Sep 02, 2017 20:28

[Solved] weird color change caused by CEGUI rendering

Postby andrewfeng123 » Sat Sep 02, 2017 20:56

Hello,
calling CEGUI's beginRendering() and endRendering() seems to change how Opengl renders alpha

here are the screenshots i took, please have a look

without CEGUI rendering:
Image

with CEGUI rendering:
Image

Btw, i use Opengl for rendering and SDL_image for image loading
here's my code for rendering:

Code: Select all

   level->Draw();            //game
   GUI::GetGUIClass()->GetRenderer()->beginRendering();      //causes the problem
   UIContext->draw();
   GUI::GetGUIClass()->GetRenderer()->endRendering();


My observation is that the colour changes when alpha is not 100%, but i can't figure out what is going on

:? :? :?

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

Re: weird color change caused by CEGUI rendering

Postby Ident » Sat Sep 02, 2017 22:19

Obviously a state is changed by CEGUI that you depended on. You can try to use this function: http://static.cegui.org.uk/docs/0.7.9/c ... b9ffd2f0f6 (enableExtraStateSettings) set to true.

or you manually reset the states.

I know this situation is unfavorable but that's how OpenGL works. In Vulkan this will work better ;)
CrazyEddie: "I don't like GUIs"

andrewfeng123
Just popping in
Just popping in
Posts: 14
Joined: Sat Sep 02, 2017 20:28

Re: weird color change caused by CEGUI rendering

Postby andrewfeng123 » Sun Sep 03, 2017 04:35

Ahh, after two hours research, i finally figured it out..

It turned out that it is beginRendering() that is setting blend mode to

Code: Select all

GUI::GetGUIClass()->GetRenderer()->setupRenderingBlendMode(CEGUI::BM_NORMAL, true);


also, endRendering() disables GL_BLEND

All i have to do is to set blend mode to CEGUI::BM_RTT_PREMULTIPLIED every time i render

but i figured it would be better to set it in my own drawing function like this..

Code: Select all

   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


After all this is actually a bug of my own drawing function,
thanks to CEGUI's renderer for finding it.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 1 guest