bug in CEGUIRenderer texture filtering not applied properly

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
mba
Greenskin
Posts: 110
Joined: Sun Sep 11, 2005 10:31 am
Location: Denmark

bug in CEGUIRenderer texture filtering not applied properly

Post by mba »

Hi

I previous had a problem with texture filtering of CEGUI elements in OpenGL, where the textures had point filtering applied instead of linear filtering. Sinbad discovered a bug in OgreCEGUIRenderer.cpp where the order of calling initRenderStates and _setTexture mattered in OpenGL whereas it didn't matter in DirectX.
I applied the solution for this bug on my old Dagon as I can't upgrade to Eihort atm. But I still have som issues with elements where I set the texture "manually" like image buttons and static images. These elements will get linear filtered only when pressing them i.e. they get focus. But until then they have point filtering applied.
I discovered a bug in the doRender loop in OgreCEGUIRenderer.cpp that causes this behavior:

Code: Select all

        while(i != d_quadlist.end())
        {
            
            d_currTexture = i->texture;
            d_render_op.vertexData->vertexStart = d_bufferPos;
            for (; i != d_quadlist.end(); ++i)
            {
                const QuadInfo& quad = (*i);
                if (d_currTexture != quad.texture)
                    /// If it has a different texture, render this quad in next operation
		            break;
                d_bufferPos += VERTEX_PER_QUAD;
            }
            d_render_op.vertexData->vertexCount = d_bufferPos - d_render_op.vertexData->vertexStart;
            /// Set texture, and do the render
            d_render_sys->_setTexture(0, true, d_currTexture->getName());
            
            if (first)
            {
              initRenderStates();
              first = false;
            }
            
            d_render_sys->_render(d_render_op);
        }
Sinbad changed the order so initRenderStates will get called after changing the texture with _setTexture, and initRenderStates will only get called once controlled by the boolean first. But during the loop theres a chance that the texture will change and therefore the first must be set to true again in this loop:

Code: Select all

            for (; i != d_quadlist.end(); ++i)
            {
                const QuadInfo& quad = (*i);
                if (d_currTexture != quad.texture) {
                    /// If it has a different texture, render this quad in next operation
                      first = true;
                      break;
                }
                d_bufferPos += VERTEX_PER_QUAD;
            }
kind regards
Martin Bang Andersen
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Thanks. In future please submit this kind of thing as a patch so it doesn't get buried in the forum.
mba
Greenskin
Posts: 110
Joined: Sun Sep 11, 2005 10:31 am
Location: Denmark

Post by mba »

Yes I know, but I only have the olde Dagon 1.2.4 and as I read in "Submitting a patch" you don't like patches against anything older than the newest stable release, and for that to happen I had to download, edit, and compile (which I cannot do atm) eihort... But next time :-), Ill submit a patch

regards
Martin
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

We prefer it against 1.4, but I can upgrade patches from older versions too. I'd rather that than it get lost :)
Post Reply