X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbackground.cpp;h=78a91809d6a9018712b7ca5abda4a2debcc4e9cd;hb=8e7ccc8e3b34ee1adb6f3cf7c3bc49e07c59fcb0;hp=1effc167131416e66587134ce5eedc873338b8e2;hpb=2074a5e3f8167dec24989c008ddadda14687a3a6;p=supertux.git diff --git a/src/background.cpp b/src/background.cpp index 1effc1671..78a91809d 100644 --- a/src/background.cpp +++ b/src/background.cpp @@ -16,8 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "background.h" +#include "background.h" #include "globals.h" #include "camera.h" #include "screen/drawing_context.h" @@ -39,7 +39,7 @@ Background::Background(LispReader& reader) int tr, tg, tb, br, bg, bb; if(reader.read_int("top_red", tr) && reader.read_int("top_green", tg) && reader.read_int("top_blue", tb) && reader.read_int("bottom_red", br) - && reader.read_int("bottom_green", br) + && reader.read_int("bottom_green", bg) && reader.read_int("bottom_blue", bb)) { set_gradient(Color(tr, tg, tb), Color(br, bg, bb)); } @@ -86,7 +86,7 @@ Background::set_image(const std::string& name, float speed) this->speed = speed; delete image; - image = new Surface(datadir + "/images/background/" + name, IGNORE_ALPHA); + image = new Surface(datadir + "/images/background/" + name, false); } void @@ -95,13 +95,26 @@ Background::set_gradient(Color top, Color bottom) type = GRADIENT; gradient_top = top; gradient_bottom = bottom; + + delete image; + image = new Surface(top, bottom, screen->w, screen->h); } void Background::draw(DrawingContext& context) { if(type == GRADIENT) { - context.draw_gradient(gradient_top, gradient_bottom, LAYER_BACKGROUND0); + /* In case we are using OpenGL just draw the gradient, else (software mode) + use the cache. */ + if(use_gl) + context.draw_gradient(gradient_top, gradient_bottom, LAYER_BACKGROUND0); + else + { + context.push_transform(); + context.set_translation(Vector(0, 0)); + context.draw_surface(image, Vector(0, 0), LAYER_BACKGROUND0); + context.pop_transform(); + } } else if(type == IMAGE) { int sx = int(-context.get_translation().x * speed) % image->w - image->w;