When using the progress bar and image is being clipped, the width/height value does not get aligned to pixels correctly before being rendered.
This results in what is shown in the image at bottom left corner.

Parts of image end up different than what they should be and can see it changing when progress bar is being updated.
Fixes:
These have both been tested.
Fix 1 is more of a quick hack to help identify cause of problem before looking deeper into it.
Fix 2 is what i am currently using, seems more elegant, although i do not know what side effects it might have if any.
Fix 1:
Within File: cegui/src/WindowRendererSets/Falagard/FalProgressBar.cpp Function: FalagardProgressBar::render
The is first thing i tried when trying to figure out the cause of the problem. Changes the height and width to integer.
Original code:
Code: Select all
if (d_vertical)
{
float height = progressClipper.getHeight() * w->getProgress();
if (d_reversed)
{
progressClipper.setHeight(height);
}
else
{
progressClipper.d_top = progressClipper.d_bottom - height;
}
}
else
{
float width = progressClipper.getWidth() * w->getProgress();
if (d_reversed)
{
progressClipper.d_left = progressClipper.d_right - width;
}
else
{
progressClipper.setWidth(width);
}
}
Changed code:
Code: Select all
if (d_vertical)
{
int height = static_cast<int>(progressClipper.getHeight() * w->getProgress());
if (d_reversed)
{
progressClipper.setHeight(static_cast<float>(height));
}
else
{
progressClipper.d_top = progressClipper.d_bottom - height;
}
}
else
{
int width = static_cast<int>(progressClipper.getWidth() * w->getProgress());
if (d_reversed)
{
progressClipper.d_left = progressClipper.d_right - width;
}
else
{
progressClipper.setWidth(static_cast<float>(width));
}
}
Fix 2:
Within File: cegui/src/CEGUIImageset.cpp Function: Imageset::draw
Seems most of time final_rect is already aligned to pixels so would be why this is not happening with other images.
So tex_rect would end up being created using a final_rect that is not pixel aligned for when progress bar is drawn
with the clipping.
Original code:
Code: Select all
// calculate final, clipped, texture co-ordinates
Rect tex_rect((source_rect.d_left + ((final_rect.d_left - dest_rect.d_left) * tex_per_pix_x)) * x_scale,
(source_rect.d_top + ((final_rect.d_top - dest_rect.d_top) * tex_per_pix_y)) * y_scale,
(source_rect.d_right + ((final_rect.d_right - dest_rect.d_right) * tex_per_pix_x)) * x_scale,
(source_rect.d_bottom + ((final_rect.d_bottom - dest_rect.d_bottom) * tex_per_pix_y)) * y_scale);
final_rect.d_left = PixelAligned(final_rect.d_left);
final_rect.d_right = PixelAligned(final_rect.d_right);
final_rect.d_top = PixelAligned(final_rect.d_top);
final_rect.d_bottom = PixelAligned(final_rect.d_bottom);
Changed code:
Code: Select all
// calculate final, clipped, texture co-ordinates
final_rect.d_left = PixelAligned(final_rect.d_left);
final_rect.d_right = PixelAligned(final_rect.d_right);
final_rect.d_top = PixelAligned(final_rect.d_top);
final_rect.d_bottom = PixelAligned(final_rect.d_bottom);
Rect tex_rect((source_rect.d_left + ((final_rect.d_left - dest_rect.d_left) * tex_per_pix_x)) * x_scale,
(source_rect.d_top + ((final_rect.d_top - dest_rect.d_top) * tex_per_pix_y)) * y_scale,
(source_rect.d_right + ((final_rect.d_right - dest_rect.d_right) * tex_per_pix_x)) * x_scale,
(source_rect.d_bottom + ((final_rect.d_bottom - dest_rect.d_bottom) * tex_per_pix_y)) * y_scale);