Page 1 of 1

[Solved] weird color change caused by CEGUI rendering

Posted: Sat Sep 02, 2017 20:56
by andrewfeng123
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

:? :? :?

Re: weird color change caused by CEGUI rendering

Posted: Sat Sep 02, 2017 22:19
by Ident
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 ;)

Re: weird color change caused by CEGUI rendering

Posted: Sun Sep 03, 2017 04:35
by andrewfeng123
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.