- // FIXME: Implement proper clipping here
- int start_x = -parallax_image_size.width / 2.0f / image->get_width() - 1;
- int end_x = parallax_image_size.width / 2.0f / image->get_width() + 1;
- int start_y = -parallax_image_size.height / 2.0f / image->get_height() - 1;
- int end_y = parallax_image_size.height / 2.0f / image->get_height() + 1;
+ int start_x = static_cast<int>(floorf((cliprect.get_left() - (pos.x - image->get_width() /2.0f)) / image->get_width()));
+ int end_x = static_cast<int>(ceilf((cliprect.get_right() - (pos.x + image->get_width() /2.0f)) / image->get_width()))+1;
+ int start_y = static_cast<int>(floorf((cliprect.get_top() - (pos.y - image->get_height()/2.0f)) / image->get_height()));
+ int end_y = static_cast<int>(ceilf((cliprect.get_bottom() - (pos.y + image->get_height()/2.0f)) / image->get_height()))+1;